| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?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 first provider. 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;
-
- /**
- * 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;
- }
|