Skip to content

Commit

Permalink
add idempotency on documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
taliyada committed Feb 6, 2024
1 parent e2c1aaa commit 48e8f38
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ require 'mercadopago'

sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN')

payment_data = {
transaction_amount: 100,
token: 'CARD_TOKEN',
description: 'Payment description',
payment_method_id: 'visa',
installments: 1,
payer: {
email: '[email protected]'
custom_headers = {
'x-idempotency-key': '<SOME_UNIQUE_VALUE>'
}

custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers)

payment_request = {
transaction_amount: 100,
token: 'CARD_TOKEN',
installments: 1,
payer: {
type: 'customer',
id: '123456789-jxOV430go9fx2e'
}
}
result = sdk.payment.create(payment_data)
payment = result[:response]
payment_response = sdk.payment.create(payment_request, custom_request_options)
payment = payment_response[:response]

puts payment
```
Expand Down

0 comments on commit 48e8f38

Please sign in to comment.