Accept Hosted Recurring billing

时间秒杀一切 提交于 2020-05-16 02:30:50

问题


getHostedPaymentPageRequest only provides two types of transaction to generate a token for the form using the following XML.

Two transaction type:

  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>

How should I modify the XML so that I can get the form for recurring billing? As I did not find any implementation example in accept hosted to get a valid form token for recurring billing. There was not mention of recurring billing the accept hosted documentation.

Also, I am using the redirect method and not the iframe one to display the form which does not return any response as well.


回答1:


There is no one form for creating a subscription through the hosted form. Fortunately someone already posted how to do this on their forum which I will repost here:

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



来源:https://stackoverflow.com/questions/61458948/accept-hosted-recurring-billing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!