user3273812
user3273812

Reputation: 33

PaymentActionNotInitiated when do Express Checkout

I play Sandbox to put Express Checkout to my site. Eveyrthing goes fine: user clicks payment button, goes redirected to paypal, logs in with Sandbox buyer's credentials getting to his sandbox page, clicks Continue button and finally goes redirected back to my site just click Confirmation button. But nothing happens to funbdings of Sandbox Seller and Byer test accounts. I revealed that both GetExpressCheckoutDetails and DoExpressCheckoutPayment contain CHECKOUTSTATUS=PaymentActionNotInitiated. According to Paypal integration - GetExpressCheckout "A value of PaymentActionNotInitiated occurs when you submit a GetExpressCheckoutDetails API call before the buyer logs into a PayPal account or when they log into their account, return to your website but have not completed the payment yet."

Then what does mean "... but have not completed the payment yet"? I asumed that payear approves his payment when clicks Continue button at Paypal page before thr return back to my site. So, after redirecting I simply call GetExpressCheckoutDetails to get payer's ID and then call DoExpressCheckoutPayment. And payer click Confirm button only just to go further.

As CHECKOUTSTATUS=PaymentActionNotInitiated happens first time from GetExpressCheckoutDetails imediately after redirect to the site I can expect that something has to be completed by payer at Paypal page betwen Continue click and redirect to the site. But there is nothing more. Could somebody comment?

Below is a list or NVP excange:

-- SetExpressCheckout Request --
https://api-3t.sandbox.paypal.com/nvp?Method=SetExpressCheckout&
VERSION=93.0&
USER=<facilitator's id>&
PWD=<facilitator's pwd>&
SIGNATURE=<facilitator's signature>&
PAYMENTREQUEST_0_PAYMENTACTION=SALE&
PAYMENTREQUEST_0_AMT=25.00&
PAYMENTREQUEST_0_CURRENCYCODE=USD&
RETURNURL=http%3a%2f%2flocalhost%3a3655%2faccount%2fconfirmpayment.aspx?im=11402062107&
CANCELURL=http%3a%2f%2flocalhost%3a3655%2f%3fr%3d1

-- SetExpressCheckout Response --
TOKEN=EC-6BF53699XL820525R&
TIMESTAMP=2014-02-06T10:07:08Z&
CORRELATIONID=b1c1c6199de7e&
ACK=Success&
VERSION=93.0&
BUILD=9605603

-- Redirect to PayPal --
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&
token=EC-6BF53699XL820525R

-- GetExpressCheckoutDetails Request --
https://api-3t.sandbox.paypal.com/nvp?Method=GetExpressCheckoutDetails&
VERSION=93.0&
USER=<facilitator's id>&
PWD=<facilitator's pwd>&
SIGNATURE=<facilitator's signature>&
TOKEN=EC-6BF53699XL820525R

-- GetExpressCheckoutDetails Response --
TOKEN=EC-6BF53699XL820525R&
CHECKOUTSTATUS=PaymentActionNotInitiated&
TIMESTAMP=2014-02-06T10:08:17Z&
CORRELATIONID=dcbb85815cdc4&
ACK=Success&
VERSION=93.0&
BUILD=9605603&
EMAIL=<payer's e-mail>&
PAYERID=ZXPJ82TPPFGQ6&
PAYERSTATUS=verified&
FIRSTNAME=Jonh&
LASTNAME=Doe&
COUNTRYCODE=US&
SHIPTONAME=Jonh Doe&
SHIPTOSTREET=1 Main St&
SHIPTOCITY=San Jose&
SHIPTOSTATE=CA&
SHIPTOZIP=95131&
SHIPTOCOUNTRYCODE=US&
SHIPTOCOUNTRYNAME=United States&
ADDRESSSTATUS=Confirmed&
CURRENCYCODE=USD&
AMT=25.00&
SHIPPINGAMT=0.00&
HANDLINGAMT=0.00&
TAXAMT=0.00&
INSURANCEAMT=0.00&
SHIPDISCAMT=0.00&
PAYMENTREQUEST_0_CURRENCYCODE=USD&
PAYMENTREQUEST_0_AMT=25.00&
PAYMENTREQUEST_0_SHIPPINGAMT=0.00&
PAYMENTREQUEST_0_HANDLINGAMT=0.00&
PAYMENTREQUEST_0_TAXAMT=0.00&
PAYMENTREQUEST_0_INSURANCEAMT=0.00&
PAYMENTREQUEST_0_SHIPDISCAMT=0.00&
PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&
PAYMENTREQUEST_0_SHIPTONAME=Jonh Doe&
PAYMENTREQUEST_0_SHIPTOSTREET=1 Main St&
PAYMENTREQUEST_0_SHIPTOCITY=San Jose&
PAYMENTREQUEST_0_SHIPTOSTATE=CA&
PAYMENTREQUEST_0_SHIPTOZIP=95131&
PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=US&
PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME=United States&
PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed&
PAYMENTREQUESTINFO_0_ERRORCODE=0

-- DoExpressCheckoutPayment Request --
https://api-3t.sandbox.paypal.com/nvp?Method=DoExpressCheckoutPayment&
VERSION=93.0&
USER=<facilitator's id>&
PWD=<facilitator's pwd>&
SIGNATURE=<facilitator's signature>&
TOKEN=EC-6BF53699XL820525R&
PAYERID=ZXPJ82TPPFGQ6&
PAYMENTREQUEST_0_PAYMENTACTION=SALE&
PAYMENTREQUEST_0_AMT=25.00&
PAYMENTREQUEST_0_CURRENCYCODE=USD

-- DoExpressCheckoutPayment Response --
TOKEN=EC-6BF53699XL820525R&
CHECKOUTSTATUS=PaymentActionNotInitiated&
TIMESTAMP=2014-02-06T10:08:48Z&
CORRELATIONID=b8fc094441d51&
ACK=Success&
VERSION=93.0&
BUILD=9605603&
EMAIL=<payer's e-mail>&
PAYERID=ZXPJ82TPPFGQ6&
PAYERSTATUS=verified&
FIRSTNAME=Jonh&
LASTNAME=Doe&
COUNTRYCODE=US&
SHIPTONAME=Jonh Doe&
SHIPTOSTREET=1 Main St&
SHIPTOCITY=San Jose&
SHIPTOSTATE=CA&
SHIPTOZIP=95131&
SHIPTOCOUNTRYCODE=US&
SHIPTOCOUNTRYNAME=United States&
ADDRESSSTATUS=Confirmed&
CURRENCYCODE=USD&
AMT=25.00&
SHIPPINGAMT=0.00&
HANDLINGAMT=0.00&
TAXAMT=0.00&
INSURANCEAMT=0.00&
SHIPDISCAMT=0.00&
PAYMENTREQUEST_0_CURRENCYCODE=USD&
PAYMENTREQUEST_0_AMT=25.00&
PAYMENTREQUEST_0_SHIPPINGAMT=0.00&
PAYMENTREQUEST_0_HANDLINGAMT=0.00&
PAYMENTREQUEST_0_TAXAMT=0.00&
PAYMENTREQUEST_0_INSURANCEAMT=0.00&
PAYMENTREQUEST_0_SHIPDISCAMT=0.00&
PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false
&PAYMENTREQUEST_0_SHIPTONAME=Jonh Doe&
PAYMENTREQUEST_0_SHIPTOSTREET=1 Main St&
PAYMENTREQUEST_0_SHIPTOCITY=San Jose&PAYMENTREQUEST_0_SHIPTOSTATE=CA&
PAYMENTREQUEST_0_SHIPTOZIP=95131&
PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=US&
PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME=United States&
PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed&
PMENTREQUESTINFO_0_ERRORCODE=0

Upvotes: 3

Views: 3537

Answers (2)

Ashraful Islam
Ashraful Islam

Reputation: 47

You can call this way, it will work.

<?php
$padata                 =   '&TOKEN='.urlencode(_GET('token'));
$httpParsedResponseAr   = $this->PPHttpPost('GetExpressCheckoutDetails', $padata, PPL_API_USER, PPL_API_PASSWORD, PPL_API_SIGNATURE, PPL_MODE);
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {         
    $i = 0;
    $order_array = array();
    foreach(array_keys($httpParsedResponseAr) as $key) {
        if (strpos($key, 'L_PAYMENTREQUEST_0_NUMBER') !== false) {
            $_SESSION['order_no'][$i] = $httpParsedResponseAr[$key];
            $i++;
        }
    }

    if($httpParsedResponseAr['CHECKOUTSTATUS'] == 'PaymentActionNotInitiated') {
        $padata  =  '&TOKEN='.$httpParsedResponseAr['TOKEN'];
        $padata .=  '&PAYERID='.$httpParsedResponseAr['PAYERID'];
        $padata .=  '&PAYMENTREQUEST_0_PAYMENTACTION='.urlencode("SALE");
        
        //set item info here, otherwise we won't see product details later
        for($i = 0; $i < $count_order2; $i++) {
            $padata .=  '&L_PAYMENTREQUEST_0_NAME'.$i.'='.$httpParsedResponseAr['L_PAYMENTREQUEST_0_NAME'.$i];
            $padata .=  '&L_PAYMENTREQUEST_0_NUMBER'.$i.'='.$httpParsedResponseAr['L_PAYMENTREQUEST_0_NUMBER'.$i];
            $padata .=  '&L_PAYMENTREQUEST_0_DESC'.$i.'='.$httpParsedResponseAr['L_PAYMENTREQUEST_0_DESC'.$i];
            $padata .=  '&L_PAYMENTREQUEST_0_AMT'.$i.'='.$httpParsedResponseAr['L_PAYMENTREQUEST_0_AMT'.$i];
            $padata .=  '&L_PAYMENTREQUEST_0_QTY'.$i.'='.$httpParsedResponseAr['L_PAYMENTREQUEST_0_QTY'.$i];
        }
        
        $padata .=  '&PAYMENTREQUEST_0_ITEMAMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_ITEMAMT'];
        $padata .=  '&PAYMENTREQUEST_0_TAXAMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_TAXAMT'];
        $padata .=  '&PAYMENTREQUEST_0_SHIPPINGAMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_SHIPPINGAMT'];
        $padata .=  '&PAYMENTREQUEST_0_HANDLINGAMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_HANDLINGAMT'];
        $padata .=  '&PAYMENTREQUEST_0_SHIPDISCAMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_SHIPDISCAMT'];
        $padata .=  '&PAYMENTREQUEST_0_INSURANCEAMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_INSURANCEAMT'];
        $padata .=  '&PAYMENTREQUEST_0_AMT='.$httpParsedResponseAr['PAYMENTREQUEST_0_AMT'];
        $padata .=  '&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode(PPL_CURRENCY_CODE);                 
        
        //We need to execute the "DoExpressCheckoutPayment" at this point to Receive payment from user.
        $httpResDoExpChkPay = $this->PPHttpPost('DoExpressCheckoutPayment', $padata);
        
        //Check if everything went ok..
        if("SUCCESS" == strtoupper($httpResDoExpChkPay["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpResDoExpChkPay["ACK"])) {
            echo '<h2>Success</h2>';
            echo 'Your Transaction ID : '.urldecode($httpResDoExpChkPay["PAYMENTINFO_0_TRANSACTIONID"]);
            
            //Sometimes Payment are kept pending even when transaction is complete. 
            //hence we need to notify user about it and ask him manually approve the transiction
            if('Completed' == $httpResDoExpChkPay["PAYMENTINFO_0_PAYMENTSTATUS"]) {
                echo '<div style="color:green">Payment Received! Your product will be sent to you very soon!</div>';
            } elseif('Pending' == $httpResDoExpChkPay["PAYMENTINFO_0_PAYMENTSTATUS"]) {             
                echo '<div style="color:red">Transaction Complete, but payment may still be pending! '. 'If that\'s the case, You can manually authorize this payment in your <a target="_new" href="http://www.paypal.com">Paypal Account</a></div>';              
            }

        } else {
            echo '<div style="color:red"><b>Error : </b>'.urldecode($httpResDoExpChkPay["L_LONGMESSAGE0"]).'</div>';
            echo '<pre>';
            print_r($httpResDoExpChkPay);
            echo '</pre>';
        }           

    }
}       

Upvotes: -1

Sam Jones
Sam Jones

Reputation: 4618

I had the same problem.

Calling GetExpressCheckoutDetails again after DoExpressCheckoutPayment should return PaymentActionCompleted.

When getting the CHECKOUTSTATUS of PaymentActionCompleted, the response will be similar to:

TOKEN=EC%2d3LD60853SC435481J&
BILLINGAGREEMENTACCEPTEDSTATUS=0&
CHECKOUTSTATUS=PaymentActionCompleted&
TIMESTAMP=2015%2d01%2d28T17%3a03%3a01Z&
CORRELATIONID=c36f3ff4b39d2&
ACK=Success&
VERSION=93
&BUILD=15009693&
EMAIL=mysupersecretemailaddress,
PAYERID=H54VEN293PLFL&
PAYERSTATUS=verified&
FIRSTNAME=Test&
LASTNAME=User&COUNTRYCODE=GB&
CURRENCYCODE=GBP&
AMT=35%2e98&
SHIPPINGAMT=0%2e00&
HANDLINGAMT=0%2e00&
TAXAMT=0%2e00&
INSURANCEAMT=0%2e00&
SHIPDISCAMT=0%2e00&
PAYMENTREQUEST_0_CURRENCYCODE=GBP&
PAYMENTREQUEST_0_AMT=35%2e98&
PAYMENTREQUEST_0_SHIPPINGAMT=0%2e00&
PAYMENTREQUEST_0_HANDLINGAMT=0%2e00&
PAYMENTREQUEST_0_TAXAMT=0%2e00&
PAYMENTREQUEST_0_INSURANCEAMT=0%2e00&
PAYMENTREQUEST_0_SHIPDISCAMT=0%2e00&
PAYMENTREQUEST_0_TRANSACTIONID=3CU92636XH572882Y&
PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&
PAYMENTREQUESTINFO_0_TRANSACTIONID=3CU92636XH572882Y&
PAYMENTREQUESTINFO_0_ERRORCODE=0

Upvotes: 1

Related Questions