将参数添加到Paypal Express Checkout按钮以进行订阅付款

时间:2017-12-04 23:35:00

标签: paypal express-checkout

是否可以简单地将参数添加到Paypal Express Checkout代码中 - 这些代码将设置为订阅 - 或指向现有订阅 - 已在我的卖家帐户中设置?

payment: function(data, actions) {
return actions.payment.create({
    payment: {
        transactions: [
            {
                amount: { total: '0.11', currency: 'USD' },
                hosted_button_id: 'PAYPALS_BUTTON_ID_7KDHB44PVYQ21',
                or_maybe_subscriptio_detials: 'monthly'

            }
        ]
    }
});

},

您知道 - 就像您可以使用常规HTML按钮一样:

<input type="hidden" name="hosted_button_id" value="PAYPALS_BUTTON_ID_7KDHB44PVYQ21">

或者您是否需要通过API动态设置订阅详细信息?

我喜欢弹出窗口并留在Express Checkout的网站上。 但是我不确定它是否值得一些额外的编码 - 当我可以用HTML按钮将它们发送到PayPal时。

1 个答案:

答案 0 :(得分:1)

您可以使用快速结账来使用定期付款,但集成本身包含;

  1. 设置付款授权(SetExpressCheckout)
  2. 将客户重定向到授权
  3. 获取客户详细信息
  4. 创建重复的个人资料。
  5. 它不像您用来了解的WPS按钮那样共享相同的停靠点。

    基本上在SetExpressCheckout中,您需要添加以下参数;

    &L_BILLINGTYPE0=RecurringPayments    #The type of billing agreement
    &L_BILLINGAGREEMENTDESCRIPTION0=RecurringPaymentWithEC    #The description of the billing agreement
    

    它将被设置为;

    Endpoint URL: https://api-3t.sandbox.paypal.com/nvp
    HTTP method: POST
    POST data:
    USER=insert_merchant_user_name_here
    &PWD=insert_merchant_password_here
    &SIGNATURE=insert_merchant_signature_value_here
    &METHOD=SetExpressCheckout
    &VERSION=86
    &L_BILLINGTYPE0=RecurringPayments    #The type of billing agreement
    &L_BILLINGAGREEMENTDESCRIPTION0=RecurringPaymentWithEC    #The description of the billing agreement
    &cancelUrl=https://example.com/cancel    #For use if the consumer decides not to proceed with payment
    &returnUrl=https://example.com/success   #For use if the consumer proceeds with payment
    

    用户重定向后,买方需要提供授权才能收取特定条款。

    之后调用CreateRecurringPaymentsProfileAPI

    Endpoint URL: https://api-3t.sandbox.paypal.com/nvp
    HTTP method: POST
    POST data:
    USER=insert_merchant_user_name_here
    &PWD=insert_merchant_password_here
    &SIGNATURE=insert_merchant_signature_value_here
    &METHOD=CreateRecurringPaymentsProfile
    &VERSION=86
    &TOKEN=insert_token_value_here
    &PAYERID=payer_id_value   #Identifies the customer's account
    &PROFILESTARTDATE=2012-05-11T00:00:00Z    #Billing date start, in UTC/GMT format
    &DESC=RecurringPaymentWithEC    #Profile description - same as billing agreement description
    &BILLINGPERIOD=Month    #Period of time between billings
    &BILLINGFREQUENCY=1    #Frequency of charges
    &AMT=10    #The amount the buyer will pay in a payment period
    &CURRENCYCODE=USD    #The currency, e.g. US dollars
    &COUNTRYCODE=US    #The country code, e.g. US
    &MAXFAILEDPAYMENTS=3    #Maximum failed payments before suspension of the profile
    

    作为回应,你会得到

    PROFILEID=I-6D5UGCVX1234
    &PROFILESTATUS=ActiveProfile
    &ACK=Success
    ...