Documentation labels the opts as optional but if you try to submit without them you get an error.
iex> amount = Money.new(20, :USD)
iex> card = %CreditCard{number: "5424000000000015", year: 2099, month: 12, verification_code: "999"}
iex> result = Gringotts.purchase(Gringotts.Gateways.AuthorizeNet, amount, card, [])
{:error,
%{
__struct__: Gringotts.Response,
authorization: nil,
avs_result: nil,
cvc_result: nil,
error_code: nil,
fraud_review: nil,
message: nil,
params: nil,
raw: %{
"ErrorResponse" => %{
"messages" => %{
"message" => %{
"code" => "E00003",
"text" => "The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:itemId' element is invalid - The value '' is invalid according to its datatype 'String' - The actual length is less than the MinLength value."
},
"resultCode" => "Error"
}
}
},
status_code: nil,
success: false
}}
When I look at the payload in Gateways.AuthorizeNet.commit/3 it looks like the opts are included as blanks anyway. I believe this is throwing a bug on Authorize.Net's end where when they see the "lineItems" node they expect a "lineItem" with a "itemId" with length greater than 0.
on Authorize.Net's API reference and I got a successful response, so it doesn't seem necessary to include all the blank options in the request if there happen to be no options included. May I suggest only submitting opts that the user submits in the call to Gringotts.purchase as a solution to this problem?
Documentation labels the
opts
as optional but if you try to submit without them you get an error.When I look at the payload in
Gateways.AuthorizeNet.commit/3
it looks like the opts are included as blanks anyway. I believe this is throwing a bug on Authorize.Net's end where when they see the "lineItems" node they expect a "lineItem" with a "itemId" with length greater than 0.I tested this structure:
on Authorize.Net's API reference and I got a successful response, so it doesn't seem necessary to include all the blank options in the request if there happen to be no options included. May I suggest only submitting opts that the user submits in the call to
Gringotts.purchase
as a solution to this problem?