Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 如何使用Express Checkout创建定期付款配置文件_Codeigniter_Paypal_Payment Gateway_Express Checkout - Fatal编程技术网

Codeigniter 如何使用Express Checkout创建定期付款配置文件

Codeigniter 如何使用Express Checkout创建定期付款配置文件,codeigniter,paypal,payment-gateway,express-checkout,Codeigniter,Paypal,Payment Gateway,Express Checkout,我目前正在我的网站上集成贝宝定期付款流程。我用了这个密码 function process() { include_once("config.php"); include_once("paypal.class.php"); if($_POST) //Post Data received from product list page. { //Mainly we need 4 variables from an item, Item Name, I

我目前正在我的网站上集成贝宝定期付款流程。我用了这个密码

    function process()
    {
    include_once("config.php");
    include_once("paypal.class.php");

    if($_POST) //Post Data received from product list page.
{
    //Mainly we need 4 variables from an item, Item Name, Item Price, Item Number and Item Quantity.
    $ItemName = $_POST["itemname"]; //Item Name
    $ItemPrice = $_POST["itemprice"]; //Item Price
    $ItemNumber = $_POST["itemnumber"]; //Item Number
    $ItemQty = $_POST["itemQty"]; // Item Quantity
    $ItemTotalPrice = ($ItemPrice*$ItemQty); //(Item Price x Quantity = Total) Get total amount of product; 


    //Data to be sent to paypal
    $padata =   '&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
                '&PAYMENTACTION=Sale'.
                '&ALLOWNOTE=1'.
                '&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
                '&PAYMENTREQUEST_0_AMT='.urlencode($ItemTotalPrice).
                '&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice). 
                '&L_PAYMENTREQUEST_0_QTY0='. urlencode($ItemQty).
                '&L_PAYMENTREQUEST_0_AMT0='.urlencode($ItemPrice).
                '&L_PAYMENTREQUEST_0_NAME0='.urlencode($ItemName).
                '&L_PAYMENTREQUEST_0_NUMBER0='.urlencode($ItemNumber).
                '&AMT='.urlencode($ItemTotalPrice). 
                '&L_BILLINGTYPE0='.urlencode('RecurringPayments').
                '&L_BILLINGAGREEMENTDESCRIPTION0='.urlencode('message plan').               
                '&RETURNURL='.urlencode($PayPalReturnURL ).
                '&CANCELURL='.urlencode($PayPalCancelURL);



        //We need to execute the "SetExpressCheckOut" method to obtain paypal token
        $paypal= new MyPayPal();
        $httpParsedResponseAr = $paypal->PPHttpPost('SetExpressCheckout', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);

        //Respond according to message we receive from Paypal
        if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"]))
        {

                // If successful set some session variable we need later when user is redirected back to page from paypal. 
                $_SESSION['itemprice'] =  $ItemPrice;
                $_SESSION['totalamount'] = $ItemTotalPrice;
                $_SESSION['itemName'] =  $ItemName;
                $_SESSION['itemNo'] =  $ItemNumber;
                $_SESSION['itemQTY'] =  $ItemQty;

                if($PayPalMode=='sandbox')
                {
                    $paypalmode     =   '.sandbox';
                }
                else
                {
                    $paypalmode     =   '';
                }
                //Redirect user to PayPal store with Token received.
                $paypalurl ='https://www'.$paypalmode.'.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='.$httpParsedResponseAr["TOKEN"].'';
                header('Location: '.$paypalurl);

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

}

//Paypal redirects back to this page using ReturnURL, We should receive TOKEN and Payer ID
if(isset($_GET["token"]) && isset($_GET["PayerID"]))
{
    //we will be using these two variables to execute the "DoExpressCheckoutPayment"
    //Note: we haven't received any payment yet.

    $token = $_GET["token"];
    $playerid = $_GET["PayerID"];

    //get session variables
    $ItemPrice      = $_SESSION['itemprice'];
    $ItemTotalPrice = $_SESSION['totalamount'];
    $ItemName       = $_SESSION['itemName'];
    $ItemNumber     = $_SESSION['itemNo'];
    $ItemQTY        =$_SESSION['itemQTY'];

    $padata =   '&TOKEN='.urlencode($token).
                        '&PAYERID='.urlencode($playerid).
                        '&PAYMENTACTION='.urlencode("SALE").
                        '&AMT='.urlencode($ItemTotalPrice).
                        '&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
                        '&NOTIFYURL='.urlencode('http://mywebiste.com/listner');

    //We need to execute the "DoExpressCheckoutPayment" at this point to Receive payment from user.
    $paypal= new MyPayPal();
    $httpParsedResponseAr = $paypal->PPHttpPost('DoExpressCheckoutPayment', $padata, $PayPalApiUsername, $PayPalApiPassword,             $PayPalApiSignature, $PayPalMode);

    //Check if everything went ok..
    if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) 
    {
            echo '<h2>Success</h2>';
            echo 'Your Transaction ID :'.urldecode($httpParsedResponseAr["TRANSACTIONID"]);

                /*
                //Sometimes Payment are kept pending even when transaction is complete. 
                //May be because of Currency change, or user choose to review each payment etc.
                //hence we need to notify user about it and ask him manually approve the transiction
                */

                if('Completed' == $httpParsedResponseAr["PAYMENTSTATUS"])
                {
                    echo '<div style="color:green">Payment Received! Your product will be sent to you very soon!</div>';
                }
                elseif('Pending' == $httpParsedResponseAr["PAYMENTSTATUS"])
                {
                    echo '<div style="color:red">Transaction Complete, but payment is still pending! You need to manually authorize this payment in your <a target="_new" href="http://www.paypal.com">Paypal Account</a></div>';
                }


            echo '<br /><b>Stuff to store in database :</b><br /><pre>';

                $transactionID = urlencode($httpParsedResponseAr["TRANSACTIONID"]);
                $nvpStr = "&TRANSACTIONID=".$transactionID;
                $paypal= new MyPayPal();
                $httpParsedResponseAr = $paypal->PPHttpPost('GetTransactionDetails', $nvpStr, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);

    if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {

                $nvpstr="&TOKEN=".$_GET['token'];
                $nvpstr.="&BILLINGPERIOD=Month";
                $nvpstr.="&BILLINGFREQUENCY=1";
                $nvpstr.="&AMT=1";
                $nvpstr.="&CURRENCYCODE=USD";
                $nvpstr.="&COUNTRYCODE=US";
                $nvpstr.="&PAYERID=".$httpParsedResponseAr['PAYERID'];
                $nvpstr.="&PROFILESTARTDATE=".date('Y-m-d');
                $recurr = $paypal->PPHttpPost('CreateRecurringPaymentsProfile',$nvpStr,$PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);

                    echo '<pre>';
                    print_r($httpParsedResponseAr);
                    echo '</pre>';

                    print_r($recurr);

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

                }

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

    }
我不知道我在这件事上哪里做错了


多谢各位

您的请求缺少创建定期付款配置文件所需的一组参数。请参阅

我认为这个过程是错误的:第二个调用应该是GetExpressCheckoutDetails,以检索Payrid,以便能够执行CreateRecurringPaymentsProfile

只需按照本教程逐步操作即可:

我添加了其他参数。仍然得到同样的回答你知道问题出在哪里吗?我也有同样的问题
Array
(
    [TIMESTAMP] => 2013%2d03%2d18T05%3a32%3a06Z
    [CORRELATIONID] => 912b6004f40bb
    [ACK] => Failure
    [VERSION] => 76%2e0
    [BUILD] => 5294323
    [L_ERRORCODE0] => 11585
    [L_ERRORCODE1] => 11518
    [L_ERRORCODE2] => 11516
    [L_ERRORCODE3] => 11519
    [L_ERRORCODE4] => 11549
    [L_SHORTMESSAGE0] => Missing%20Token%20or%20payment%20source
    [L_SHORTMESSAGE1] => Invalid%20billing%20period%2e
    [L_SHORTMESSAGE2] => Invalid%20billing%20frequency
    [L_SHORTMESSAGE3] => Invalid%20amount
    [L_SHORTMESSAGE4] => Start%20Date%20is%20required
    [L_LONGMESSAGE0] => Missing%20Token%20or%20buyer%20credit%20card
    [L_LONGMESSAGE1] => Billing%20period%20must%20be%20one%20of%20Day%2c%20Week%2c%20SemiMonth%2c%20or%20Year
    [L_LONGMESSAGE2] => Billing%20frequency%20must%20be%20%3e%200%20and%20be%20less%20than%20or%20equal%20to%20one%20year
    [L_LONGMESSAGE3] => Bill%20amount%20must%20be%20greater%20than%200
    [L_LONGMESSAGE4] => Subscription%20start%20date%20is%20required
    [L_SEVERITYCODE0] => Error
    [L_SEVERITYCODE1] => Error
    [L_SEVERITYCODE2] => Error
    [L_SEVERITYCODE3] => Error
    [L_SEVERITYCODE4] => Error
)