AuthorizeNet / sdk-dotnet

.Net SDK for Authorize.Net API
Other
149 stars 206 forks source link

CustomerGateway.AddCreditCard() throws required field error in live mode. #116

Closed mikelunn closed 8 years ago

mikelunn commented 8 years ago

I'm using the version 1.8.8 of the sdk and are receiving the following exception when calling the AddCreditCard method of the CustomerGateway class in Live mode. image

However, I do not experience the exception when using my sandbox credentials in test mode. I have verified that I am passing the correct parameters to the AddCreditCard method.

mikelunn commented 8 years ago

I've cloned the repository and have been able to replicate the problem i'm experiencing. I changed the api_login_key and transaction key to my live account, and added the ServiceMode.Live enum to the CustomerGateway constructor param. image

image

I've looked into the problem by stepping through code, but at this time i'm not able to identify why it is working using my test account and why I receive the error with my production account.

henryirvin commented 8 years ago

I am having the exact same issue with this method call. It works in the sandbox, but consistently fails against the live account. I know the credit cards are valid as well because subscriptions get created with them.

System.InvalidOperationException: Error processing request: E00027 - There is one or more missing or invalid required fields. at AuthorizeNet.HttpXmlUtility.CheckForErrors(ANetApiResponse response) at AuthorizeNet.HttpXmlUtility.Send(ANetApiRequest apiRequest) at AuthorizeNet.CustomerGateway.AddCreditCard(String profileID, String cardNumber, Int32 expirationMonth, Int32 expirationYear, String cardCode, Address billToAddress) at AuthorizeNet.CustomerGateway.AddCreditCard(String profileID, String cardNumber, Int32 expirationMonth, Int32 expirationYear, String cardCode)

rhldr commented 8 years ago

One possible solution is the card code field. If you are not including a card code in the request, check that you don't have that field set as required in the Merchant Interface.

henryirvin commented 8 years ago

Thanks for the reply.

The code field is set to required and I do pass a code ( I log the raw http request). I'm also pretty sure it's not that because card code validation is turned on in authorize.net for this client AND subscriptions get created and billed. Payment profiles just don't get created on CIM accounts. I do see some errors saying a first name is required (even though the API does not required this).

AlphaSolutions7 commented 8 years ago

Did any of you guys ended up with a solution to this issue? I'm using the version 1.8.3 and I'm getting the same exact error when in live mode.

Sapbasu15 commented 8 years ago

We are looking into this issue.

mikelunn commented 8 years ago

Until a resolution, for this particular use case i'm using the Web Service rather than the SDK.

brianmc commented 8 years ago

@mlunn01 Could you try this with your production account using the new model for adding a payment profile (credit card)? Here's the sample: https://github.com/AuthorizeNet/sample-code-csharp/blob/master/CustomerProfiles/CreateCustomerPaymentProfile.cs

If you wouldn't mind cloning the sample repo and just running that sample with your production account it would give us some good data for troubleshooting.

Thanks,

Brian

mikelunn commented 8 years ago

@brianmc Is there a way to test this new model using the unit tests instead? That is how I was able to ultimately identify the issue, by accessing the AddCreditCardTest method in the CustomerGatewayTest class.

ashtru commented 8 years ago

@mlunn01 You can download and run the sample code https://github.com/AuthorizeNet/sample-code-csharp It's a simple console application. Setup is same as SDK, just install Authorize-Net package (View>Other Windows>Package Manager Console PM> Install-Package AuthorizeNet)

  1. Edit merchant credentials in https://github.com/AuthorizeNet/sample-code-csharp/blob/master/SampleCode.cs#L127
  2. I have modified the sample to use credit card instead of bank account. https://github.com/ashtru/sample-code-csharp/blob/master/CustomerProfiles/CreateCustomerPaymentProfile.cs#L22
    • Change the RunEnvironment to AuthorizeNet.Environment.PRODUCTION
  3. Add your credit card to run this sample. I have set the validation mode to liveMode in Line 60
ashtru commented 8 years ago

I was finally able to reproduce the same error "There is one or more missing or invalid required fields." It happens if I do not assign billTo in the example shared above in my fork. I am guessing billing address is compulsory for charging credit card in your region.

Note that when including billing address, you must provide all of the fields

@mlunn01 Pllease try running this sample code and reply if the error message changes to something else. Or if the payment profile is successfully added.

4eyecoder commented 8 years ago

In the CustomerGateway constructor the ServiceMode parameter it setting the ValidationMode to Live/Test based on the ServiceMode. The ValidationMode needs to be handled seperately.

brianmc commented 8 years ago

Hi @mlunn01,

the behavior differs because liveMode does what is a called a "card validation" or "zero dollar auth" in that it actually goes to the processor and checks the validity of the card. Many processors require the address fields for this operation so if you're going to validate the card with liveMode you'll want to supply these fields. Some applications only use testMode because that does basic card checks (expiry, type, luhn check) and there is no charge for testMode whereas liveMode gets charged at standard transaction rates.

I'm going to close this issue but feel free to reopen if you think there is a problem with the SDK itself.

Thanks,

Brian