|
@@ -17,8 +17,8 @@ class Applepay extends Payment
|
|
|
*/
|
|
*/
|
|
|
protected $code = 'applepay';
|
|
protected $code = 'applepay';
|
|
|
protected $clientId;
|
|
protected $clientId;
|
|
|
- protected $apikey;
|
|
|
|
|
protected $secret;
|
|
protected $secret;
|
|
|
|
|
+ protected $webhookId;
|
|
|
protected $currentOrder;
|
|
protected $currentOrder;
|
|
|
protected $prefix = 'QQS';
|
|
protected $prefix = 'QQS';
|
|
|
public $createOrderApi = 'https://api-m.sandbox.paypal.com/v2/checkout/orders';
|
|
public $createOrderApi = 'https://api-m.sandbox.paypal.com/v2/checkout/orders';
|
|
@@ -45,7 +45,7 @@ class Applepay extends Payment
|
|
|
}
|
|
}
|
|
|
$this->clientId = $this->getConfigData('client_id');
|
|
$this->clientId = $this->getConfigData('client_id');
|
|
|
$this->apikey = $this->getConfigData('secret_id');
|
|
$this->apikey = $this->getConfigData('secret_id');
|
|
|
- $this->secret = $this->getConfigData('webhook_id');
|
|
|
|
|
|
|
+ $this->webhookId = $this->getConfigData('webhook_id');
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* Get redirect url.
|
|
* Get redirect url.
|
|
@@ -155,6 +155,36 @@ class Applepay extends Payment
|
|
|
return $lineItems;
|
|
return $lineItems;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function webhookSignature($header, $data)
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ 'transmission_id' => $header['Paypal-Transmission-Id'],
|
|
|
|
|
+ 'transmission_time' => $header['Paypal-Transmission-Time'],
|
|
|
|
|
+ 'cert_url' => $header['Paypal-Cert-Url'],
|
|
|
|
|
+ 'auth_algo' => $header['Paypal-Auth-Algo'],
|
|
|
|
|
+ 'transmission_sig' => $header['Paypal-Transmission-Sig'],
|
|
|
|
|
+ 'webhook_id' => $this->webhookId,
|
|
|
|
|
+ 'webhook_event' => $data
|
|
|
|
|
+ ];
|
|
|
|
|
+ $client = new Client();
|
|
|
|
|
+ $response = $client->request('POST', $this->sigApi, [
|
|
|
|
|
+ 'headers' => [
|
|
|
|
|
+ 'Accept' => 'application/json',
|
|
|
|
|
+ 'Content-Type' => 'application/json',
|
|
|
|
|
+ 'Authorization' => 'Basic '. base64_encode("{$this->apikey}:{$this->secret}")
|
|
|
|
|
+ ],
|
|
|
|
|
+ 'json' => $data,
|
|
|
|
|
+ 'timeout' => 30,
|
|
|
|
|
+ 'verify' => false
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $resultObject = json_decode($response->getBody()->getContents());
|
|
|
|
|
+ if ($resultObject->verification_status == 'SUCCESS') {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//成功修改状态
|
|
//成功修改状态
|
|
|
public function paymentSucceeded($orderId, $transactionId)
|
|
public function paymentSucceeded($orderId, $transactionId)
|
|
|
{
|
|
{
|