22

I have integrated paypal into codeigniter with paypal_helper (didn't rememeber where I found it, but it is a slightly rewritten version of Paypals original code for express checkout. I try calling this function,

CallShortcutExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL)

sending $paymentAmount as int, $currencyCodeType as "NOK" and $paymentType as "Sale".

Both in Sandbox and live, no amount appears on the paypal site...

What could be wrong?

Edit, to further explain my process. I use this, mostly as specified in the https://www.paypal-labs.com/integrationwizard/ecpaypal/cart.php. This should be doable without the form? The paymentAmount could be sent as a standard variable, when calling the function CallShortcutExpressCheckout?:

$resArray = CallShortcutExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
$ack = strtoupper($resArray["ACK"]);
if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
{
    RedirectToPayPal ( $resArray["TOKEN"] );
} 
else  
{
    //Display a user friendly Error on the page using any of the following error information returned by PayPal
    $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
    $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
    $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
    $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);

    echo "SetExpressCheckout API call failed. ";
    echo "Detailed Error Message: " . $ErrorLongMsg;
    echo "Short Error Message: " . $ErrorShortMsg;
    echo "Error Code: " . $ErrorCode;
    echo "Error Severity Code: " . $ErrorSeverityCode;
}

The token is saved in a database. The user gets redirected to Paypal, where no amount is listed.

Robert
  • 19,326
  • 3
  • 58
  • 59
Øyvind
  • 979
  • 4
  • 17
  • 34

3 Answers3

51

As you're not passing so called 'line item details' (product data), PayPal doesn't display the total amount.

If you only want to show the amount for the current purchase, redirect buyers to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-xxxxxx&useraction=commit (instead of https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-xxxxx)

If you want to start sending line-item details to PayPal, include the following in your SetExpressCheckout API request:

// Total amount of the purchase, incl shipping, tax, etc  
PAYMENTREQUEST_0_AMT=300.0  
// Total amount of items purchased, excl shipping, tax, etc     
PAYMENTREQUEST_0_ITEMAMT=300.0  
// Authorize the funds first (Authorization), or capture immediately (Sale)?    
PAYMENTREQUEST_0_PAYMENTACTION=Sale  
// First item  
L_PAYMENTREQUEST_0_NAME0=Item1  
L_PAYMENTREQUEST_0_QTY0=1  
L_PAYMENTREQUEST_0_AMT0=100.00  
// Second item  
L_PAYMENTREQUEST_0_NAME1=Item2  
L_PAYMENTREQUEST_0_QTY1=1  
L_PAYMENTREQUEST_0_AMT1=200.00  

If you want to see this in your own history as well, you'll also need to include this in DoExpressCheckoutPayment.

This was also posted in php paypal express checkout problem

Community
  • 1
  • 1
Robert
  • 19,326
  • 3
  • 58
  • 59
  • 1
    Note: This will not include this data in any PayPal reporting, so if that's your goal, you'll still need to add line-items. – Robert Nov 21 '11 at 20:16
  • I know, I understood; simply added a note for anyone else who may happen to stumble upon this answer in the future. :-) – Robert Nov 21 '11 at 22:31
  • 1
    I found that the amount wouldn't appear for api version 54.0, but would for 65.1 (which is the version that the Digital Category appeared) https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout. Is there a minimum API version? – Trent Sep 06 '12 at 10:41
  • Do you add useraction=commit to the SetExpressCheckout option? I found that this didn't help?! – Trent Sep 06 '12 at 10:49
  • 1
    Hi Taras; there is no point in using an old API version. Just stick with the most recent one (94) if you're working on a new integration. – Robert Sep 06 '12 at 20:09
  • With the lastest version of the API as of 2015 the amount in the checkout pages would sometimes disappear for no reason; adding `&useraction=commit` to the checkout url seems to fix this behaviour. – Mahn Jul 01 '15 at 13:29
  • Great. Was working with active merchant and this was the missing piece! – Phillipp Sep 12 '15 at 07:30
  • Thanks so much for this! We were banging to developer heads against the wall to figure out how to get a Total displayed. – zıəs uɐɟəʇs Dec 20 '16 at 09:41
  • &useraction=commit has [some documentation](https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#allow-buyers-to-complete-purchases-on-paypal) – mndrix Jan 17 '17 at 14:48
14

After an extensive reading on messy Paypal docs site this is a short ExpressCheckout guide working on year 2013. I wanted to have item details shown on paypal payment page and merchant transaction history page.

Paypal documentation links

You can call following url methods directly on web browser, update token and payerid parameters accordingly.

This is a digital goods so shipping and handling fees are not given. Single item row. Amount and tax fees are given. Do not require a confirmed delivery address, no shipping address fields, no allow freetext note, payer don't need paypal account and no registration required (solutiontype=sole). Activate credit card section on paypal site (landingpage=billing). Use customized brand title on paypal site. Use custom field to give own value for tracking purpose. Merchant site transaction history must show item details (give item details on SetExpressCheckout and DoExpressCheckoutPayment methods).

SetExpressCheckout method opens a new transaction

https://api-3t.sandbox.paypal.com/nvp?
    USER=<userid>
    &PWD=<pwd>
    &SIGNATURE=<mysig>
    &METHOD=SetExpressCheckout
    &VERSION=98
    &PAYMENTREQUEST_0_PAYMENTACTION=SALE
    &REQCONFIRMSHIPPING=0
    &NOSHIPPING=1
    &ALLOWNOTE=0
    &SOLUTIONTYPE=Sole
    &LANDINGPAGE=Billing
    &BRANDNAME=MY+WEBSHOP+TITLE
    &PAYMENTREQUEST_0_AMT=22.22
    &PAYMENTREQUEST_0_TAXAMT=4.30
    &PAYMENTREQUEST_0_ITEMAMT=17.92
    &PAYMENTREQUEST_0_DESC=mypurdesc
    &PAYMENTREQUEST_0_CUSTOM=custom1
    &PAYMENTREQUEST_0_CURRENCYCODE=EUR
    &L_PAYMENTREQUEST_0_NUMBER0=itemid1
    &L_PAYMENTREQUEST_0_NAME0=MyItem1
    &L_PAYMENTREQUEST_0_DESC0=Item1+description
    &L_PAYMENTREQUEST_0_QTY0=1
    &L_PAYMENTREQUEST_0_AMT0=17.92
    &L_PAYMENTREQUEST_0_TAXAMT0=4.30
    &RETURNURL=https://myserver.com/webapp/paypal.jsp%3Fcmd=successexp
    &CANCELURL=https://myserver.com/webapp/paypal.jsp%3Fcmd=cancelexp

Reply must have ACK=Success or ACK=SuccessWithWarning, read TOKEN value

Redirect user browser to Paypal site, give token value

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<token>

User uses paypal account or credit card. Paypal redirects user to return or cancel url. Redirect destination url gets token and PayerID parameter values. Transaction is not completed yet we must call doExpressCheckoutPayment method.

Show confirm dialog on screen (with OK, CANCEL button) or simple case commit a transaction and show "Thank you, purchase completed" message. User has already accepted a payment in paypal site and expects transaction be finalized.

You may commit transaction within a same request-response handler or using asynchronous background task. Paypal site may temporarily be unavailable so don't expect it to work immediately.

Commit transaction if redirect was success, use token and payerid

https://api-3t.sandbox.paypal.com/nvp?
    USER=<userid>
    &PWD=<pwd>
    &SIGNATURE=<mysig>
    &METHOD=DoExpressCheckoutPayment
    &VERSION=98
    &PAYMENTREQUEST_0_PAYMENTACTION=SALE
    &PAYMENTREQUEST_0_AMT=22.22
    &PAYMENTREQUEST_0_TAXAMT=4.30
    &PAYMENTREQUEST_0_ITEMAMT=17.92
    &PAYMENTREQUEST_0_CURRENCYCODE=EUR
    &L_PAYMENTREQUEST_0_NUMBER0=itemid1
    &L_PAYMENTREQUEST_0_NAME0=MyItem1
    &L_PAYMENTREQUEST_0_QTY0=1
    &L_PAYMENTREQUEST_0_AMT0=17.92
    &L_PAYMENTREQUEST_0_TAXAMT0=4.30
    &token=<token>
    &payerid=<payerid>

Read ACK=Success and verify fields

ACK=Success
PAYMENTINFO_0_PAYMENTSTATUS=Completed
PAYMENTINFO_0_ACK=Success
PAYMENTINFO_0_AMT=22.22     total amount must match
PAYMENTINFO_0_FEEAMT=0.99   (just for fun, read paypal comission fee)
PAYMENTINFO_0_CURRENCYCODE=EUR  currency must match

(Optional) Read transaction details from Paypal

You can use this during transaction workflow or any time if stored a token for later use.

https://api-3t.sandbox.paypal.com/nvp
    ?USER=<userid>
    &PWD=<pwd>
    &SIGNATURE=<mysig>
    &METHOD=GetExpressCheckoutDetails
    &VERSION=98
    &token=<token>

Read response parameters.

ACK=Success
CHECKOUTSTATUS=PaymentActionCompleted
PAYMENTREQUEST_0_AMT=22.22
PAYMENTREQUEST_0_TAXAMT=4.30
PAYMENTREQUEST_0_CURRENCYCODE=EUR

(Optional) Read and save transaction id, correlation id and token id and write to logtable.

PAYMENTREQUEST_0_TRANSACTIONID=11E585715B622391E
CORRELATIONID=4534b683c335f

I'm willing to receive comments if there is any logic errors.

Whome
  • 10,181
  • 6
  • 53
  • 65
  • 1
    Ideally GetExpressCheckoutDetails should take place before DoExpressCheckoutPayment. It's typically used to provide a 'review your order' type page before calling DoExpressCheckoutPayment to finalize the transaction. – Robert Jul 25 '13 at 04:32
0

Check this link, hope it helps in some sense: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted

PAYMENTREQUEST_0_AMT=amount //for amount
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162