Skip to content

Commit

Permalink
Merge pull request #25 from ebangug/feature/retrieve-source
Browse files Browse the repository at this point in the history
Feature/retrieve source
  • Loading branch information
jofftiquez authored Jan 9, 2021
2 parents 144fc8f + c36b719 commit c7d5adc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ If you like this project, please give it a star, and consider following the auth
- [Retrieve](#payment-intents---retrieve)
- [Sources](#sources)
- [Create](#sources---create)
- [Retrieve](#sources---retrieve)
- [Payments](#payments)
- [Create](#payments---create)
- [List](#payments---list)
Expand Down Expand Up @@ -221,6 +222,15 @@ const result = await paymongo.sources.create(data);
}
}
```

#### Sources - Retrieve

```javascript
/**
* @param {string} id Source id
*/
const result = await paymongo.sources.retrieve(id);
```
[Go back to top ⮝](#contents)

### PAYMENTS
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createPaymentMethod, retrievePaymentMethod } from './payment-methods/index';
import { createPaymentIntent, retrievePaymentIntent, attachToPaymentIntent } from './payment-intents/index';
import { createToken, retrieveToken } from './tokens/index';
import { createSource } from './sources/index';
import { createSource, retrieveSource } from './sources/index';
import { createPayment, retrievePayment, listPayments } from './payments/index';
import { createWebhook, retrieveWebhook, listWebhooks, toggleWebhook } from './webhooks/index';

Expand All @@ -25,6 +25,7 @@ export default class Paymongo {
// SOURCES
this.sources = {
create: (data) => createSource(this.secret, data),
retrieve: (id) => retrieveSource(this.secret, id),
};
// PAYMENTS
this.payments = {
Expand Down
14 changes: 14 additions & 0 deletions src/sources/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,17 @@ export const createSource = async (secret, data) => {
data,
});
};


/**
* @param {string} secret API private key
* @param {string} id Source id
*/
export const retrieveSource = async (secret, id) => {
if (!id) throw new Error('Source id is required.');
return makeRequest({
secret,
method: 'GET',
path: `/sources/${id}`,
});
};
Loading

0 comments on commit c7d5adc

Please sign in to comment.