Skip to content

Commit

Permalink
Merge pull request #308 from mercadopago/feature/add-idempotency-on-e…
Browse files Browse the repository at this point in the history
…xamples

add idempotency key on examples
  • Loading branch information
taliyada authored Feb 8, 2024
2 parents c3d47c3 + 0c652ce commit 6c5409f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ const body = {
},
};

// Step 5: Make the request
payment.create({ body }).then(console.log).catch(console.log);
// Step 5: Create request options object - Optional
const requestOptions = {
idempotencyKey: '<IDEMPOTENCY_KEY>',
};

// Step 6: Make the request
payment.create({ body, requestOptions }).then(console.log).catch(console.log);
```

### Step 1: Import the parts of the module you want to use
Expand Down
3 changes: 3 additions & 0 deletions src/examples/payment/cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ const payment = new Payment(client);

payment.cancel({
id: '<PAYMENT_ID>',
requestOptions: {
idempotencyKey: '<IDEMPOTENCY_KEY>'
},
}).then(console.log).catch(console.log);

3 changes: 3 additions & 0 deletions src/examples/payment/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ const payment = new Payment(client);
payment.capture({
id: '<PAYMENT_ID>',
transaction_amount: 12.34,
requestOptions: {
idempotencyKey: '<IDEMPOTENCY_KEY>'
},
}).then(console.log).catch(console.log);

3 changes: 3 additions & 0 deletions src/examples/payment/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ payment.create({ body: {
payer: {
email: '<EMAIL>'
},
},
requestOptions: {
idempotencyKey: '<IDEMPOTENCY_KEY>'
} }).then(console.log).catch(console.log);

0 comments on commit 6c5409f

Please sign in to comment.