Skip to content

Commit

Permalink
code cleanups and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrax committed Feb 17, 2021
1 parent 66576e7 commit 573076d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/PaypalLaravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand All @@ -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;


}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/PaypalUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function fetch_token(string $url, string $authorization)
}


public function executepayment($token,$url){
public function executepayment($token,$url,$payer_id){



Expand All @@ -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',
Expand Down

0 comments on commit 573076d

Please sign in to comment.