Search by

stetodd / payment-gateway

stetodd

Provider-neutral payment gateway contracts, models and test simulator

Package info

github.com/stetodd/payment-gateway

pkg:composer/stetodd/payment-gateway

Statistics

Installs: 250

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.7.1 2026-09-19 14:55 UTC

This package is auto-updated.

Last update: 2026-09-19 14:57:10 UTC


README

Provider-neutral payment gateway contracts: PaymentGatewayInterface, request/response models, and a SimulatorPaymentGateway test double.

Implementations live in separate packages (e.g. stetodd/stripe-gateway-bundle).

Install

composer require stetodd/payment-gateway

Usage

Type-hint Stetodd\PaymentGateway\PaymentGatewayInterface in your application code. Bind it to a concrete gateway implementation in your container.

In tests, use Stetodd\PaymentGateway\Testing\SimulatorPaymentGateway and queue responses with willReturnResponse(string $key, object $response).

Refunds and subscription payments

Seed a paid subscription invoice with recordSubscriptionPayment(SubscriptionPayment). That also registers its captured payment, so refundPayment() works against it. failNextRefund($reason) makes the next refund throw RefundFailedException. A RefundPaymentRequest given an idempotencyKey pays at most once per payment: a repeat under the same key returns the first refund, with the first refund's amount. refunds, refundedAmount($paymentId) and checkoutSessionRequests let you assert on what was sent.

Tests: composer install && vendor/bin/phpunit.