This is the scenario, User instantiate a paypal transaction (eg.$100) but returns to the site without cancelling from paypal and decided to choose a different amount (eg.$25). When it redirects to paypal it still charges $100. Is there any way of updating that amount?
//CODE SNIPPET
$transactionDetails = array(
"amount" => array(
"total" => $total,
"currency" => PAYPAL_CURRENCY
),
"description" => "Adding $".$total.PAYPAL_CURRENCY
);
$returnUrl = site_url('referral/addFundForUser');
$cancelUrl = site_url('referral/');
$paymentMethod = "paypal";
$data = array(
"intent" => "sale",
"redirect_urls" => array(
"return_url" => $returnUrl,
"cancel_url" => $cancelUrl
),
"payer" => array(
"payment_method" => $paymentMethod
),
"transactions" => array($transactionDetails)
);
$header = array(
'Content-Type: application/json',
'Authorization: '.$tokenType. ' '.$accessToken
);
$url = $this->url.'v1/payments/payment';
return $this->doCurlCall($url,$data,$header);
FYI: I was saving user $transactionDetails in Session so that when paypal redirects back to me, I can update my payment Log.
if (!$this->getTransactionInfo() ){
$newTransaction = $this->paypal->startSale($this->getTokenType(),$this->getAccessToken(),$transactionDetails);
$transactionInfo = array(
"paymentTransactionId" => $newTransaction->id,
"total" => $total
);
foreach($newTransaction->links as $key=>$value){
if (strcmp($value->rel,'self') == 0){
$transactionInfo['self'] = $value->href;
}else if (strcmp($value->rel,'approval_url') == 0){
$transactionInfo['approval'] = $value->href;
$data['approval_url'] = $value->href;
}else if (strcmp($value->rel,'execute') == 0){
$transactionInfo['execute'] = $value->href;
}
}
$this->setTransactionInfo($transactionInfo,true);//SAVES IN SESSION
$paymentTransactionId = $newTransaction->id;
}else{
$newTransaction = $this->getTransactionInfo();
$paymentTransactionId = $newTransaction['paymentTransactionId'];
}
$successMsg = "Paypal Transaction Instantiated";
if ($this->insertPaymentLog($paymentTransactionId,$total,$payerId="",false,$successMsg,"",$transactionType)){
}
$data['transactionDetails'] = $transactionDetails;
$approval = $this->getTransactionInfo()['approval'];
redirect($approval);
if (!$this->getTransactionInfo() || $total != $this->getTransactionInfo()['total']){
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.