From dc680c6a85c65e0abe8db40d4f650e658af86c4e Mon Sep 17 00:00:00 2001 From: Abbas Arif <43321373+buzzclue@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:19:02 +0500 Subject: [PATCH] Add custom id for invoice id (#603) * Add custom id for invoice id --- .../PayPalAPI/Subscriptions/Helpers.php | 23 +++++++++++++++++++ src/Traits/PayPalVerifyIPN.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Traits/PayPalAPI/Subscriptions/Helpers.php b/src/Traits/PayPalAPI/Subscriptions/Helpers.php index 8b65faa2..cb3a7a9e 100644 --- a/src/Traits/PayPalAPI/Subscriptions/Helpers.php +++ b/src/Traits/PayPalAPI/Subscriptions/Helpers.php @@ -48,6 +48,11 @@ trait Helpers */ protected $taxes; + /** + * @var string + */ + protected $custom_id; + /** * Setup a subscription. * @@ -93,6 +98,10 @@ public function setupSubscription(string $customer_name, string $customer_email, $body['taxes'] = $this->taxes; } + if (isset($this->custom_id)) { + $body['custom_id'] = $this->custom_id; + } + $subscription = $this->createSubscription($body); unset($this->product); @@ -475,4 +484,18 @@ public function addTaxes(float $percentage) return $this; } + + /** + * Add custom id. + * + * @param string $custom_id + * + * @return \Srmklive\PayPal\Services\PayPal + */ + public function addCustomId(string $custom_id) + { + $this->custom_id = $custom_id; + + return $this; + } } diff --git a/src/Traits/PayPalVerifyIPN.php b/src/Traits/PayPalVerifyIPN.php index cff1437d..63478683 100644 --- a/src/Traits/PayPalVerifyIPN.php +++ b/src/Traits/PayPalVerifyIPN.php @@ -36,7 +36,7 @@ public function verifyIPN(\Illuminate\Http\Request $request) return ['error' => 'Invalid headers or webhook id provided']; } - $params = $request->all(); + $params = json_decode($request->getContent()); $payload = [ 'auth_algo' => $headers['PAYPAL-AUTH-ALGO'][0],