NewSupefinaSpeiLogic.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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. }
  139. }
  140. if (!empty($order->pay_at) || !empty($order->finished_at)) {
  141. if ($order->payment_sn != $post['platformOrderNo']) {
  142. $logic = new OrderLogic();
  143. $amount = 100;
  144. $order_sn = $order_sn . '#' . time();
  145. $logic->orderCreate($order_sn, $amount, 'NewSupefinaSpei', $order->user_id);
  146. $order = DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)
  147. ->first();
  148. } else {
  149. return '{"success":true}';
  150. }
  151. }
  152. $status = (string)($post['transStatus'] ?? '');
  153. if (in_array($status, ['FAILED', 'CLOSED', 'CANCELED'])) {
  154. $body = ['pay_status' => 2, 'updated_at' => date('Y-m-d H:i:s')];
  155. DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)->update($body);
  156. return '{"success":true}';
  157. }
  158. if (in_array($status, ['REFUNDING', 'PARTIAL_REFUND', 'REFUNDED'])) {
  159. Util::WriteLog('NewSupefinaSpei', 'payin notify status refund: ' . $order_sn);
  160. return '{"success":true}';
  161. }
  162. if ($status !== 'SUCCESS') {
  163. Util::WriteLog('NewSupefinaSpei', 'payin notify status not success: ' . $order_sn);
  164. return '{"success":true}';
  165. }
  166. $GiftsID = $order->GiftsID ?: '';
  167. $userID = $order->user_id ?: '';
  168. $AdId = $order->AdId ?: '';
  169. $eventType = $order->eventType ?: '';
  170. $realityAmount = isset($post['amount']) ? (float)$post['amount'] : (float)($post['amount'] ?? 0);
  171. if ($realityAmount <= 0) {
  172. Util::WriteLog('NewSupefinaSpei_error', 'payin notify invalid realityAmount: ' . json_encode($post));
  173. return 'fail';
  174. }
  175. $payAmt = round($realityAmount, 2);
  176. $amountInScore = (int)round($payAmt * NumConfig::NUM_VALUE);
  177. $body = [
  178. 'payment_sn' => $post['platformOrderNo'] ?? '',
  179. 'pay_status' => 1,
  180. 'pay_at' => date('Y-m-d H:i:s'),
  181. 'finished_at' => date('Y-m-d H:i:s'),
  182. 'amount' => $amountInScore,
  183. 'updated_at' => date('Y-m-d H:i:s'),
  184. ];
  185. $body['payment_fee'] = $post['fee'] ?? 0;
  186. $service = new OrderServices();
  187. if ((int)$order->amount != $amountInScore) {
  188. $body['GiftsID'] = 0;
  189. $body['amount'] = $amountInScore;
  190. $Recharge = $payAmt;
  191. $give = 0;
  192. $favorable_price = $Recharge + $give;
  193. $czReason = 1;
  194. $cjReason = 45;
  195. } else {
  196. [$give, $favorable_price, $Recharge, $czReason, $cjReason] = $service->getPayInfo($GiftsID, $userID, $payAmt);
  197. }
  198. [$Score] = $service->addRecord($userID, $payAmt, $favorable_price, $order_sn, $GiftsID, $Recharge, $czReason, $give, $cjReason, $AdId, $eventType,
  199. $body['payment_fee'] ?? 0);
  200. Order::dispatch([$userID, $payAmt, $Score, $favorable_price, $GiftsID, $order_sn]);
  201. DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)->update($body);
  202. Util::WriteLog('NewSupefinaSpei', 'payin success, order_sn=' . $order_sn . ', realityAmount=' . $realityAmount);
  203. return '{"success":true}';
  204. } catch (\Throwable $exception) {
  205. Util::WriteLog('NewSupefinaSpei_error', $exception->getMessage() . "\n" . $exception->getTraceAsString());
  206. throw $exception;
  207. }
  208. }
  209. public function payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum, $PixType, $IFSCNumber, $BranchBank, $BankNO)
  210. {
  211. // 查询提现订单
  212. $query = DB::connection('write')
  213. ->table('QPAccountsDB.dbo.OrderWithDraw')
  214. ->where('RecordID', $RecordID)
  215. ->first();
  216. if (!$query) {
  217. Util::WriteLog('NewSupefinaSpei', 'withdraw order not found: ' . $RecordID);
  218. return 'fail';
  219. }
  220. $config = (new PayConfig())->getConfig('NewSupefinaSpei');
  221. // 账户号:优先 PixNum,其次 BankNO
  222. $account = $PixNum ?: $BankNO;
  223. if (!$account) {
  224. Util::WriteLog('NewSupefinaSpei_error', 'missing account for withdraw: ' . $OrderId);
  225. return 'fail';
  226. }
  227. // 银行编号:优先 BankNO(如果看作 bankId),否则使用配置默认
  228. $bankId = $BranchBank;
  229. if ($bankId === '') {
  230. Util::WriteLog('NewSupefinaSpei_error', 'missing bankId for withdraw: ' . $OrderId);
  231. return 'fail';
  232. }
  233. // 提现金额是以分存储,转成两位小数金额
  234. $orderAmount = number_format($amount / 100, 2, '.', '');
  235. $bankList = config('games.mex_bank_list');
  236. try {
  237. $now = time() * 1000;
  238. $data = [
  239. 'transTime' => $now,
  240. 'merchantOrderNo' => $OrderId,
  241. 'amount' => (string)$orderAmount,
  242. 'country' => $config['country'] ?? 'MX',
  243. 'currency' => $config['currency'] ?? 'MXN',
  244. 'payeeInfo' => [
  245. 'accountInfo' => [
  246. 'accountNo' => $account,
  247. 'accountType' => mb_strlen($account) == 16 ? '20' : '10',
  248. ],
  249. 'bankInfo' => [
  250. 'bankCode' => $bankId,
  251. 'bankName' => $bankList[$bankId] ?? 'bank',
  252. ],
  253. 'payeeName' => $accountName ?: 'slot777',
  254. ],
  255. 'notifyUrl' => $config['cashCallbackUrl'],
  256. ];
  257. $url = $config['baseUrl'] . $config['transferPath'];
  258. $result = $this->sendRequest($url, 'TRANSFER', $data);
  259. if ($result === false) {
  260. return 'fail';
  261. }
  262. } catch (\Throwable $e) {
  263. Util::WriteLog('NewSupefinaSpei_error', 'payout request exception: ' . $e->getMessage());
  264. return '';
  265. }
  266. try {
  267. $responseData = \GuzzleHttp\json_decode($result, true);
  268. } catch (\Throwable $e) {
  269. Util::WriteLog('NewSupefinaSpei_error', [$result, $e->getMessage()]);
  270. $this->error = 'Payment processing error';
  271. return false;
  272. }
  273. if (!isset($responseData['success']) || $responseData['success'] !== true) {
  274. $this->error = $responseData['message'] ?? 'request failed';
  275. // 同步下单失败:如果订单在处理中(State=5),退回资金并标记失败
  276. if ((int)$query->State === 5) {
  277. $msg = $data['msg'] ?? 'NewSupefinaSpei payout failed';
  278. $WithDraw = $query->WithDraw + $query->ServiceFee;
  279. $bonus = '30000,' . $WithDraw;
  280. PrivateMail::failMail($query->UserID, $OrderId, $WithDraw, $msg, $bonus);
  281. $withdraw_data = [
  282. 'State' => 6,
  283. 'agent' => self::AGENT,
  284. 'finishDate' => now(),
  285. 'remark' => json_encode($data),
  286. ];
  287. DB::connection('write')
  288. ->table('QPAccountsDB.dbo.OrderWithDraw')
  289. ->where('OrderId', $query->OrderId)
  290. ->update($withdraw_data);
  291. $RecordData = ['after_state' => 6, 'update_at' => now()];
  292. DB::connection('write')
  293. ->table('QPAccountsDB.dbo.AccountsRecord')
  294. ->where('type', 1)
  295. ->where('RecordID', $RecordID)
  296. ->update($RecordData);
  297. }
  298. return 'fail';
  299. }
  300. $decryptData = Aes::decrypt($responseData['data'], base64_decode($config['aesKey']));
  301. Util::WriteLog('NewSupefinaSpei', 'transfer decrypt response: ' . $decryptData);
  302. $this->result = json_decode($decryptData, true);
  303. return $this->result;
  304. }
  305. public function cashNotify($post)
  306. {
  307. $OrderId = $post['merchantOrderNo'];
  308. if ($OrderId === '') {
  309. Util::WriteLog('NewSupefinaSpei_error', 'payout notify missing merchantOrderNo');
  310. return 'fail';
  311. }
  312. $query = DB::connection('write')
  313. ->table('QPAccountsDB.dbo.OrderWithDraw')
  314. ->where('OrderId', $OrderId)
  315. ->first();
  316. if (!$query) {
  317. Util::WriteLog('NewSupefinaSpei_error', 'withdraw order not found in notify: '.$OrderId);
  318. return '{"success":true}';
  319. }
  320. // 只处理 State=5 或 7 的订单,避免重复
  321. if (!in_array((int)$query->State, [5, 7], true)) {
  322. Util::WriteLog('NewSupefinaSpei', 'withdraw already handled: '.$OrderId);
  323. return '{"success":true}';
  324. }
  325. $status = $post['transStatus'] ?? '';
  326. $orderStatus = 0;
  327. if (in_array($status, ['SUCCESS'], true)) {
  328. $orderStatus = 1; // 成功
  329. } elseif (in_array($status, ['FAILED', 'CANCELED', 'REFUNDED'])) {
  330. $orderStatus = 2; // 失败
  331. }
  332. if ($orderStatus === 0) {
  333. Util::WriteLog('NewSupefinaSpei', 'payout processing: '.$OrderId.' status='.$status);
  334. return '{"success":true}';
  335. }
  336. $agentID = DB::connection('write')
  337. ->table('agent.dbo.admin_configs')
  338. ->where('config_value', self::AGENT)
  339. ->where('type', 'cash')
  340. ->value('id') ?? '';
  341. $now = now();
  342. $UserID = $query->UserID;
  343. $TakeMoney = $query->WithDraw + $query->ServiceFee;
  344. // Supefina 回调里带有 amount/fee 和 realityAmount/realityFee
  345. // 提醒:这里仍以我们订单金额为准做账,仅将真实金额用于日志,可根据需要扩展到统计侧。
  346. $realityAmount = isset($post['amount']) ? (float)$post['amount'] : null;
  347. $realityFee = isset($post['fee']) ? (float)$post['fee'] : null;
  348. Util::WriteLog('NewSupefinaSpei', 'payout reality: amount='.$realityAmount.', fee='.$realityFee.', orderId='.$OrderId);
  349. $withdraw_data = [];
  350. switch ($orderStatus) {
  351. case 1: // 提现成功
  352. $withdraw_data = [
  353. 'State' => 2,
  354. 'agent' => $agentID,
  355. 'finishDate' => $now,
  356. 'withdraw_fee' => $realityFee * NumConfig::NUM_VALUE,
  357. ];
  358. // 增加提现记录
  359. $first = DB::connection('write')
  360. ->table('QPAccountsDB.dbo.UserTabData')
  361. ->where('UserID', $UserID)
  362. ->first();
  363. if ($first) {
  364. DB::connection('write')
  365. ->table('QPAccountsDB.dbo.UserTabData')
  366. ->where('UserID', $UserID)
  367. ->increment('TakeMoney', $TakeMoney);
  368. } else {
  369. DB::connection('write')
  370. ->table('QPAccountsDB.dbo.UserTabData')
  371. ->insert(['TakeMoney' => $TakeMoney, 'UserID' => $UserID]);
  372. try {
  373. PrivateMail::praiseSendMail($UserID);
  374. } catch (\Throwable $e) {
  375. // 忽略邮件发送失败
  376. }
  377. }
  378. // 免审记录
  379. $withdrawal_position_log = DB::connection('write')
  380. ->table('agent.dbo.withdrawal_position_log')
  381. ->where('order_sn', $OrderId)
  382. ->first();
  383. if ($withdrawal_position_log) {
  384. DB::connection('write')
  385. ->table('agent.dbo.withdrawal_position_log')
  386. ->where('order_sn', $OrderId)
  387. ->update(['take_effect' => 2, 'update_at' => date('Y-m-d H:i:s')]);
  388. }
  389. try {
  390. StoredProcedure::addPlatformData($UserID, 4, $TakeMoney);
  391. } catch (\Throwable $exception) {
  392. Util::WriteLog('StoredProcedure', $exception->getMessage());
  393. }
  394. $ServiceFee = $query->ServiceFee;
  395. RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $ServiceFee);
  396. $fee = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
  397. ->value('withdraw_fee');
  398. (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $realityFee * NumConfig::NUM_VALUE, $ServiceFee);
  399. $redis = Redis::connection();
  400. $redis->incr('draw_'.date('Ymd').$UserID);
  401. break;
  402. case 2: // 提现失败
  403. $msg = $post['msg'] ?? 'Withdraw rejected';
  404. $bonus = '30000,'.$TakeMoney;
  405. PrivateMail::failMail($query->UserID, $OrderId, $TakeMoney, $msg, $bonus);
  406. Util::WriteLog('SupefinaSpeiEmail', [$query->UserID, $OrderId, $TakeMoney, $msg, $bonus]);
  407. $withdraw_data = [
  408. 'State' => 6,
  409. 'agent' => $agentID,
  410. 'remark' => $msg,
  411. ];
  412. break;
  413. }
  414. $RecordData = [
  415. 'before_state' => $query->State,
  416. 'after_state' => $withdraw_data['State'] ?? 0,
  417. 'RecordID' => $query->RecordID,
  418. 'update_at' => date('Y-m-d H:i:s'),
  419. ];
  420. DB::connection('write')
  421. ->table('QPAccountsDB.dbo.AccountsRecord')
  422. ->updateOrInsert(
  423. ['RecordID' => $query->RecordID, 'type' => 1],
  424. $RecordData
  425. );
  426. DB::connection('write')
  427. ->table('QPAccountsDB.dbo.OrderWithDraw')
  428. ->where('OrderId', $OrderId)
  429. ->update($withdraw_data);
  430. if (isset($withdraw_data['State']) && (int)$withdraw_data['State'] === 2) {
  431. StoredProcedure::user_label($UserID, 2, $TakeMoney);
  432. }
  433. return '{"success":true}';
  434. }
  435. public function getSignString($headers, $data)
  436. {
  437. $params = array_merge($headers, $data);
  438. $filtered = [];
  439. foreach ($params as $k => $v) {
  440. if (strtolower($k) === 'sign') {
  441. continue;
  442. }
  443. if ($v === null) {
  444. continue;
  445. }
  446. $filtered[$k] = $v;
  447. }
  448. ksort($filtered);
  449. $parts = [];
  450. foreach ($filtered as $k => $v) {
  451. $parts[] = $k . '=' . $v;
  452. }
  453. $signString = implode('&', $parts);
  454. return $signString;
  455. }
  456. public function sign($headers, $data, $key)
  457. {
  458. $signString = $this->getSignString($headers, $data);
  459. $res = openssl_pkey_get_private("-----BEGIN PRIVATE KEY-----\n" . $key . "\n-----END PRIVATE KEY-----");
  460. openssl_sign(
  461. $signString,
  462. $signature,
  463. $res,
  464. OPENSSL_ALGO_SHA256 // RSA2 核心
  465. );
  466. return base64_encode($signature);
  467. }
  468. public function verifySign($data, $sign, $key)
  469. {
  470. $res = openssl_pkey_get_public("-----BEGIN PUBLIC KEY-----\n" . $key . "\n-----END PUBLIC KEY-----");
  471. $result = openssl_verify(
  472. $data,
  473. base64_decode($sign),
  474. $res,
  475. OPENSSL_ALGO_SHA256
  476. );
  477. return $result === 1;
  478. }
  479. private function sendRequest($url, $productNo, $data)
  480. {
  481. $config = (new PayConfig())->getConfig('NewSupefinaSpei');
  482. $headers = [
  483. 'version' => '1.0.0',
  484. 'merchantNo' => $config['merId'] ?? '',
  485. 'requestId' => mt_rand(100000, 999999) . time(),
  486. 'requestTime' => time() * 1000,
  487. ];
  488. $body = [
  489. 'productNo' => $productNo,
  490. 'data' => Aes::encrypt(json_encode($data), base64_decode($config['aesKey'])),
  491. ];
  492. $sign = $this->sign($headers, $body, $config['privateKey']);
  493. $headers['sign'] = $sign;
  494. try {
  495. $client = new Client();
  496. Util::WriteLog('NewSupefinaSpei', $productNo . ' request: ' . $url . ' | ' . json_encode($data) . '|' . json_encode($headers));
  497. $result = $client->post($url, [
  498. 'headers' => $headers,
  499. 'json' => $body,
  500. ])->getBody()->getContents();
  501. Util::WriteLog('NewSupefinaSpei', $productNo . ' response: ' . $result);
  502. return $result;
  503. } catch (\Throwable $e) {
  504. Util::WriteLog('NewSupefinaSpei_error', $productNo . ' request exception: ' . $e->getMessage());
  505. $this->error = 'Payment processing error';
  506. return false;
  507. }
  508. }
  509. }