AegPayController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\logic\api\AegPayCashierLogic;
  4. use App\Http\logic\api\AegPayLogic;
  5. use App\Http\logic\api\NicePayCashierLogic;
  6. use App\Http\logic\api\NicePayLogic;
  7. use App\Inter\PayMentInterFace;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Facades\Log;
  10. class AegPayController implements PayMentInterFace
  11. {
  12. public function pay_order($userId, $payAmt, $userName, $userEmail, $userPhone, $GiftsID, $buyIp, $AdId, $eventType, $pay_method = '')
  13. {
  14. $logic = new AegPayLogic();
  15. $res = $logic->pay_order($userId, $payAmt, $userPhone, $userEmail, $userName, $GiftsID, $buyIp, $AdId, $eventType);
  16. if ($res === false) {
  17. return apiReturnFail($logic->getError());
  18. }
  19. //{"status":200,"response":
  20. //{"orderId":"bd03a92f-7c77-4c76-9bac-842c84127e39",
  21. //"redirectUrl":"https://www.aegpay.tech/checkout/sfp/bd03a92f-7c77-4c76-9bac-842c84127e39/enter-cpf"}}
  22. if (!empty($res)) {
  23. $data = [
  24. 'content' => urldecode($res['code']),
  25. 'money' => $payAmt,
  26. 'url'=>$res['payUrl'],
  27. 'prdOrdNo' => $res['orderNo'],
  28. ];
  29. return apiReturnSuc($data);
  30. }else{
  31. return 'Erro de pagamento.';
  32. }
  33. }
  34. // 支付异步回调
  35. public function notify(Request $request)
  36. {
  37. $post = $request->all();
  38. if (!is_array($post)) {
  39. $post = \GuzzleHttp\json_decode($post, true);
  40. }
  41. Log::channel('aegPay')->info('aegPay支付异步回调'.json_encode($post));
  42. $logic = new AegPayLogic();
  43. return $logic->notify($post['response']);
  44. }
  45. // 提现异步回调
  46. public function cash_notify(Request $request)
  47. {
  48. $post = $request->all();
  49. if (!is_array($post)) {
  50. $post = \GuzzleHttp\json_decode($post, true);
  51. }
  52. Log::channel('aegPay')->info('aegPay提现异步回调'.json_encode($post));
  53. $logic = new AegPayCashierLogic();
  54. return $logic->notify($post['response']);
  55. }
  56. }