|
3 | 3 |
|
4 | 4 | namespace PhpMonsters\Larapay\Adapter; |
5 | 5 |
|
6 | | -use SoapClient; |
7 | | -use SoapFault; |
8 | | -use PhpMonsters\Larapay\Adapter\Zarinpal\Helper; |
| 6 | +use Illuminate\Support\Facades\Http; |
9 | 7 | use PhpMonsters\Larapay\Adapter\Zarinpal\Exception; |
10 | 8 | use PhpMonsters\Log\Facades\XLog; |
11 | 9 |
|
@@ -61,9 +59,13 @@ protected function requestToken(): string |
61 | 59 | try { |
62 | 60 | XLog::debug('PaymentRequest call', $sendParams); |
63 | 61 |
|
64 | | - $response = Helper::post2https($sendParams, $this->getPaymentRequestEndpPoint()); |
65 | | - $result = json_decode($response); |
66 | | - XLog::info('reservation result', $result); |
| 62 | + $response = Http::withHeaders([ |
| 63 | + 'Content-Type' => 'application/json', |
| 64 | + ])->post($this->getPaymentRequestEndpPoint(), $sendParams); |
| 65 | + |
| 66 | + $response->throw(); |
| 67 | + |
| 68 | + $result = $response->object(); |
67 | 69 |
|
68 | 70 | if (empty($result->errors)) { |
69 | 71 | if ($result->data->code == 100) { |
@@ -138,9 +140,15 @@ protected function verifyTransaction(): bool |
138 | 140 | XLog::debug('PaymentVerification call', $sendParams); |
139 | 141 |
|
140 | 142 | try { |
141 | | - $response = Helper::post2https($sendParams, $this->getPaymentVerifyEndpPoint()); |
142 | | - $result = json_decode($response); |
143 | | - XLog::info('PaymentVerification response', $this->obj2array($result)); |
| 143 | + $response = Http::withHeaders([ |
| 144 | + 'Content-Type' => 'application/json', |
| 145 | + ])->post($this->getPaymentVerifyEndpPoint(), $sendParams); |
| 146 | + |
| 147 | + $response->throw(); |
| 148 | + |
| 149 | + $result = $response->object(); |
| 150 | + |
| 151 | + XLog::info('PaymentVerification response', $response->json()); |
144 | 152 |
|
145 | 153 | if ($result->data->code === 100) { |
146 | 154 | $this->getTransaction()->setVerified(); |
|
0 commit comments