AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PaymentGateway.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Commerce\Payments;
  3. use App\Models\Order;
  4. use App\Models\Store;
  5. /**
  6. * The one interface the app uses to take payments.
  7. * Stripe is the first provider. Another provider only needs a class that implements this.
  8. */
  9. interface PaymentGateway
  10. {
  11. /** The name saved on the order, such as "stripe". */
  12. public function name(): string;
  13. /**
  14. * Whether shoppers can pay this store now (with Stripe: the merchant connected their own account and Stripe approved it).
  15. */
  16. public function canTakePayments(Store $store): bool;
  17. /**
  18. * Create a payment page for the order and say where to send the shopper.
  19. *
  20. * @throws PaymentException
  21. */
  22. public function startCheckout(Order $order, string $successUrl, string $cancelUrl): CheckoutLink;
  23. /**
  24. * Ask the provider about the order's payment page, in the account it was made in.
  25. *
  26. * @throws PaymentException
  27. */
  28. public function checkPayment(Order $order): PaymentStatus;
  29. /**
  30. * Read a message the provider sent to our webhook address.
  31. * $fromMerchants is true for the address that hears about payments on merchants' own accounts.
  32. * Returns null when the message is about something we do not handle.
  33. *
  34. * @throws PaymentException When the message is not genuine.
  35. */
  36. public function readWebhook(string $payload, string $signature, bool $fromMerchants = false): ?PaymentStatus;
  37. }