AuthorizeNet / sample-code-php

This repository contains working code samples which demonstrate php integration with the Authorize.Net API
MIT License
176 stars 197 forks source link

Creating a subscrption from a payment profile doesn't work #52

Closed VerilySoft closed 7 years ago

VerilySoft commented 7 years ago

Hello,

I don't know if you've already tested ARBCreateSubscriptionRequest with customer profile ID. Apparently it seems not working even here http://developer.authorize.net/api/reference/index.html#recurring-billing-create-a-subscription-from-customer-profile

When you send this request with customer profile ID:

<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>api login id</name>
        <transactionKey>transaction key</transactionKey>
    </merchantAuthentication>
    <refId>Sample</refId>
    <subscription>
        <name>Sample subscription</name>
        <paymentSchedule>
            <interval>
                <length>1</length>
                <unit>months</unit>
            </interval>
            <startDate>2020-08-30</startDate>
            <totalOccurrences>12</totalOccurrences>
            <trialOccurrences>1</trialOccurrences>
        </paymentSchedule>
        <amount>10.29</amount>
        <trialAmount>0.00</trialAmount>
        <profile>
          <customerProfileId>1807263780</customerProfileId>
          <customerPaymentProfileId>1802291213</customerPaymentProfileId>
        </profile>
    </subscription>
</ARBCreateSubscriptionRequest>

it asks for Billing first and last names:

<?xml version="1.0" encoding="utf-8"?> 
<ARBCreateSubscriptionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <refId>
    Sample
  </refId>
  <messages>
    <resultCode>
      Error
    </resultCode>
    <message>
      <code>
        E00014
      </code>
      <text>
        Bill-To First Name is required.
      </text>
    </message>
    <message>
      <code>
        E00014
      </code>
      <text>
        Bill-To Last Name is required.
      </text>
    </message>
  </messages>
</ARBCreateSubscriptionResponse>

and when you set the billing first and last names:

<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>api login id</name>
        <transactionKey>transaction key</transactionKey>
    </merchantAuthentication>
    <refId>Sample</refId>
    <subscription>
        <name>Sample subscription</name>
        <paymentSchedule>
            <interval>
                <length>1</length>
                <unit>months</unit>
            </interval>
            <startDate>2020-08-30</startDate>
            <totalOccurrences>12</totalOccurrences>
            <trialOccurrences>1</trialOccurrences>
        </paymentSchedule>
        <amount>10.29</amount>
        <trialAmount>0.00</trialAmount>
        <billTo>
            <firstName>John</firstName>
            <lastName>Smith</lastName>
        </billTo>
        <profile>
          <customerProfileId>39931060</customerProfileId>
          <customerPaymentProfileId>36223863</customerPaymentProfileId>
          <customerAddressId>37726371</customerAddressId>
        </profile>
    </subscription>
</ARBCreateSubscriptionRequest>

it says you cannot use both:

<?xml version="1.0" encoding="utf-8"?> 
<ARBCreateSubscriptionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <refId>
    Sample
  </refId>
  <messages>
    <resultCode>
      Error
    </resultCode>
    <message>
      <code>
        E00093
      </code>
      <text>
        PaymentProfile cannot be sent with billing data.
      </text>
    </message>
  </messages>
</ARBCreateSubscriptionResponse>

But removing the profile node and you're asked for the payment information.

Any idea how to make this work ?

Thanks

brianmc commented 7 years ago

Does your payment profile have first and last name set?

VerilySoft commented 7 years ago

Hei Brian,

I think this was the issue!

Thank you so much!

Stephane

hoangtrongphuc commented 7 years ago

I'm facing with same problem. How can I resolve this?

nhustak commented 5 years ago

You need to make sure the name (and if you want address) information is filled in on the payment profile if you are using it. You cannot specify both a payment profile and a bill to address.