1

Possible Duplicate:
Paypal Checkout Express empty cart problem

i have an issue with paypal expresscheckout. I used the code from integration wizard https://www.paypal-labs.com/integrationwizard/ecpaypal/main.php, everything works fine but when i am redirected to paypal i would like to have an order summary like total amount and kind of description on paypal's page, but in my case its blank (like on this screen http://imageshack.us/photo/my-images/819/blankv.png/) i can put my code snippet that i am using:

                  // ==================================
                  // PayPal Express Checkout Module
                  // ==================================

                  //'------------------------------------
                  //' The paymentAmount is the total value of
                  //' the shopping cart, that was set
                  //' earlier in a session variable
                  //' by the shopping cart page
                  //'------------------------------------
                  $paymentAmount = $_SESSION["Payment_Amount"];

                  //'------------------------------------
                  //' When you integrate this code
                  //' set the variables below with
                  //' shipping address details
                  //' entered by the user on the
                  //' Shipping page.
                  //'------------------------------------

                  $sql = "SELECT * FROM orders_shipping_address WHERE orderid={$_SESSION['orderId']}";
                  $shipping_address = $this->db->query($sql)->fetchAll();

                  $shipToName = $shipping_address[0]['lastname'] . " " . $shipping_address[0]['firstname'];
                  $shipToStreet = $shipping_address[0]['street1'];
                  $shipToStreet2 = $shipping_address[0]['street2']; //Leave it blank if there is no value
                  $shipToCity = $shipping_address[0]['city'];
                  $shipToState = "Romania";
                  $shipToCountryCode = "RO"; // Please refer to the PayPal country codes in the API documentation
                  $shipToZip = $shipping_address[0]['zip'];
                  $phoneNum = $shipping_address[0]['phone'];

                  //'------------------------------------
                  //' The currencyCodeType and paymentType
                  //' are set to the selections made on the Integration Assistant
                  //'------------------------------------
                  $currencyCodeType = $_SESSION['currencyCodeType'] = "EUR";
                  $paymentType = $_SESSION['PaymentType'] = "Sale";

                  //'------------------------------------
                  //' The returnURL is the location where buyers return to when a
                  //' payment has been succesfully authorized.
                  //'
                  //' This is set to the value entered on the Integration Assistant
                  //'------------------------------------
                  $returnURL = $ret;

                  //'------------------------------------
                  //' The cancelURL is the location buyers are sent to when they hit the
                  //' cancel button during authorization of payment during the PayPal flow
                  //'
                  //' This is set to the value entered on the Integration Assistant
                  //'------------------------------------
                  $cancelURL = $cancel;

                  //'------------------------------------
                  //' Calls the SetExpressCheckout API call
                  //'
                  //' The CallMarkExpressCheckout function is defined in the file PayPalFunctions.php,
                  //' it is included at the top of this file.
                  //'-------------------------------------------------
                  $resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL,
                                                                                                                     $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
                                                                                                                     $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
                  );

                  $ack = strtoupper($resArray["ACK"]);
                  if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
                  {
                             //dump($resArray);
                             //die;
                             $token = urldecode($resArray["TOKEN"]);
                             $_SESSION['reshash']=$token;
                             RedirectToPayPal ( $token );
                  }

any help would be really apreciated, thanks in advance.

Community
  • 1
  • 1
Centurion
  • 5,169
  • 6
  • 28
  • 47

2 Answers2

4

In addition to the other comments here, be sure to use the undocumented "useraction" option when you redirect to PayPal after getting the response from SetExpressCheckout:

?cmd=_express-checkout&useraction=commit&token=the-returned-token

Here's the PayPal forum reference to this parameter

TechSavvySam
  • 1,382
  • 16
  • 28
  • 3
    "be sure to use" and "undocumented" in the same sentence scare me – Flexo Jan 30 '12 at 23:16
  • 2
    Yes Flexy, proves how bad Paypals documentation is.. – teecee Sep 15 '12 at 11:12
  • It makes me very sad that this was the solution. But, I'm very happy you posted it. It wasn't mentioned at all in their example here: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECGettingStarted/#idde509e1a-af2a-412a-b9ab-829b844986c5 – Grallen Aug 26 '14 at 03:31
3

Before calling SetExpressCheckout you need to add the items to the nvp string.

The extra parameters below add two products:

        &L_PAYMENTREQUEST_0_NAME0=productname
        &L_PAYMENTREQUEST_0_NUMBER0=productcode
        &L_PAYMENTREQUEST_0_DESC0=product-description
        &L_PAYMENTREQUEST_0_AMT0=productamount
        &L_PAYMENTREQUEST_0_QTY0=product-unit-price
        &L_PAYMENTREQUEST_0_NAME1=productname
        &L_PAYMENTREQUEST_0_NUMBER1=productcode
        &L_PAYMENTREQUEST_0_DESC1=product-description
        &L_PAYMENTREQUEST_0_AMT1=productamount
        &L_PAYMENTREQUEST_0_QTY1=product-unit-price
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
  • 2
    This data needs to be included in DoExpressCheckoutPayment as well, if you want it to appear on the transaction details on the buyer's side as well as your own transaction history. – Robert Nov 08 '11 at 15:59