| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
-
- namespace App\Commerce\Payments;
-
- use App\Models\Order;
- use App\Models\Store;
-
- /**
- * The one interface the app uses to take payments.
- * Stripe is the main provider and HitPay the second (PaymentGateways). Another provider only needs a class that implements this.
- */
- interface PaymentGateway
- {
- /** The name saved on the order, such as "stripe". */
- public function name(): string;
-
- /**
- * Whether shoppers can pay this store now (with Stripe: the merchant connected their own account and Stripe approved it).
- */
- public function canTakePayments(Store $store): bool;
-
- /**
- * The payment methods shoppers will see on this provider's page, such as ["card", "fpx", "grabpay"].
- *
- * @return list<string>
- */
- public function methods(Store $store): array;
-
- /**
- * Create a payment page for the order and say where to send the shopper.
- *
- * @throws PaymentException
- */
- public function startCheckout(Order $order, string $successUrl, string $cancelUrl): CheckoutLink;
-
- /**
- * Ask the provider about the order's payment page, in the account it was made in.
- *
- * @throws PaymentException
- */
- public function checkPayment(Order $order): PaymentStatus;
-
- /**
- * Read a message the provider sent to our webhook address.
- * $fromMerchants is true for the address that hears about payments on merchants' own accounts.
- * Returns null when the message is about something we do not handle.
- *
- * @throws PaymentException When the message is not genuine.
- */
- public function readWebhook(string $payload, string $signature, bool $fromMerchants = false): ?PaymentStatus;
- }
|