Showing
1 changed file
with
15 additions
and
1 deletions
| ... | @@ -33,6 +33,8 @@ class ApplePayment implements PaymentInterface | ... | @@ -33,6 +33,8 @@ class ApplePayment implements PaymentInterface |
| 33 | 33 | ||
| 34 | const SANDBOX_URL = 'https://sandbox.itunes.apple.com/verifyReceipt'; | 34 | const SANDBOX_URL = 'https://sandbox.itunes.apple.com/verifyReceipt'; |
| 35 | 35 | ||
| 36 | + const PASSWORD = 'cbd66447ac8b463daf6d5498fec5f580'; | ||
| 37 | + | ||
| 36 | public function __construct() | 38 | public function __construct() |
| 37 | { | 39 | { |
| 38 | 40 | ||
| ... | @@ -55,8 +57,20 @@ class ApplePayment implements PaymentInterface | ... | @@ -55,8 +57,20 @@ class ApplePayment implements PaymentInterface |
| 55 | $client = new Client(['headers' => ['Content-Type' => 'application/json']]); | 57 | $client = new Client(['headers' => ['Content-Type' => 'application/json']]); |
| 56 | try{ | 58 | try{ |
| 57 | $response = $client->post(self::IS_SANDBOX ? self::SANDBOX_URL : self::VERIFY_URL, | 59 | $response = $client->post(self::IS_SANDBOX ? self::SANDBOX_URL : self::VERIFY_URL, |
| 58 | - ['json' => ['receipt-data' => $token,]])->getBody()->getContents(); | 60 | + ['json' => ['receipt-data' => $token, 'password' => self::PASSWORD]])->getBody()->getContents(); |
| 61 | + $resp = json_decode($response,true); | ||
| 59 | Log::debug($response); | 62 | Log::debug($response); |
| 63 | + if ($resp['status'] <= 21003) { | ||
| 64 | + $newToken = str_replace('+', ' ', $token); | ||
| 65 | + try{ | ||
| 66 | + $response = $client->post(self::IS_SANDBOX ? self::SANDBOX_URL : self::VERIFY_URL, | ||
| 67 | + ['json' => ['receipt-data' => $newToken, 'password' => self::PASSWORD]])->getBody()->getContents(); | ||
| 68 | + Log::debug('======== 替换+ ========'); | ||
| 69 | + Log::debug($response); | ||
| 70 | + }catch (GuzzleException $exception){ | ||
| 71 | + Log::error($exception->getMessage() . 'Line:' . $exception->getLine()); | ||
| 72 | + } | ||
| 73 | + } | ||
| 60 | }catch (GuzzleException $exception){ | 74 | }catch (GuzzleException $exception){ |
| 61 | Log::error($exception->getMessage() . 'Line:' . $exception->getLine()); | 75 | Log::error($exception->getMessage() . 'Line:' . $exception->getLine()); |
| 62 | } | 76 | } | ... | ... |
-
Please register or login to post a comment