diff --git a/src/PaypalLaravel.php b/src/PaypalLaravel.php index 1033a37..fc794dc 100644 --- a/src/PaypalLaravel.php +++ b/src/PaypalLaravel.php @@ -66,7 +66,7 @@ public function CreatePayment(int $amount, $tax, $shipping, $handling_fee, $desc $response = $api->create_payment_util($this->token, config("paypal-laravel.live_endpoint"), $amount, 0, 0, 0, $description); } - + $payment_id = json_decode($response)->id; $payment_links = json_decode($response)->links; @@ -83,7 +83,7 @@ public function CreatePayment(int $amount, $tax, $shipping, $handling_fee, $desc /** * /v1/payments/payment/PAY-XXX/execute */ - public function executePayment($paymentid,$PayeID){ + public function executePayment($paymentid,$PayeID,$payer_id){ $this->getAccessToken(); @@ -93,17 +93,20 @@ public function executePayment($paymentid,$PayeID){ $url=config("paypal-laravel.sandbox_endpoint")."/v1/payments/payment/".$PayeID."/execute"; - $response = $api->executepayment($this->token, $url); + $response = $api->executepayment($this->token, $url,$payer_id); } else { $api = new PaypalUtil(); $url=config("paypal-laravel.live_endpoint")."/v1/payments/payment/".$PayeID."/execute"; - $response = $api->executepayment($this->token, $url); + $response = $api->executepayment($this->token, $url,$payer_id); } + return $response; + + } /** diff --git a/src/PaypalUtil.php b/src/PaypalUtil.php index 187dd0a..b84dbfa 100644 --- a/src/PaypalUtil.php +++ b/src/PaypalUtil.php @@ -50,7 +50,7 @@ public function fetch_token(string $url, string $authorization) } - public function executepayment($token,$url){ + public function executepayment($token,$url,$payer_id){ @@ -65,7 +65,7 @@ public function executepayment($token,$url){ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => '{ - "payer_id": "'.$paymentid.'" + "payer_id": "'.$payer_id.'" }', CURLOPT_HTTPHEADER => array( 'accept: application/json',