Skip to content

Commit

Permalink
add idempotency key on readme
Browse files Browse the repository at this point in the history
  • Loading branch information
taliyada committed Feb 6, 2024
1 parent 532e964 commit 34b6ff9
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 34b6ff9

Please sign in to comment.