Fix for ValidateWebhookEvent - Fatal error (#1300)

* Test against php 7.3
* fix for ValidateWebhookEvent - Fatal error
* fixed typo
This commit is contained in:
Prakash Gangadharan
2019-10-15 23:02:55 +05:30
committed by GitHub
parent 647c8c49bc
commit 4ddb1de829
6 changed files with 11 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ php:
- 7.0 - 7.0
- 7.1 - 7.1
- 7.2 - 7.2
- 7.3
- hhvm - hhvm
matrix: matrix:
allow_failures: allow_failures:

View File

@@ -7,7 +7,7 @@ that has been approved by
the buyer by logging into paypal site. the buyer by logging into paypal site.
You can optionally update transaction You can optionally update transaction
information by passing in one or more transactions. information by passing in one or more transactions.
API used: POST &#39;/v1/payments/payment/<payment-id>/execute&#39;.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>; API used: POST &#39;/v1/payments/payment/{payment_id}/execute&#39;.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>; <span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Details</span>; <span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Details</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>; <span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><title>payments/GetCapture</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/GetCapture"><meta name="groc-project-path" content="payments/GetCapture.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/GetCapture.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="getcapture">GetCapture</h1> <!DOCTYPE html><html lang="en"><head><title>payments/GetCapture</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/GetCapture"><meta name="groc-project-path" content="payments/GetCapture.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/GetCapture.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="getcapture">GetCapture</h1>
<p>This sample code demonstrates how you can lookup the details <p>This sample code demonstrates how you can lookup the details
of a captured payment. of a captured payment.
API used: /v1/payments/capture/&lt;$captureId&gt;</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Replace $captureId with any static Id you might already have. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$captureId</span> = <span class="hljs-string">"&lt;your authorization id here&gt;"</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-capture-details">Retrieve Capture details</h3> API used: /v1/payments/capture/{capture_id}</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Replace $captureId with any static Id you might already have. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$captureId</span> = <span class="hljs-string">"&lt;your authorization id here&gt;"</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-capture-details">Retrieve Capture details</h3>
<p>You can look up a capture by invoking the Capture::get method <p>You can look up a capture by invoking the Capture::get method
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> { with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$capture</span> = Capture::get(<span class="hljs-variable">$captureId</span>, <span class="hljs-variable">$apiContext</span>); <span class="hljs-variable">$capture</span> = Capture::get(<span class="hljs-variable">$captureId</span>, <span class="hljs-variable">$apiContext</span>);

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><title>payments/RefundCapture</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/RefundCapture"><meta name="groc-project-path" content="payments/RefundCapture.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/RefundCapture.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="refund-capture-sample">Refund Capture Sample</h1> <!DOCTYPE html><html lang="en"><head><title>payments/RefundCapture</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/RefundCapture"><meta name="groc-project-path" content="payments/RefundCapture.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/RefundCapture.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="refund-capture-sample">Refund Capture Sample</h1>
<p>This sample code demonstrates how you can <p>This sample code demonstrates how you can
process a refund on a Captured transaction. process a refund on a Captured transaction.
API used: /v1/payments/capture/{<captureID>}/refund</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/** <span class="hljs-doctag">@var</span> Capture $capture */</span> API used: /v1/payments/capture/{capture_id}/refund</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/** <span class="hljs-doctag">@var</span> Capture $capture */</span>
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>; <span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>;

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><title>payments/VoidAuthorization</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/VoidAuthorization"><meta name="groc-project-path" content="payments/VoidAuthorization.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/VoidAuthorization.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="voidauthorization">VoidAuthorization</h1> <!DOCTYPE html><html lang="en"><head><title>payments/VoidAuthorization</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/VoidAuthorization"><meta name="groc-project-path" content="payments/VoidAuthorization.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/VoidAuthorization.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="voidauthorization">VoidAuthorization</h1>
<p>This sample code demonstrates how you can <p>This sample code demonstrates how you can
void an authorized payment. void an authorized payment.
API used: /v1/payments/authorization/&lt;{authorizationid}&gt;/void&quot;</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Replace $authorizationId with any static Id you might already have. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$authorizationId</span> = <span class="hljs-string">"&lt;your authorization id here&gt;"</span>; API used: &#39;/v1/payments/authorization/{authorization_id}/void&#39;</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Replace $authorizationId with any static Id you might already have. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$authorizationId</span> = <span class="hljs-string">"&lt;your authorization id here&gt;"</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="voidauthorization">VoidAuthorization</h3> <span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="voidauthorization">VoidAuthorization</h3>
<p>You can void a previously authorized payment <p>You can void a previously authorized payment

View File

@@ -13,7 +13,7 @@ $apiContext = require __DIR__ . '/../bootstrap.php';
* Just uncomment the below line to read the data from actual request. * Just uncomment the below line to read the data from actual request.
*/ */
/** @var String $requestBody */ /** @var String $requestBody */
$requestBody = '{"id":"WH-9UG43882HX7271132-6E0871324L7949614","event_version":"1.0","create_time":"2016-09-21T22:00:45Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 21.0 USD","resource":{"id":"80F85758S3080410K","state":"completed","amount":{"total":"21.00","currency":"USD","details":{"subtotal":"17.50","tax":"1.30","shipping":"2.20"}},"payment_mode":"INSTANT_TRANSFER","protection_eligibility":"ELIGIBLE","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","transaction_fee":{"value":"0.91","currency":"USD"},"invoice_number":"57e3028db8d1b","custom":"","parent_payment":"PAY-7F371669SL612941HK7RQFDQ","create_time":"2016-09-21T21:59:02Z","update_time":"2016-09-21T22:00:06Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/80F85758S3080410K","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/80F85758S3080410K/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-7F371669SL612941HK7RQFDQ","rel":"parent_payment","method":"GET"}]},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-9UG43882HX7271132-6E0871324L7949614","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-9UG43882HX7271132-6E0871324L7949614/resend","rel":"resend","method":"POST"}]}'; $requestBody = '{"id":"WH-7MU294299R542214K-4N1831857K851783H","event_version":"1.0","create_time":"2019-08-29T10:49:03.439Z","resource_type":"payment","event_type":"PAYMENTS.PAYMENT.CREATED","summary":"Checkout payment is created and approved by buyer","resource":{"update_time":"2019-08-29T10:48:54Z","create_time":"2019-08-29T10:47:51Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LVT22VY7N839502VJ678725M","rel":"self","method":"GET"}],"id":"PAYID-LVT22VY7N839502VJ678725M","state":"approved","transactions":[{"amount":{"total":"30.11","currency":"USD","details":{"subtotal":"30.00","tax":"0.07","shipping":"0.03","insurance":"0.01","handling_fee":"1.00","shipping_discount":"-1.00"}},"payee":{"merchant_id":"2BP3WP8PK6566","email":"jaypatel512-facilitator@hotmail.com"},"description":"The payment transaction description.","custom":"EBAY_EMS_90048630024435","invoice_number":"48787589673111","item_list":{"items":[{"name":"hat","sku":"1","description":"Brown hat.","price":"3.00","currency":"USD","tax":"0.01","quantity":5},{"name":"handbag","sku":"product34","description":"Black handbag.","price":"15.00","currency":"USD","tax":"0.02","quantity":1}],"shipping_address":{"recipient_name":"Brian Robinson","line1":"4th Floor","line2":"Unit #34","city":"San Jose","state":"CA","postal_code":"95131","country_code":"US","default_address":false,"preferred_address":false,"primary_address":false,"disable_for_transaction":false}},"related_resources":[{"sale":{"id":"08U30449S6662931K","state":"completed","amount":{"total":"30.11","currency":"USD","details":{"subtotal":"30.00","tax":"0.07","shipping":"0.03","insurance":"0.01","handling_fee":"1.00","shipping_discount":"-1.00"}},"payment_mode":"INSTANT_TRANSFER","protection_eligibility":"ELIGIBLE","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","transaction_fee":{"value":"1.17","currency":"USD"},"parent_payment":"PAYID-LVT22VY7N839502VJ678725M","create_time":"2019-08-29T10:48:54Z","update_time":"2019-08-29T10:48:54Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/08U30449S6662931K","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/08U30449S6662931K/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LVT22VY7N839502VJ678725M","rel":"parent_payment","method":"GET"}]}}]}],"intent":"sale","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"sb-ahlmo117121@personal.example.com","first_name":"John","last_name":"Doe","payer_id":"WZH5NSHUBE63W","shipping_address":{"recipient_name":"Brian Robinson","line1":"4th Floor","line2":"Unit #34","city":"San Jose","state":"CA","postal_code":"95131","country_code":"US","default_address":false,"preferred_address":false,"primary_address":false,"disable_for_transaction":false},"phone":"4084959323","country_code":"US"}},"cart":"1R7827981J4260732"},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-7MU294299R542214K-4N1831857K851783H","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-7MU294299R542214K-4N1831857K851783H/resend","rel":"resend","method":"POST"}]}';
/** /**
* Receive the entire body that you received from PayPal webhook. * Receive the entire body that you received from PayPal webhook.
* Just uncomment the below line to read the data from actual request. * Just uncomment the below line to read the data from actual request.
@@ -28,11 +28,11 @@ $requestBody = '{"id":"WH-9UG43882HX7271132-6E0871324L7949614","event_version":"
'Host' => 'shiparound-dev.de', 'Host' => 'shiparound-dev.de',
'User-Agent' => 'PayPal/AUHD-208.0-25552773', 'User-Agent' => 'PayPal/AUHD-208.0-25552773',
'Paypal-Auth-Algo' => 'SHA256withRSA', 'Paypal-Auth-Algo' => 'SHA256withRSA',
'Paypal-Cert-Url' => 'https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-a5cafa77', 'Paypal-Cert-Url' => 'https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-1d93a270',
'Paypal-Auth-Version' => 'v2', 'Paypal-Auth-Version' => 'v2',
'Paypal-Transmission-Sig' => 'eDOnWUj9FXOnr2naQnrdL7bhgejVSTwRbwbJ0kuk5wAtm2ZYkr7w5BSUDO7e5ZOsqLwN3sPn3RV85Jd9pjHuTlpuXDLYk+l5qiViPbaaC0tLV+8C/zbDjg2WCfvtf2NmFT8CHgPPQAByUqiiTY+RJZPPQC5np7j7WuxcegsJLeWStRAofsDLiSKrzYV3CKZYtNoNnRvYmSFMkYp/5vk4xGcQLeYNV1CC2PyqraZj8HGG6Y+KV4trhreV9VZDn+rPtLDZTbzUohie1LpEy31k2dg+1szpWaGYOz+MRb40U04oD7fD69vghCrDTYs5AsuFM2+WZtsMDmYGI0pxLjn2yw==', 'Paypal-Transmission-Sig' => 'K7DF5+hOyGS6v0xTZ9PkEO+BFNQmpryxw2hFlXbHgmxpu+883ldEC9HcL6ccEmB8sfy80y/Q3qcZZL1MR8Qi0e1ysylVj/yROgKK6zBsQPoNmgXC8yTiNoAjULuhk5Aoau0Itk3nrkgAfji1zvADlErMFM9VZe2nDvhM3nDMLjCi/K5fRjWp3eGo6Nx17GX/WIEibeKDyS+YdJMex3i+KO4aWmm9zznC/FJ5Y/ntd0MxOJNrM0r0f3y7c3e3sO5pB3oPgN6KzKVS5P6AWHqtS8acD3DjgCKZ1uqKz7q954G1aBz2/m0wRGOFFsv0/D3FE2uIheRRmoQtVSOAX7Aupg==',
'Paypal-Transmission-Time' => '2016-09-21T22:00:46Z', 'Paypal-Transmission-Time' => '2019-08-29T10:49:33Z',
'Paypal-Transmission-Id' => 'd938e770-8046-11e6-8103-6b62a8a99ac4', 'Paypal-Transmission-Id' => 'afa30d40-ca4a-11e9-ab68-7d4e2605c70c',
'Accept' => '*/*', 'Accept' => '*/*',
); );
@@ -53,7 +53,7 @@ $signatureVerification = new VerifyWebhookSignature();
$signatureVerification->setAuthAlgo($headers['PAYPAL-AUTH-ALGO']); $signatureVerification->setAuthAlgo($headers['PAYPAL-AUTH-ALGO']);
$signatureVerification->setTransmissionId($headers['PAYPAL-TRANSMISSION-ID']); $signatureVerification->setTransmissionId($headers['PAYPAL-TRANSMISSION-ID']);
$signatureVerification->setCertUrl($headers['PAYPAL-CERT-URL']); $signatureVerification->setCertUrl($headers['PAYPAL-CERT-URL']);
$signatureVerification->setWebhookId("9XL90610J3647323C"); // Note that the Webhook ID must be a currently valid Webhook that you created with your client ID/secret. $signatureVerification->setWebhookId("0FV983392A0531201"); // Note that the Webhook ID must be a currently valid Webhook that you created with your client ID/secret.
$signatureVerification->setTransmissionSig($headers['PAYPAL-TRANSMISSION-SIG']); $signatureVerification->setTransmissionSig($headers['PAYPAL-TRANSMISSION-SIG']);
$signatureVerification->setTransmissionTime($headers['PAYPAL-TRANSMISSION-TIME']); $signatureVerification->setTransmissionTime($headers['PAYPAL-TRANSMISSION-TIME']);