NewSupefinaSpeiLogic.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <?php
  2. namespace App\Http\logic\api;
  3. use App\dao\Estatisticas\RechargeWithDraw;
  4. use App\dao\Pay\PayController;
  5. use App\Http\helper\CreateOrder;
  6. use App\Http\helper\NumConfig;
  7. use App\Jobs\Order;
  8. use App\Models\PrivateMail;
  9. use App\Models\RecordUserDataStatistics;
  10. use App\Services\Aes;
  11. use App\Services\OrderServices;
  12. use App\Services\PayConfig;
  13. use App\Services\StoredProcedure;
  14. use App\Services\SupefinaSpei;
  15. use App\Services\CreateLog;
  16. use App\Util;
  17. use GuzzleHttp\Client;
  18. use Illuminate\Support\Facades\DB;
  19. use Illuminate\Support\Facades\Redis;
  20. /**
  21. * Supefina SPEI
  22. *
  23. */
  24. class NewSupefinaSpeiLogic extends BaseApiLogic
  25. {
  26. const AGENT = 108;
  27. public $result;
  28. public function pay_order($userId, $pay_amount, $userPhone, $userEmail, $userName, $GiftsID, $buyIP, $AdId, $eventType, $pay_method = '')
  29. {
  30. $PayVerify = new PayController();
  31. $pay_amount = $PayVerify->verify($userId, $GiftsID, $pay_amount);
  32. if ($PayVerify->verify($userId, $GiftsID, $pay_amount) === false) {
  33. $this->error = $PayVerify->getError();
  34. return false;
  35. }
  36. if ($pay_amount < 0) {
  37. $this->error = 'Payment error_4';
  38. return false;
  39. }
  40. $service = new SupefinaSpei('NewSupefinaSpei');
  41. $config = $service->config;
  42. $merId = $config['merId'] ?? '';
  43. $baseUrl = $config['baseUrl'] ?? '';
  44. $payinPath = $config['payinPath'] ?? '/api/supefina/transactions/collection';
  45. $callbackUrl = $config['callbackUrl'] ?? '';
  46. $countryId = $config['countryId'] ?? 'MX';
  47. $currency = $config['currency'] ?? 'MXN';
  48. $aesKey = $config['aesKey'] ?? '';
  49. $privateKey = $config['privateKey'] ?? '';
  50. $productNo = $config['productNo'] ?? '';
  51. if ($merId === '' || $baseUrl === '' || empty($privateKey) || $callbackUrl === '') {
  52. $this->error = 'Payment config error';
  53. return false;
  54. }
  55. $order_sn = CreateOrder::order_sn($userId);
  56. $logic = new OrderLogic();
  57. $amount = (int)round($pay_amount * NumConfig::NUM_VALUE);
  58. $logic->orderCreate($order_sn, $amount, 'NewSupefinaSpei', $userId, $pay_method, $GiftsID, $AdId, $eventType);
  59. $orderAmount = (string)(int)$pay_amount;
  60. if ($pay_amount != (int)$pay_amount) {
  61. $orderAmount = number_format($pay_amount, 2, '.', '');
  62. }
  63. $params = [
  64. 'merchantOrderNo' => $order_sn,
  65. 'amount' => $orderAmount,
  66. 'country' => $countryId,
  67. 'currency' => $currency,
  68. 'notifyUrl' => $callbackUrl,
  69. ];
  70. $headers = [
  71. 'version' => '1.0.0',
  72. 'merchantNo' => $merId,
  73. 'requestId' => mt_rand(100000, 999999) . time(),
  74. 'requestTime' => time() * 1000,
  75. ];
  76. $body = [
  77. 'productNo' => $productNo,
  78. 'data' => Aes::encrypt(json_encode($params), base64_decode($aesKey)),
  79. ];
  80. $sign = $this->sign($headers, $body, $privateKey);
  81. $headers['sign'] = $sign;
  82. $request_extra = \GuzzleHttp\json_encode(array_merge($headers, $params));
  83. CreateLog::pay_request($userPhone, $request_extra, $order_sn, $userEmail, $userId, $userName);
  84. $url = rtrim($baseUrl, '/') . $payinPath;
  85. Util::WriteLog('NewSupefinaSpei', 'payin request: ' . $url . ' | ' . $request_extra);
  86. try {
  87. $client = new Client();
  88. $result = $client->post($url, [
  89. 'headers' => $headers,
  90. 'json' => $body,
  91. ])->getBody()->getContents();
  92. } catch (\Throwable $e) {
  93. Util::WriteLog('NewSupefinaSpei_error', 'payin request exception: ' . $e->getMessage());
  94. $this->error = 'Payment processing error';
  95. return false;
  96. }
  97. Util::WriteLog('NewSupefinaSpei', 'payin response: ' . $result);
  98. try {
  99. $data = \GuzzleHttp\json_decode($result, true);
  100. } catch (\Throwable $e) {
  101. Util::WriteLog('NewSupefinaSpei_error', [$result, $e->getMessage()]);
  102. $this->error = 'Payment processing error';
  103. return false;
  104. }
  105. if (!isset($data['success']) || $data['success'] !== true) {
  106. $this->error = $data['message'] ?? 'Payment request failed';
  107. return false;
  108. }
  109. $decryptData = Aes::decrypt($data['data'], base64_decode($aesKey));
  110. Util::WriteLog('NewSupefinaSpei', 'payin response1: ' . $decryptData);
  111. $this->result = json_decode($decryptData, true);
  112. return $this->result;
  113. }
  114. /**
  115. * 代收回调:仅代收存在“实际金额与订单金额不一致”,以 realityAmount 入账
  116. *
  117. * @param array<string,mixed> $post
  118. */
  119. public function notify($post)
  120. {
  121. $order_sn = $post['merchantOrderNo'];
  122. if ($order_sn === '') {
  123. Util::WriteLog('NewSupefinaSpei_error', 'payin notify missing merchantOrderNo');
  124. return 'fail';
  125. }
  126. try {
  127. $order = DB::connection('write')->table('agent.dbo.order')
  128. ->lock('with(nolock)')
  129. ->where('order_sn', $order_sn)->first();
  130. if (!$order) {
  131. $orderArr = explode('-', $order_sn);
  132. if (count($orderArr) > 1) {
  133. $order_sn1 = $orderArr[0];
  134. $order = DB::connection('write')->table('agent.dbo.order')
  135. ->lock('with(nolock)')
  136. ->where('order_sn', $order_sn1)
  137. ->first();
  138. if (!$order) {
  139. Util::WriteLog('NewSupefinaSpei_error', 'payin notify order not found: ' . $order_sn);
  140. }
  141. }
  142. }
  143. if (!empty($order->pay_at) || !empty($order->finished_at)) {
  144. if ($order->payment_sn != $post['platformOrderNo']) {
  145. $logic = new OrderLogic();
  146. $amount = 100;
  147. $order_sn = $order_sn . '#' . time();
  148. $logic->orderCreate($order_sn, $amount, 'NewSupefinaSpei', $order->user_id);
  149. $order = DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)
  150. ->first();
  151. } else {
  152. return '{"success":true}';
  153. }
  154. }
  155. $status = (string)($post['transStatus'] ?? '');
  156. if (in_array($status, ['FAILED', 'CLOSED', 'CANCELED'])) {
  157. $body = ['pay_status' => 2, 'updated_at' => date('Y-m-d H:i:s')];
  158. DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)->update($body);
  159. return '{"success":true}';
  160. }
  161. if (in_array($status, ['REFUNDING', 'PARTIAL_REFUND', 'REFUNDED'])) {
  162. Util::WriteLog('NewSupefinaSpei', 'payin notify status refund: ' . $order_sn);
  163. return '{"success":true}';
  164. }
  165. if ($status !== 'SUCCESS') {
  166. Util::WriteLog('NewSupefinaSpei', 'payin notify status not success: ' . $order_sn);
  167. return '{"success":true}';
  168. }
  169. $GiftsID = $order->GiftsID ?: '';
  170. $userID = $order->user_id ?: '';
  171. $AdId = $order->AdId ?: '';
  172. $eventType = $order->eventType ?: '';
  173. $realityAmount = isset($post['amount']) ? (float)$post['amount'] : (float)($post['amount'] ?? 0);
  174. if ($realityAmount <= 0) {
  175. Util::WriteLog('NewSupefinaSpei_error', 'payin notify invalid realityAmount: ' . json_encode($post));
  176. return 'fail';
  177. }
  178. $payAmt = round($realityAmount, 2);
  179. $amountInScore = (int)round($payAmt * NumConfig::NUM_VALUE);
  180. $body = [
  181. 'payment_sn' => $post['platformOrderNo'] ?? '',
  182. 'pay_status' => 1,
  183. 'pay_at' => date('Y-m-d H:i:s'),
  184. 'finished_at' => date('Y-m-d H:i:s'),
  185. 'amount' => $amountInScore,
  186. 'updated_at' => date('Y-m-d H:i:s'),
  187. ];
  188. $body['payment_fee'] = $post['fee'] ?? 0;
  189. $service = new OrderServices();
  190. if ((int)$order->amount != $amountInScore) {
  191. $body['GiftsID'] = 0;
  192. $body['amount'] = $amountInScore;
  193. $Recharge = $payAmt;
  194. $give = 0;
  195. $favorable_price = $Recharge + $give;
  196. $czReason = 1;
  197. $cjReason = 45;
  198. } else {
  199. [$give, $favorable_price, $Recharge, $czReason, $cjReason] = $service->getPayInfo($GiftsID, $userID, $payAmt);
  200. }
  201. [$Score] = $service->addRecord($userID, $payAmt, $favorable_price, $order_sn, $GiftsID, $Recharge, $czReason, $give, $cjReason, $AdId, $eventType,
  202. $body['payment_fee'] ?? 0);
  203. Order::dispatch([$userID, $payAmt, $Score, $favorable_price, $GiftsID, $order_sn]);
  204. DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)->update($body);
  205. Util::WriteLog('NewSupefinaSpei', 'payin success, order_sn=' . $order_sn . ', realityAmount=' . $realityAmount);
  206. return '{"success":true}';
  207. } catch (\Throwable $exception) {
  208. Util::WriteLog('NewSupefinaSpei_error', $exception->getMessage() . "\n" . $exception->getTraceAsString());
  209. throw $exception;
  210. }
  211. }
  212. public function payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum, $PixType, $IFSCNumber, $BranchBank, $BankNO)
  213. {
  214. // 查询提现订单
  215. $query = DB::connection('write')
  216. ->table('QPAccountsDB.dbo.OrderWithDraw')
  217. ->where('RecordID', $RecordID)
  218. ->first();
  219. if (!$query) {
  220. Util::WriteLog('NewSupefinaSpei', 'withdraw order not found: ' . $RecordID);
  221. return 'fail';
  222. }
  223. $config = (new PayConfig())->getConfig('NewSupefinaSpei');
  224. // 账户号:优先 PixNum,其次 BankNO
  225. $account = $PixNum ?: $BankNO;
  226. if (!$account) {
  227. Util::WriteLog('NewSupefinaSpei_error', 'missing account for withdraw: ' . $OrderId);
  228. return 'fail';
  229. }
  230. // 银行编号:优先 BankNO(如果看作 bankId),否则使用配置默认
  231. $bankId = $BranchBank;
  232. if ($bankId === '') {
  233. Util::WriteLog('NewSupefinaSpei_error', 'missing bankId for withdraw: ' . $OrderId);
  234. return 'fail';
  235. }
  236. // 提现金额是以分存储,转成两位小数金额
  237. $orderAmount = number_format($amount / 100, 2, '.', '');
  238. $bankList = config('games.mex_bank_list');
  239. try {
  240. $now = time() * 1000;
  241. $data = [
  242. 'transTime' => $now,
  243. 'merchantOrderNo' => $OrderId,
  244. 'amount' => (string)$orderAmount,
  245. 'country' => $config['country'] ?? 'MX',
  246. 'currency' => $config['currency'] ?? 'MXN',
  247. 'payeeInfo' => [
  248. 'accountInfo' => [
  249. 'accountNo' => $account,
  250. 'accountType' => mb_strlen($account) == 16 ? '20' : '10',
  251. ],
  252. 'bankInfo' => [
  253. 'bankCode' => $bankId,
  254. 'bankName' => $bankList[$bankId] ?? 'bank',
  255. ],
  256. 'payeeName' => $accountName ?: 'slot777',
  257. ],
  258. 'notifyUrl' => $config['cashCallbackUrl'],
  259. ];
  260. $url = $config['baseUrl'] . $config['transferPath'];
  261. $result = $this->sendRequest($url, 'TRANSFER', $data);
  262. if ($result === false) {
  263. return 'fail';
  264. }
  265. } catch (\Throwable $e) {
  266. Util::WriteLog('NewSupefinaSpei_error', 'payout request exception: ' . $e->getMessage());
  267. return '';
  268. }
  269. try {
  270. $responseData = \GuzzleHttp\json_decode($result, true);
  271. } catch (\Throwable $e) {
  272. Util::WriteLog('NewSupefinaSpei_error', [$result, $e->getMessage()]);
  273. $this->error = 'Payment processing error';
  274. return false;
  275. }
  276. if (!isset($responseData['success']) || $responseData['success'] !== true) {
  277. $this->error = $responseData['message'] ?? 'request failed';
  278. // 同步下单失败:如果订单在处理中(State=5),退回资金并标记失败
  279. if ((int)$query->State === 5) {
  280. $msg = $data['msg'] ?? 'NewSupefinaSpei payout failed';
  281. $WithDraw = $query->WithDraw + $query->ServiceFee;
  282. $bonus = '30000,' . $WithDraw;
  283. PrivateMail::failMail($query->UserID, $OrderId, $WithDraw, $msg, $bonus);
  284. $withdraw_data = [
  285. 'State' => 6,
  286. 'agent' => self::AGENT,
  287. 'finishDate' => now(),
  288. 'remark' => json_encode($data),
  289. ];
  290. DB::connection('write')
  291. ->table('QPAccountsDB.dbo.OrderWithDraw')
  292. ->where('OrderId', $query->OrderId)
  293. ->update($withdraw_data);
  294. $RecordData = ['after_state' => 6, 'update_at' => now()];
  295. DB::connection('write')
  296. ->table('QPAccountsDB.dbo.AccountsRecord')
  297. ->where('type', 1)
  298. ->where('RecordID', $RecordID)
  299. ->update($RecordData);
  300. }
  301. return 'fail';
  302. }
  303. $decryptData = Aes::decrypt($responseData['data'], base64_decode($config['aesKey']));
  304. Util::WriteLog('NewSupefinaSpei', 'transfer decrypt response: ' . $decryptData);
  305. $this->result = json_decode($decryptData, true);
  306. return $this->result;
  307. }
  308. public function cashNotify($post)
  309. {
  310. $OrderId = $post['merchantOrderNo'];
  311. if ($OrderId === '') {
  312. Util::WriteLog('NewSupefinaSpei_error', 'payout notify missing merchantOrderNo');
  313. return 'fail';
  314. }
  315. $query = DB::connection('write')
  316. ->table('QPAccountsDB.dbo.OrderWithDraw')
  317. ->where('OrderId', $OrderId)
  318. ->first();
  319. if (!$query) {
  320. Util::WriteLog('NewSupefinaSpei_error', 'withdraw order not found in notify: '.$OrderId);
  321. return '{"success":true}';
  322. }
  323. // 只处理 State=5 或 7 的订单,避免重复
  324. if (!in_array((int)$query->State, [5, 7], true)) {
  325. Util::WriteLog('NewSupefinaSpei', 'withdraw already handled: '.$OrderId);
  326. return '{"success":true}';
  327. }
  328. $status = $post['transStatus'] ?? '';
  329. $orderStatus = 0;
  330. if (in_array($status, ['SUCCESS'], true)) {
  331. $orderStatus = 1; // 成功
  332. } elseif (in_array($status, ['FAILED', 'CANCELED', 'REFUNDED'])) {
  333. $orderStatus = 2; // 失败
  334. }
  335. if ($orderStatus === 0) {
  336. Util::WriteLog('NewSupefinaSpei', 'payout processing: '.$OrderId.' status='.$status);
  337. return '{"success":true}';
  338. }
  339. $agentID = DB::connection('write')
  340. ->table('agent.dbo.admin_configs')
  341. ->where('config_value', self::AGENT)
  342. ->where('type', 'cash')
  343. ->value('id') ?? '';
  344. $now = now();
  345. $UserID = $query->UserID;
  346. $TakeMoney = $query->WithDraw + $query->ServiceFee;
  347. // Supefina 回调里带有 amount/fee 和 realityAmount/realityFee
  348. // 提醒:这里仍以我们订单金额为准做账,仅将真实金额用于日志,可根据需要扩展到统计侧。
  349. $realityAmount = isset($post['amount']) ? (float)$post['amount'] : null;
  350. $realityFee = isset($post['fee']) ? (float)$post['fee'] : null;
  351. Util::WriteLog('NewSupefinaSpei', 'payout reality: amount='.$realityAmount.', fee='.$realityFee.', orderId='.$OrderId);
  352. $withdraw_data = [];
  353. switch ($orderStatus) {
  354. case 1: // 提现成功
  355. $withdraw_data = [
  356. 'State' => 2,
  357. 'agent' => $agentID,
  358. 'finishDate' => $now,
  359. 'withdraw_fee' => $realityFee * NumConfig::NUM_VALUE,
  360. ];
  361. // 增加提现记录
  362. $first = DB::connection('write')
  363. ->table('QPAccountsDB.dbo.UserTabData')
  364. ->where('UserID', $UserID)
  365. ->first();
  366. if ($first) {
  367. DB::connection('write')
  368. ->table('QPAccountsDB.dbo.UserTabData')
  369. ->where('UserID', $UserID)
  370. ->increment('TakeMoney', $TakeMoney);
  371. } else {
  372. DB::connection('write')
  373. ->table('QPAccountsDB.dbo.UserTabData')
  374. ->insert(['TakeMoney' => $TakeMoney, 'UserID' => $UserID]);
  375. try {
  376. PrivateMail::praiseSendMail($UserID);
  377. } catch (\Throwable $e) {
  378. // 忽略邮件发送失败
  379. }
  380. }
  381. // 免审记录
  382. $withdrawal_position_log = DB::connection('write')
  383. ->table('agent.dbo.withdrawal_position_log')
  384. ->where('order_sn', $OrderId)
  385. ->first();
  386. if ($withdrawal_position_log) {
  387. DB::connection('write')
  388. ->table('agent.dbo.withdrawal_position_log')
  389. ->where('order_sn', $OrderId)
  390. ->update(['take_effect' => 2, 'update_at' => date('Y-m-d H:i:s')]);
  391. }
  392. try {
  393. StoredProcedure::addPlatformData($UserID, 4, $TakeMoney);
  394. } catch (\Throwable $exception) {
  395. Util::WriteLog('StoredProcedure', $exception->getMessage());
  396. }
  397. $ServiceFee = $query->ServiceFee;
  398. RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $ServiceFee);
  399. $fee = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
  400. ->value('withdraw_fee');
  401. (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $realityFee * NumConfig::NUM_VALUE, $ServiceFee);
  402. $redis = Redis::connection();
  403. $redis->incr('draw_'.date('Ymd').$UserID);
  404. break;
  405. case 2: // 提现失败
  406. $msg = $post['msg'] ?? 'Withdraw rejected';
  407. $bonus = '30000,'.$TakeMoney;
  408. PrivateMail::failMail($query->UserID, $OrderId, $TakeMoney, $msg, $bonus);
  409. Util::WriteLog('SupefinaSpeiEmail', [$query->UserID, $OrderId, $TakeMoney, $msg, $bonus]);
  410. $withdraw_data = [
  411. 'State' => 6,
  412. 'agent' => $agentID,
  413. 'remark' => $msg,
  414. ];
  415. break;
  416. }
  417. $RecordData = [
  418. 'before_state' => $query->State,
  419. 'after_state' => $withdraw_data['State'] ?? 0,
  420. 'RecordID' => $query->RecordID,
  421. 'update_at' => date('Y-m-d H:i:s'),
  422. ];
  423. DB::connection('write')
  424. ->table('QPAccountsDB.dbo.AccountsRecord')
  425. ->updateOrInsert(
  426. ['RecordID' => $query->RecordID, 'type' => 1],
  427. $RecordData
  428. );
  429. DB::connection('write')
  430. ->table('QPAccountsDB.dbo.OrderWithDraw')
  431. ->where('OrderId', $OrderId)
  432. ->update($withdraw_data);
  433. if (isset($withdraw_data['State']) && (int)$withdraw_data['State'] === 2) {
  434. StoredProcedure::user_label($UserID, 2, $TakeMoney);
  435. }
  436. return '{"success":true}';
  437. }
  438. public function getSignString($headers, $data)
  439. {
  440. $params = array_merge($headers, $data);
  441. $filtered = [];
  442. foreach ($params as $k => $v) {
  443. if (strtolower($k) === 'sign') {
  444. continue;
  445. }
  446. if ($v === null) {
  447. continue;
  448. }
  449. $filtered[$k] = $v;
  450. }
  451. ksort($filtered);
  452. $parts = [];
  453. foreach ($filtered as $k => $v) {
  454. $parts[] = $k . '=' . $v;
  455. }
  456. $signString = implode('&', $parts);
  457. return $signString;
  458. }
  459. public function sign($headers, $data, $key)
  460. {
  461. $signString = $this->getSignString($headers, $data);
  462. $res = openssl_pkey_get_private("-----BEGIN PRIVATE KEY-----\n" . $key . "\n-----END PRIVATE KEY-----");
  463. openssl_sign(
  464. $signString,
  465. $signature,
  466. $res,
  467. OPENSSL_ALGO_SHA256 // RSA2 核心
  468. );
  469. return base64_encode($signature);
  470. }
  471. public function verifySign($data, $sign, $key)
  472. {
  473. $res = openssl_pkey_get_public("-----BEGIN PUBLIC KEY-----\n" . $key . "\n-----END PUBLIC KEY-----");
  474. $result = openssl_verify(
  475. $data,
  476. base64_decode($sign),
  477. $res,
  478. OPENSSL_ALGO_SHA256
  479. );
  480. return $result === 1;
  481. }
  482. private function sendRequest($url, $productNo, $data)
  483. {
  484. $config = (new PayConfig())->getConfig('NewSupefinaSpei');
  485. $headers = [
  486. 'version' => '1.0.0',
  487. 'merchantNo' => $config['merId'] ?? '',
  488. 'requestId' => mt_rand(100000, 999999) . time(),
  489. 'requestTime' => time() * 1000,
  490. ];
  491. $body = [
  492. 'productNo' => $productNo,
  493. 'data' => Aes::encrypt(json_encode($data), base64_decode($config['aesKey'])),
  494. ];
  495. $sign = $this->sign($headers, $body, $config['privateKey']);
  496. $headers['sign'] = $sign;
  497. try {
  498. $client = new Client();
  499. Util::WriteLog('NewSupefinaSpei', $productNo . ' request: ' . $url . ' | ' . json_encode($data) . '|' . json_encode($headers));
  500. $result = $client->post($url, [
  501. 'headers' => $headers,
  502. 'json' => $body,
  503. ])->getBody()->getContents();
  504. Util::WriteLog('NewSupefinaSpei', $productNo . ' response: ' . $result);
  505. return $result;
  506. } catch (\Throwable $e) {
  507. Util::WriteLog('NewSupefinaSpei_error', $productNo . ' request exception: ' . $e->getMessage());
  508. $this->error = 'Payment processing error';
  509. return false;
  510. }
  511. }
  512. }