Skip to content

Commit

Permalink
Some cleanups and simplifications regarding retries
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Jul 26, 2024
1 parent 26995d8 commit 2c3bb3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 76 deletions.
70 changes: 0 additions & 70 deletions example/Transaction/example-authorize-retry.php

This file was deleted.

11 changes: 7 additions & 4 deletions example/Transaction/example-authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
true
);

// This library also supports retry requests.
// For more information on how and when Saferpay allows them, see
// https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/error-handling

# $requestConfig->setRequestId($requestId); // $responseOfPreviousTry->getRequestHeader()->getRequestId();
# $requestConfig->setRetryIndicator($retryIndicator); // a number between 0 and 9

// -----------------------------
// Step 2:
// Create the request with required data
Expand All @@ -32,10 +39,6 @@
$token,
);

// Note: More data can be provided to InitializeRequest with setters,
// for example: $authorizeRequest->setCondition()
// See Saferpay documentation for available options.

// -----------------------------
// Step 3:
// Execute and check for successful response
Expand Down
8 changes: 6 additions & 2 deletions lib/SaferpayJson/Request/RequestConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class RequestConfig
private string $apiSecret;
private string $customerId;
private bool $test;

private ?Client $client = null;
private ?string $requestId = null;
private int $retryIndicator = self::MIN_RETRY_INDICATOR;
Expand Down Expand Up @@ -83,8 +84,11 @@ public function getRequestId(): ?string
public function setRetryIndicator(int $retryIndicator): self
{
if ($retryIndicator < self::MIN_RETRY_INDICATOR || $retryIndicator > self::MAX_RETRY_INDICATOR) {
throw new InvalidArgumentException('Retry indicator range: inclusive between '
. self::MIN_RETRY_INDICATOR . ' and ' . self::MAX_RETRY_INDICATOR);
throw new InvalidArgumentException(sprintf(
'Retry indicator range: inclusive between %s and %s.',
self::MIN_RETRY_INDICATOR,
self::MAX_RETRY_INDICATOR
));
}

$this->retryIndicator = $retryIndicator;
Expand Down

0 comments on commit 2c3bb3d

Please sign in to comment.