durango / authorize-net-cim

Authorize.net CIM bindings for Node.JS
14 stars 5 forks source link

createCustomerPaymentProfile doesn't work properly #5

Open sean-hill opened 9 years ago

sean-hill commented 9 years ago

The createCustomerPaymentProfile example in the README returns this error.

{ [AuthNetError: Authorize.net error: The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.]
  message: 'Authorize.net error: The element \'payment\' in namespace \'AnetApi/xml/v1/schema/AnetApiSchema.xsd\' has incomplete content. List of possible elements expected: \'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData\' in namespace \'AnetApi/xml/v1/schema/AnetApiSchema.xsd\'.',
  code: 'E00003' }

This is my code

var payment = new Types.Payment({
    creditCard: new Types.CreditCard({
        cardNumber: 41111111111111111,
        expirationDate: '2012-01',
        cardCode: 111
    })
});

var paymentProfile = {
    customerType: 'individual',
    payment: payment
};

AuthorizeCIM.createCustomerPaymentProfile({
    customerProfileId: customerId,
    paymentProfile: paymentProfile
}, function(err, response){
    console.log(err);
});

How do I fix this issue?

lkobashigawa commented 9 years ago

I ran into the same issue, I was able to work around it by not using the Payment type.

var payment = {
    creditCard: new Types.CreditCard({
        cardNumber: 41111111111111111,
        expirationDate: '2012-01',
        cardCode: 111
    })
};
sean-hill commented 9 years ago

Thanks for the help, after modifying the code by removing the Payment type, I get the following error.

message: 'Authorize.net error: The \'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardNumber\' element is invalid - The value \'41111111111111110\' is invalid according to its datatype \'String\' - The actual length is greater than the MaxLength value.'
sean-hill commented 9 years ago

Lol these docs are so bad and the code is so bad. 41111111111111111 has one to many 1's. Authorize.net, @durango, or whoever is over this repo, could you please fix these issues? Thanks!