接受托管定期计费

Accept Hosted Recurring billing

getHostedPaymentPageRequest只提供了两种交易方式,使用下面的XML.

为表单生成token

两种交易类型:

  1. authCaptureTransaction
  2. authOnlyTransaction
<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name>5KP3u95bQpv</name>
    <transactionKey>346HZ32z3fP4hTG2</transactionKey>
  </merchantAuthentication>
  <transactionRequest>
    <transactionType>authCaptureTransaction</transactionType>
    <amount>20.00</amount>
    <profile>
      <customerProfileId>123456789</customerProfileId>
    </profile>
    <customer>
      <email>ellen@mail.com</email>
    </customer>
    <billTo>
        <firstName>Ellen</firstName>
        <lastName>Johnson</lastName>
        <company>Souveniropolis</company>
        <address>14 Main Street</address>
        <city>Pecan Springs</city>
        <state>TX</state>
        <zip>44628</zip>
        <country>USA</country>
    </billTo>
  </transactionRequest>
  <hostedPaymentSettings>
    <setting>
      <settingName>hostedPaymentReturnOptions</settingName>
      <settingValue>{"showReceipt": true, "url": "https://url-when-continue-button-clicked/receipt", "urlText": "Continue", "cancelUrl": "https://url-when-cancel-button-clicked.com/cancel", "cancelUrlText": "Cancel"}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentButtonOptions</settingName>
      <settingValue>{"text": "Pay"}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentStyleOptions</settingName>
      <settingValue>{"bgColor": "blue"}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentPaymentOptions</settingName>
      <settingValue>{"cardCodeRequired": false, "showCreditCard": true, "showBankAccount": true}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentSecurityOptions</settingName>
      <settingValue>{"captcha": false}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentShippingAddressOptions</settingName>
      <settingValue>{"show": false, "required": false}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentBillingAddressOptions</settingName>
      <settingValue>{"show": true, "required":false}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentCustomerOptions</settingName>
      <settingValue>{"showEmail": false, "requiredEmail": false, "addPaymentProfile": true}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentOrderOptions</settingName>
      <settingValue>{"show": true, "merchantName": "G and S Questions Inc."}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentIFrameCommunicatorUrl</settingName>
      <settingValue>{"url": "https://url-contianing-iframe"}</settingValue>
    </setting>
  </hostedPaymentSettings>
</getHostedPaymentPageRequest>

我应该如何修改 XML 才能获得循环计费的表格?因为我没有在 accept hosted 中找到任何实施示例来获取用于定期计费的有效表单令牌。没有提到接受托管文档的定期计费。

此外,我使用的是重定向方法而不是 iframe 方法来显示没有 return 任何响应的表单。

没有一种表单可以通过托管表单创建订阅。幸运的是已经有人 posted how to do this on their forum 我将在这里重新发布:

If you are trying to use the Accept hosted forms for creating a subscription, you actually wouldn't use the hosted payment page, described here.

The correct workflow is, using the API, make a request for a customer profile: createCustomerProfileRequest. All you need is their email address.

After getting the profile id from that call, you make a request for a token for the accept hosted add profile form. Documentation for this form and others is here. I didn't even realize these forms existed. It's hard to find them in google even if you know what you're looking for.

You need the customer profile id to get the token for the "add payment profile" form.

You handle the response to this form client-side since you are getting the response from the IFrameCommunicator page you set up (it works the same for the payment form or these customer profile type forms). Here's a sample.

I then called server-side code to create the subscription with the api - I pass it the customer profile id because honestly I don't know if the form returns the newly created payment profile id. If you have the customer profile id, you can retrieve any existing payment profiles. So, using just the customer profile id, I make a call to get the payment profile id - getCustomerProfileRequest. That call returns all sorts of stuff including the payment profiles. I just grab the first one. Now with the customer profile id and the payment profile id, I can create a subscription - ARBCreateSubscriptionRequest. There are samples out there to help you form the subscription properly.

Final note: if you are testing this in the sandbox, you will need to put a 20 second delay between obtaining a payment profile id and obtaining a subscription using the api. The sandbox does not have the resources to handle these transactions real time. Figuring that out cost me several hours. You can read through this post to confirm, and though it's older, it is still true:

https://community.developer.authorize.net/t5/Integration-and-Testing/E00040-when-Creating-Subscription-from-Customer-Profile/m-p/59597#M34176