cutExpressCheckout之后调用CreateRecu

cutExpressCheckout之后调用CreateRecu

本文介绍了如何在Paypal定期配置文件快速结账中的CallShortcutExpressCheckout之后调用CreateRecurringPaymentsProfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的网站上下载并实现了这个贝宝集成库.https://github.com/hrendoh/PayPal-Express-Checkout-example

I have downloaded and implemented this paypal integration lib on my website.https://github.com/hrendoh/PayPal-Express-Checkout-example

未创建重复配置文件.

Express checkout 的函数调用是

The function call for Express checkout is

  $resArray = CallShortcutExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
  $ack = strtoupper($resArray["ACK"]);
  if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
  {
  // if SetExpressCheckout is returned with success, move to paypal site for payments.
  RedirectToPayPal ( $resArray["TOKEN"] );
  }


function CallShortcutExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL)
    {
        //------------------------------------------------------------------------------------------------------------------------------------
        // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation

        $nvpstr="&AMT=". $paymentAmount;
        $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
        $nvpstr = $nvpstr . "&BILLINGAGREEMENTDESCRIPTION=".urlencode("Test Recurring Payment($1 monthly)");
        $nvpstr = $nvpstr . "&BILLINGTYPE=RecurringPayments";
        $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
        $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
        $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCodeType;

        $_SESSION["currencyCodeType"] = $currencyCodeType;
        $_SESSION["PaymentType"] = $paymentType;

        //'---------------------------------------------------------------------------------------------------------------
        //' Make the API call to PayPal
        //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
        //' If an error occured, show the resulting errors
        //'---------------------------------------------------------------------------------------------------------------

        $resArray=hash_call("SetExpressCheckout", $nvpstr);
        $ack = strtoupper($resArray["ACK"]);
        if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
        {
            $token = urldecode($resArray["TOKEN"]);
            $_SESSION['TOKEN']=$token;
        }

        return $resArray;
    }

此函数用于创建在示例代码中未调用的重复配置文件.

This function is for creating a recurring profile which is not called anywhere in the sample code.

function CreateRecurringPaymentsProfile()
    {
        //'--------------------------------------------------------------
        //' At this point, the buyer has completed authorizing the payment
        //' at PayPal.  The function will call PayPal to obtain the details
        //' of the authorization, incuding any shipping information of the
        //' buyer.  Remember, the authorization is not a completed transaction
        //' at this state - the buyer still needs an additional step to finalize
        //' the transaction
        //'--------------------------------------------------------------
        $token      = urlencode($_SESSION['TOKEN']);
        $email      = urlencode($_SESSION['email']);
        $shipToName     = urlencode($_SESSION['shipToName']);
        $shipToStreet       = urlencode($_SESSION['shipToStreet']);
        $shipToCity     = urlencode($_SESSION['shipToCity']);
        $shipToState        = urlencode($_SESSION['shipToState']);
        $shipToZip      = urlencode($_SESSION['shipToZip']);
        $shipToCountry  = urlencode($_SESSION['shipToCountry']);

        //'---------------------------------------------------------------------------
        //' Build a second API request to PayPal, using the token as the
        //'  ID to get the details on the payment authorization
        //'---------------------------------------------------------------------------
        $nvpstr="&TOKEN=".$token;
        #$nvpstr.="&EMAIL=".$email;
        $nvpstr.="&SHIPTONAME=".$shipToName;
        $nvpstr.="&SHIPTOSTREET=".$shipToStreet;
        $nvpstr.="&SHIPTOCITY=".$shipToCity;
        $nvpstr.="&SHIPTOSTATE=".$shipToState;
        $nvpstr.="&SHIPTOZIP=".$shipToZip;
        $nvpstr.="&SHIPTOCOUNTRY=".$shipToCountry;
        $nvpstr.="&PROFILESTARTDATE=".urlencode("2011-07-01T0:0:0");
        $nvpstr.="&DESC=".urlencode("Test Recurring Payment($1 monthly)");
        $nvpstr.="&BILLINGPERIOD=Month";
        $nvpstr.="&BILLINGFREQUENCY=5";
        $nvpstr.="&AMT=1";
        $nvpstr.="&CURRENCYCODE=USD";
        $nvpstr.="&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];

        //'---------------------------------------------------------------------------
        //' Make the API call and store the results in an array.
        //' If the call was a success, show the authorization details, and provide
        //'     an action to complete the payment.
        //' If failed, show the error
        //'---------------------------------------------------------------------------
        $resArray=hash_call("CreateRecurringPaymentsProfile",$nvpstr);
        $ack = strtoupper($resArray["ACK"]);
        return $resArray;
    }

我可以调用这个函数在 returnurl 中创建循环配置文件并将令牌 ID 和付款人 ID 传递给这个函数吗.

can I call this function to create the recurring profile in returnurl and pass the token id and payer id to this function.

推荐答案

无论您使用什么库,流程都应该是 SetExpressCheckout, GetExpressCheckoutDetails(可选),然后您可以使用任一/或/两者进行跟进 DoExpresscheckoutPayment创建RecurringPaymentsProfile.

Regardless of any library you're using, the flow should be SetExpressCheckout, GetExpressCheckoutDetails (optional), and then you can follow that up with either/or/both DoExpresscheckoutPayment and CreateRecurringPaymentsProfile.

如果您要使用 CRPP,则需要确保 SEC 包含计费协议参数,否则在调用 CRPP 时最终会出现无效令牌错误.这是一个旧示例 RAW API 请求流以使其正常工作.

If you're going to use CRPP you need to make sure SEC includes the billing agreement parameters, otherwise you'll end up with an invalid token error when you call CRPP. Here's an old sample of RAW API requests flow to make it work.

那么,有兴趣的可以看看我的PayPal 的 PHP 类库 使您更轻松.我知道我的作品.:)

Then, if you're interested, you may want to take a look at my PHP class library for PayPal to make this easier on you. I know mine works. :)

这篇关于如何在Paypal定期配置文件快速结账中的CallShortcutExpressCheckout之后调用CreateRecurringPaymentsProfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:44