AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

PaymentGateway.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 main provider and HitPay the second (PaymentGateways). 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. * The payment methods shoppers will see on this provider's page, such as ["card", "fpx", "grabpay"].
  19. *
  20. * @return list<string>
  21. */
  22. public function methods(Store $store): array;
  23. /**
  24. * Create a payment page for the order and say where to send the shopper.
  25. *
  26. * @throws PaymentException
  27. */
  28. public function startCheckout(Order $order, string $successUrl, string $cancelUrl): CheckoutLink;
  29. /**
  30. * Ask the provider about the order's payment page, in the account it was made in.
  31. *
  32. * @throws PaymentException
  33. */
  34. public function checkPayment(Order $order): PaymentStatus;
  35. /**
  36. * Read a message the provider sent to our webhook address.
  37. * $fromMerchants is true for the address that hears about payments on merchants' own accounts.
  38. * Returns null when the message is about something we do not handle.
  39. *
  40. * @throws PaymentException When the message is not genuine.
  41. */
  42. public function readWebhook(string $payload, string $signature, bool $fromMerchants = false): ?PaymentStatus;
  43. }