cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with the defaultPaymentProfile flag

Hi Folks,

 

I am creating a customer profile with two payment profiles. I am explicitly assigning one of the payment profiles to be the default payment profile.

 

However, when I then follow that up with a call to getProfile, both of the payment profiles are returned and neither of them is marked as the default.

 

One of my requirements is to allow the customer to select and/or change their default payment profile, so this is causing me an issue as I'd hoped to rely on this flag to implement this requirement.

 

Has anyone else had trouble working with default payment profiles, or can help me understand what it is that I'm doing wrong?

 

If needed, I can provide code samples.

 

Thanks,

--Jason

JasonSki7475
Member
16 REPLIES 16

I did add the customer type, but it didn't resolve the situation. The profile does have a billto to hold the name on the card, but all I have for an address is empty fields. I could populate something hard coded since we're not using customer addresses, but I'm not terribly happy with that as a solution.

If you have the customerType as individual or business and the BillTo address lines filled, you should get a successful response. 

Powered by NexWebSites.com -
Certified Authorize.net developers

Actually, setting the default payment profile is not possible using the createCustomerProfileRequest method. As you've noticed, the request will accept the defaultPaymentProfile element without error, but will not act on it.

 

However, our API reference does not document defaultPaymentProfile as a valid parameter for this request.

 

We've already tracked this internally as a request for improvement, but if you'd like, this would be a good thing to add to our Ideas Forum (where others can take a look, contribute feedback, and vote for new features).

He is calling createCustomerPaymentProfileRequest, not createCustomerProfile. createCustomerPaymentProfileRequest most definitely DOES have a parameter in the docs for defaultPaymentProfile. I am also trying to use it and it does not work. I populated the fields recommended in previous replies - customerType and the entire set of BillTo fields. After creating a new card (which does work), it will not be shown as the default.

 

The defaultPaymentProfile flag simply does not work. You may be trying it with one of the other SDKs. But myself (and I believe the OP) are using the .NET sdk. There definitely seems to be a bug with that flag. It does not work.

 @Aaron is right. You should be calling createCustomerPaymentProfileRequest with an existing customerProfileId, instead of createCustomerProfileRequest in order to set the defaultPayment Profile.

Powered by NexWebSites.com -
Certified Authorize.net developers

You're not really reading through the OP's entire code. The first chunk of code creates the customer profile. Yes.. acknowledged.... After that.. you will see that he then uses the new customer profile ID to create a customerPaymentProfile. THAT is where the problem lies... not in the creation of the customerProfile.

I am also seeing the exact same problem. I have an existing customer profile. All I am trying to do is create a new customer payment profile. This does work, but no matter what.. the defaultPaymentProfle flag does not work. If you set it to true, it will not take. If you query the profile again, it is set to false.

Are there any developers out there who are able to see this issue, or able to understand the problem? I would challenge anyone to try this with the .Net sdk. You will see that it does not work.

Here is the code the OP posted. See how there are two parts? The first is creating the customer profile, the second is creating a customerPaymentProfile.

public ProfileIDs createProfile(Guid transactionGuid, FC_Payment.Data.Customer customer, PlanCode planCode)
{
createCustomerProfileRequest request = new createCustomerProfileRequest();
request.refId = customer.ID;
request.profile = new customerProfileType();
request.profile.merchantCustomerId = customer.ID.ToString();
request.profile.email = customer.EmailAddress;
request.profile.description = customer.Description;
request.profile.paymentProfiles = ANetPaymentProcessor.MapCustomerToANetPaymentProfiles(customer).ToArray();
request.profile.shipToList = new customerAddressType[] {
ANetPaymentProcessor.MapCustomerAddressToANetCustomerAddress(customer.MailingAddress, customer.LastName,
customer.FirstName, customer.CompanyName) };
request.validationMode = ANetPaymentProcessor.CIMValidationMode;
request.validationModeSpecified = true;
ANetMakeRequest requestMaker = new ANetMakeRequest(planCode);
 
createCustomerProfileResponse response = (createCustomerProfileResponse)requestMaker.MakeRequest(request);
ProfileIDs profileIDs = new ProfileIDs();
profileIDs.CustomerProfileID = response.customerProfileId;
profileIDs.PaymentProfileIDs = new List<string>(response.customerPaymentProfileIdList);
return profileIDs;
}
 
Here's the code for the MapCustomerToANetPaymentProfiles method. We only allow credit cards by the way. This just takes the data from the Customer parameter above and maps it to the auth.net object.
 
public static List<customerPaymentProfileExType> MapCustomerToANetPaymentProfiles(FC_Payment.Data.Customer customer)
{
List<customerPaymentProfileExType> pymtProfiles = new List<customerPaymentProfileExType>();
 
if (customer.CreditCards != null && customer.CreditCards.Count > 0)
{
foreach (CustomerCreditCard creditCard in customer.CreditCards)
{
customerPaymentProfileExType pymtProfile = new customerPaymentProfileExType();
pymtProfile.customerPaymentProfileId = string.IsNullOrEmpty(creditCard.PaymentProfileID) ? null : creditCard.PaymentProfileID;
pymtProfile.defaultPaymentProfile = creditCard.IsPrimary;
pymtProfile.defaultPaymentProfileSpecified = creditCard.IsPrimary;
pymtProfile.billTo = new customerAddressType();
pymtProfile.billTo.address = customer.BillingAddress.Street1;
pymtProfile.billTo.city = customer.BillingAddress.City;
pymtProfile.billTo.state = customer.BillingAddress.StateProvinceCode;
pymtProfile.billTo.zip = customer.BillingAddress.PostalCode;
pymtProfile.billTo.country = customer.BillingAddress.Country;
pymtProfile.billTo.phoneNumber = customer.BillingAddress.Phone;
pymtProfile.billTo.faxNumber = customer.BillingAddress.Fax;
pymtProfile.billTo.firstName = creditCard.FirstNameOnCard;
pymtProfile.billTo.lastName = creditCard.LastNameOnCard;
pymtProfile.billTo.company = customer.CompanyName;
pymtProfile.customerType = customer.Type == CustomerType.Individual ? customerTypeEnum.individual : customerTypeEnum.business;
pymtProfile.payment = new paymentType();
creditCardType cc = new creditCardType();
cc.cardNumber = creditCard.CardNumber;
cc.cardCode = creditCard.CVVCode;
//Expiration month and year could be present as either the actual numbers or masked as XX.
int expMonth, expYear;
if (Int32.TryParse(creditCard.ExpirationMonth, out expMonth) &&
Int32.TryParse(creditCard.ExpirationYear, out expYear))
{
cc.expirationDate = string.Format("{0}-{1:D2}", expYear, expMonth);
}
else
{
cc.expirationDate = string.Format("{0}{1}", creditCard.ExpirationYear, creditCard.ExpirationMonth);
}
pymtProfile.payment.Item = cc;
pymtProfiles.Add(pymtProfile);
}
}
 
return pymtProfiles;
}

Regradless of whether the OP was uisng the wrong method... I am still seeing this same issue. Please look at this quick walk-through of what happens. Maybe this will illustrate better the problem...

 

https://gtma.s3.amazonaws.com/videos/2017-06-15-2009-06_720p.mp4