1. Go to this page and download the library: Download rasuvaeff/payments-testing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rasuvaeff / payments-testing example snippets
use Rasuvaeff\PaymentsTesting\FakePaymentGateway;
$gateway = new FakePaymentGateway();
$attempt = $gateway->createPayment($request);
$sameAttempt = $gateway->retrievePayment(new RetrievePaymentRequest(
operationId: new OperationId(value: 'reconcile-1'),
payment: $attempt->payment,
));
use Rasuvaeff\PaymentsTesting\FakeGatewayConfig;
use Rasuvaeff\PaymentsTesting\FakeRefundGateway;
$gateway = new FakeRefundGateway(config: new FakeGatewayConfig(
provider: new PaymentProvider(value: 'fake'),
capabilities: CapabilitySet::of(new PartialRefundCapability()),
now: new \DateTimeImmutable('2025-06-01T12:00:00+00:00'),
createState: PaymentState::Pending,
));
use Rasuvaeff\PaymentsTesting\PaymentGatewayAssertions;
$capabilities = PaymentGatewayAssertions::assertCapabilities($gateway);
$attempt = PaymentGatewayAssertions::assertCreatePayment($gateway, $createRequest);
// Issues four calls: the key twice, then a distinct key, then the key with a
// changed amount. Checking only the replay would pass a gateway that ignores
// the key entirely and always answers with the same reference.
PaymentGatewayAssertions::assertCreatePaymentIdempotency($gateway, $keyedRequest);
PaymentGatewayAssertions::assertRetrievePayment($gateway, new RetrievePaymentRequest(
operationId: new OperationId(value: 'reconcile-1'),
payment: $attempt->payment,
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.