xendit-node
Advanced tools
Comparing version 1.21.7 to 1.21.8
@@ -18,2 +18,3 @@ console.log('Starting Integration Test...'); // eslint-disable-line no-console | ||
require('./transaction.test')(), | ||
// require('./refund.test')() //test disabled until refunds endpoint is fixed | ||
]) | ||
@@ -20,0 +21,0 @@ .then(() => { |
{ | ||
"name": "xendit-node", | ||
"version": "1.21.7", | ||
"version": "1.21.8", | ||
"description": "NodeJS client for Xendit API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -119,2 +119,6 @@ # Xendit API Node.js Client | ||
- [Create fee rules](#create-fee-rules) | ||
- [Refund Services](#refund-services) | ||
- [Create refund](#create-refund-1) | ||
- [List refunds](#list-refunds) | ||
- [Get refund details by ID](#get-refund-details-by-id) | ||
- [Contributing](#contributing) | ||
@@ -1603,2 +1607,64 @@ | ||
### Refund Services | ||
Instanitiate Refund service using constructor that has been injected with Xendit keys | ||
```js | ||
const { Refund } = x; | ||
const r = new Refund(); | ||
``` | ||
Example: Create a refund | ||
```js | ||
r.createRefund({ | ||
invoice_id: 'your-invoice-id', | ||
reason: 'FRAUDULENT', | ||
amount: 1000, | ||
}).then(({ id }) => { | ||
console.log(`refund created with ID: ${id}`); | ||
}); | ||
``` | ||
Refer to [Xendit API Reference](https://developers.xendit.co/api-reference/#refunds) for more info about methods' parameters | ||
#### Create refund | ||
```ts | ||
r.createRefund(data: { | ||
payment_request_id?: string; | ||
reference_id?: string; | ||
invoice_id?: string; | ||
currency?: string; | ||
amount?: number; | ||
reason: RefundReasons; | ||
metadata?: object; | ||
idempotencty_key?: string; | ||
for_user_id?: string; | ||
}) | ||
``` | ||
#### List refunds | ||
```ts | ||
r.listRefunds(data: { | ||
payment_request_id?: string; | ||
invoice_id?: string; | ||
payment_method_type?: string; | ||
channel_code?: string; | ||
limit?: number; | ||
after_id?: string; | ||
before_id?: string; | ||
for_user_id?: string; | ||
}) | ||
``` | ||
#### Get refund details by ID | ||
```ts | ||
r.getRefundById(data: { | ||
id: string; | ||
}) | ||
``` | ||
## Contributing | ||
@@ -1605,0 +1671,0 @@ |
@@ -19,2 +19,3 @@ import Errors from './errors'; | ||
import { TransactionService } from './transaction'; | ||
import { RefundService } from './refund'; | ||
@@ -41,3 +42,4 @@ declare class Xendit { | ||
Transaction: typeof TransactionService; | ||
Refund: typeof RefundService; | ||
} | ||
export = Xendit; |
@@ -18,2 +18,3 @@ const { CardService } = require('./card'); | ||
const { TransactionService } = require('./transaction'); | ||
const { RefundService } = require('./refund'); | ||
const Errors = require('./errors'); | ||
@@ -61,2 +62,3 @@ | ||
); | ||
this.Refund = RefundService._constructorWithInjectedXenditOpts(this.opts); | ||
} | ||
@@ -63,0 +65,0 @@ |
257063
200
7136
1688