AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

HitPayWebhookController.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Commerce\Checkout;
  4. use App\Commerce\Payments\HitPay\HitPayGateway;
  5. use App\Commerce\Payments\PaymentException;
  6. use App\Models\Order;
  7. use Illuminate\Http\Response;
  8. /**
  9. * HitPay calls this address when an order's payment page changes. The address names the order.
  10. *
  11. * Nothing in the message is trusted: it only tells us to ask HitPay about the order, with the merchant's own key,
  12. * the same way the shopper's return page does. So a fake message cannot mark an order paid.
  13. * It is the safety net for shoppers who pay but close the browser before coming back to the store.
  14. */
  15. class HitPayWebhookController extends Controller
  16. {
  17. public function __invoke(string $publicId, HitPayGateway $hitpay, Checkout $checkout): Response
  18. {
  19. $order = Order::query()
  20. ->where('public_id', $publicId)
  21. ->where('payment_provider', $hitpay->name())
  22. ->first();
  23. if ($order !== null && ! $order->isPaid()) {
  24. try {
  25. $checkout->markPaid($order, $hitpay->checkPayment($order));
  26. } catch (PaymentException $e) {
  27. report($e);
  28. }
  29. }
  30. return response('OK');
  31. }
  32. }