Skip to content

Commit

Permalink
Merge pull request #497 from mercadopago/feature/add-idempotency-on-r…
Browse files Browse the repository at this point in the history
…eadme

add idempotency key on readme
  • Loading branch information
taliyada committed Feb 6, 2024
2 parents 532e964 + 34b6ff9 commit b456188
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ Simple usage looks like:
]
];

// Step 5: Make the request
$payment = $client->create($request);
// Step 5: Create the request options, setting X-Idempotency-Key
$request_options = new RequestOptions();
$request_options->setCustomHeaders(["X-Idempotency-Key: <SOME_UNIQUE_VALUE>"]);

// Step 6: Make the request
$payment = $client->create($request, $request_options);
echo $payment->id;

// Step 6: Handle exceptions
// Step 7: Handle exceptions
} catch (MPApiException $e) {
echo "Status code: " . $e->getApiResponse()->getStatusCode() . "\n";
echo "Content: ";
Expand Down Expand Up @@ -126,14 +130,19 @@ $request = [
]
];
```
### Step 5: Create the request options, setting X-Idempotency-Key
```php
$request_options = new RequestOptions();
$request_options->setCustomHeaders(["X-Idempotency-Key: <SOME_UNIQUE_VALUE>"]);
```

### Step 5: Make the request
### Step 6: Make the request

```php
$payment = $client->create($request);
$payment = $client->create($request, $request_options);
```

### Step 6: Handle exceptions
### Step 7: Handle exceptions

```php
try{
Expand Down

0 comments on commit b456188

Please sign in to comment.