How implement parallel payment in express checkout ?
MustaphaDZ
New Community Member
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Aug-06-2018
03:03 PM
Hi,
I have this code of parallel payment using express checkout :
index.php
<?php require 'paypal.php'; $total = 0.1; $mail_1 = "first_email"; $mail_2 = "second-email"; $paypal = "#"; $paypal = new Paypal(); $params = array( 'RETURNURL' => 'http://site.com/process.php', 'CANCELURL' => 'http://site.com/cancel.php', 'NOSHIPPING' => '1', 'LOGOIMG' => '', // 190 60 PNG JPG 'LANDINGPAGE' => 'Billing', // OR Login 'BRANDNAME' => 'MUSTAPHA', 'SOLUTIONTYPE' => 'SOLE', 'PAYMENTREQUEST_0_AMT' => $total, 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', 'PAYMENTREQUEST_0_ITEMAMT' => $total, 'PAYMENTREQUEST_0_DESC' => 'description detaillé', 'PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID' => $mail_1, 'PAYMENTREQUEST_0_PAYMENTREQUESTID' => '1234567', 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Order', 'PAYMENTREQUEST_1_AMT' => $total, 'PAYMENTREQUEST_1_CURRENCYCODE' => 'EUR', 'PAYMENTREQUEST_1_ITEMAMT' => $total, 'PAYMENTREQUEST_1_DESC' => ' description detaillé222', 'PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID' => $mail_2, 'PAYMENTREQUEST_1_PAYMENTREQUESTID' => '1234567222', 'PAYMENTREQUEST_1_PAYMENTACTION' => 'Order', ); $response = $paypal->request('SetExpressCheckout', $params); if($response){ $paypal = 'https://www.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=' . $response['TOKEN']; }else{ var_dump($paypal->errors); die('Erreur '); } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-responsive.min.css"> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div class="navbar navbar-fixed"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">Paypal Express checkout</a> </div> </div> </div> <div class="container-fluid main"> <div class="row-fluid"> <div class="span12"> <p> <a href="<?= $paypal; ?>" class="btn btn-primary">Payer</a> </p> </div> </div> </div> </body> </html>
process.php
<?php require 'paypal.php'; $paypal = new Paypal(); $response = $paypal->request('GetExpressCheckoutDetails', array( 'TOKEN' => $_GET['token'] )); if($response){ if($response['CHECKOUTSTATUS'] == 'PaymentActionCompleted'){ die('Ce paiement a déjà été validé'); } }else{ var_dump($paypal->errors); die(); } $params = array( 'TOKEN' => $_GET['token'], 'PAYERID'=> $_GET['PayerID'], //'PAYMENTACTION' => 'Sale', 'PAYMENTREQUEST_0_AMT' => $response['PAYMENTINFO_0_AMT'], 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', 'PAYMENTREQUEST_0_ITEMAMT' => $response['PAYMENTINFO_0_ITEMAMT'], 'PAYMENTREQUEST_0_DESC' => $response['PAYMENTINFO_0_DESC'], 'PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID' => $response['PAYMENTINFO_0_SELLERPAYPALACCOUNTID'], 'PAYMENTREQUEST_0_PAYMENTREQUESTID' => $response['PAYMENTINFO_0_PAYMENTREQUESTID'], 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', 'PAYMENTREQUEST_1_AMT' => $response['PAYMENTINFO_1_AMT'], 'PAYMENTREQUEST_1_CURRENCYCODE' => 'EUR', 'PAYMENTREQUEST_1_ITEMAMT' => $response['PAYMENTINFO_1_ITEMAMT'], 'PAYMENTREQUEST_1_DESC' => $response['PAYMENTINFO_1_DESC'], 'PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID' => $response['PAYMENTINFO_1_SELLERPAYPALACCOUNTID'], 'PAYMENTREQUEST_1_PAYMENTREQUESTID' => $response['PAYMENTINFO_1_PAYMENTREQUESTID'], 'PAYMENTREQUEST_1_PAYMENTACTION' => 'Sale', ); $response = $paypal->request('DoExpressCheckoutPayment',$params); if($response){ var_dump($response); $response['PAYMENTINFO_0_TRANSACTIONID']; }else{ var_dump($paypal->errors); } ?>
paypal.php
<?php class Paypal{ private $user = "..."; private $pwd = "..."; private $signature = "..."; private $endpoint = "https://api-3t.paypal.com/nvp"; public $errors = array(); public function __construct($user = false, $pwd = false, $signature = false){ if($user){ $this->user = $user; } if($pwd){ $this->pwd = $pwd; } if($signature){ $this->signature = $signature; } } public function request($method, $params){ $params = array_merge($params, array( 'METHOD' => $method, 'VERSION' => '93.0', 'USER' => $this->user, 'SIGNATURE' => $this->signature, 'PWD' => $this->pwd )); $params = http_build_query($params); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->endpoint, CURLOPT_POST=> 1, CURLOPT_POSTFIELDS => $params, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_VERBOSE => 1 )); $response = curl_exec($curl); $responseArray = array(); parse_str($response, $responseArray); if(curl_errno($curl)){ $this->errors = curl_error($curl); curl_close($curl); return false; }else{ if($responseArray['ACK'] == 'Success'){ curl_close($curl); return $responseArray; }else{ $this->errors = $responseArray; curl_close($curl); return false; } } } }
1) details (email0 and 1, desc 0 and 1, Amount 0 and 1) not display in page payment paypal
2) doesn't work correctly: when I test live and click to pay, the redirection is to return URL, but when I check my paypal account there is no transation done?
What did I do wrong??
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- PayPal Checkout golden buttons opens checkout window with different options in PayPal Upgrade Community
- Recurring payments for cart with multiple individually subscribable items? in PayPal Payments Standard
- Payment not automatically being captured, funds not transferred in Sandbox Environment
- Need Help Upgrading to PayPal complete payments in PayPal Upgrade Community
- Advance integration form field processing in REST APIs