authorizenet / sdk-ruby Goto Github PK
View Code? Open in Web Editor NEWRuby SDK for the Authorize.Net API
License: Other
Ruby SDK for the Authorize.Net API
License: Other
The street_address method is returning nil.
What's weird is that when I use the deprecated call Cim.new.get_customer_profile(user.acid)
from the AuthNetApi the response has the address in it.
resp = cim.get_profile(user.acid)
resp.profile.payment_profiles.billing_address.street_address #=> nil
Have any idea why this is happening?
No matter what I try. I cannot get ARB::Subscirption.new to work. I keep getting errors that makes me thing this SDK is not in alignment with the actual API.
This page http://developer.authorize.net/integration/fifteenminutes/ruby/ suggests
sudo gem install authorize-net-1.5.2.gem
So it will be helpful to state that this repo is an official A.Net Ruby gem and to change the docs at http://developer.authorize.net/
Right now it is kinda frustrating :)
On Authorize, I can see the text invoice field, which I want to use to pass the type of donation that is being submitted.
After spending awhile reading through the source code, I don't see the invoice field on either the Transaction Request or the Subscription Request objects. Is there a way to submit that field to Authorize using this gem?
For example, I want to download a list of all the subscriptions from my Authorize account.
@billing_api = AuthorizeNet::ARB::Transaction.new(API_LOGIN, API_KEY, gateway: :production)
page_1 = @billing_api.get_subscription_list("subscriptionActive", nil, AuthorizeNet::ARB::Paging.new(1,1000).subscription_details
@billing_api = AuthorizeNet::ARB::Transaction.new(API_LOGIN, API_KEY, gateway: :production)
page_2 = @billing_api.get_subscription_list("subscriptionActive", nil, AuthorizeNet::ARB::Paging.new(2,1000).subscription_details
page_1.count
#=> 1000
page_2.count
#=> 104
So far, everything appears correct as I have 1104 active subscriptions when I look in my Authorize interface. But...
page_1.map!{|x| x.id}
page_2.map!{|x| x.id}
page_2.select{|x| page_1.include?(x)}.count
#=> 104
What I get for page 2 of my results is actually the same results as page 1 but limited to 104.
As far as I can tell, this isn't desirable behavior since I don't see how I can get any subscriptions beyond my first 1000.
returned_item = AuthorizeNet::Reporting::ReturnedItem.new({:return_item_id => id, :return_item_date_utc => date_utc, :return_item_date_utc => date_local, :return_item_code => code, :line_item_description => description})
:return_item_date_utc
is duplicated in this hash. Is it supposed to be :return_item_date_local
?
Gem is incompatible with Ruby 2.4:
lib/authorize_net/api/schema.rb:2525: warning: constant ::Fixnum is deprecated
lib/authorize_net/api/schema.rb:2542: warning: constant ::Fixnum is deprecated
lib/authorize_net/api/schema.rb:2544: warning: constant ::Fixnum is deprecated
Our customer enter their Auth.net credentials into our system. How can I ping Auth.net to make sure those credentials are valid?
I can do this
transaction = AuthorizeNet::AIM::Transaction.new('API_LOGIN', 'API_KEY', :gateway => :...)
but how do I check the response w/o actually running credit card charge?
transaction = Transaction.new(LOGIN_ID, TRANS_KEY, :gateway => :sandbox)
request = CreateTransactionRequest.new
request.transactionRequest = TransactionRequestType.new()
request.transactionRequest.amount = 42.03
request.transactionRequest.payment = PaymentType.new
request.transactionRequest.payment.creditCard = CreditCardType.new('4007000000027', '0220', '123')
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
myCustomElement = Hash.new
myCustomData = Array.new
myCustomElement[:userField] = UserField.new('cereal','specialk')
myCustomData.push(myCustomElement)
myCustomElement[:userField] = UserField.new('coffee','sumatra')
myCustomData.push(myCustomElement)
request.transactionRequest.userFields = UserFields.new(myCustomData)
response = transaction.create_transaction(request)
Referring to the ROXML doc and the gem source for the sdk-ruby, this should work. Sadly here is no example in sample-code-ruby (hint-hint). However, the source is pretty clear that userFields is an array of userField objects, each of which is a name/value pair.
request.transactionRequest.userFields in the console:
#<AuthorizeNet::API::UserFields:0x007fdfbf43a520 @userFields=[{:userField=>#<AuthorizeNet::API::UserField:0x007fdfbf3c8c18 @name="coffee", @value="sumatra">}, {:userField=>#<AuthorizeNet::API::UserField:0x007fdfbf3c8c18 @name="coffee", @value="sumatra">}]>
request.transactionRequest in the console:
#<AuthorizeNet::API::TransactionRequestType:0x007fdfb8af74a0 @transactionType="authCaptureTransaction", @amount=249, @currencyCode=nil, @payment=#<AuthorizeNet::API::PaymentType:0x007fdfbf1827b0 @creditCard=#<AuthorizeNet::API::CreditCardType:0x007fdfbf14a9f0 @cardNumber="4007000000027", @expirationDate="0220", @cardCode="123", @isPaymentToken=nil, @cryptogram=nil>, @bankAccount=nil, @trackData=nil, @encryptedTrackData=nil, @payPal=nil, @opaqueData=nil>, @profile=nil, @solution=nil, @callId=nil, @authCode=nil, @refTransId=nil, @splitTenderId=nil, @order=nil, @lineItems=nil, @tax=nil, @duty=nil, @shipping=nil, @taxExempt=nil, @poNumber=nil, @customer=nil, @billTo=nil, @shipTo=nil, @customerIP=nil, @cardholderAuthentication=nil, @retail=nil, @transactionSettings=nil, @userFields=#<AuthorizeNet::API::UserFields:0x007fdfbf43a520 @userFields=[{:userField=>#<AuthorizeNet::API::UserField:0x007fdfbf3c8c18 @name="coffee", @value="sumatra">}, {:userField=>#<AuthorizeNet::API::UserField:0x007fdfbf3c8c18 @name="coffee", @value="sumatra">}]>>
@value="specialk">]
But I get the error:
#<AuthorizeNet::API::CreateTransactionResponse:0x007fdfb8b0cbe8 @refId=nil, @messages=#<AuthorizeNet::API::MessagesType:0x007fdfb8b5e998 @resultCode="Error", @messages=[#<AuthorizeNet::API::MessagesType::Message:0x007fdfb8b3d9a0 @code="E00003", @text="Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 17, position 19.", @roxml_references=[#<ROXML::XMLTextRef:0x007fdfb8b3d748 @opts=#<ROXML::Definition:0x007fdfba903840 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="code", @array=false, @blocks=[], @sought_type=:text, @attr_name="code", @name="code">, @instance=#<AuthorizeNet::API::MessagesType::Message:0x007fdfb8b3d9a0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x007fdfb8b3d720 @opts=#<ROXML::Definition:0x007fdfba902a58 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="text", @array=false, @blocks=[], @sought_type=:text, @attr_name="text", @name="text">, @instance=#<AuthorizeNet::API::MessagesType::Message:0x007fdfb8b3d9a0 ...>, @default_namespace="xmlns">]>], @roxml_references=[#<ROXML::XMLTextRef:0x007fdfb8b5e470 @opts=#<ROXML::Definition:0x007fdfba901c98 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="resultCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="resultCode", @name="resultCode">, @instance=#<AuthorizeNet::API::MessagesType:0x007fdfb8b5e998 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fdfb8b5e448 @opts=#<ROXML::Definition:0x007fdfba901068 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="messages", @array=true, @blocks=[], @sought_type=AuthorizeNet::API::MessagesType::Message, @attr_name="messages", @name="message">, @instance=#<AuthorizeNet::API::MessagesType:0x007fdfb8b5e998 ...>, @default_namespace="xmlns">]>, @sessionToken=nil, @transactionResponse=nil, @profileResponse=nil, @roxml_references=[#<ROXML::XMLTextRef:0x007fdfb8b0ca58 @opts=#<ROXML::Definition:0x007fdfb926e170 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="refId", @array=false, @blocks=[], @sought_type=:text, @attr_name="refId", @name="refId">, @instance=#<AuthorizeNet::API::CreateTransactionResponse:0x007fdfb8b0cbe8 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fdfb8b0c8f0 @opts=#<ROXML::Definition:0x007fdfb926d838 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="messages", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::MessagesType, @attr_name="messages", @name="messages">, @instance=#<AuthorizeNet::API::CreateTransactionResponse:0x007fdfb8b0cbe8 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x007fdfb8b0c7d8 @opts=#<ROXML::Definition:0x007fdfb926d108 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="sessionToken", @array=false, @blocks=[], @sought_type=:text, @attr_name="sessionToken", @name="sessionToken">, @instance=#<AuthorizeNet::API::CreateTransactionResponse:0x007fdfb8b0cbe8 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fdfb8b0c7b0 @opts=#<ROXML::Definition:0x007fdfb926c938 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="transactionResponse", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse, @attr_name="transactionResponse", @name="transactionResponse">, @instance=#<AuthorizeNet::API::CreateTransactionResponse:0x007fdfb8b0cbe8 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fdfb8b0c788 @opts=#<ROXML::Definition:0x007fdfb926c168 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="profileResponse", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::CreateProfileResponse, @attr_name="profileResponse", @name="profileResponse">, @instance=#<AuthorizeNet::API::CreateTransactionResponse:0x007fdfb8b0cbe8 ...>, @default_namespace="xmlns">]>
-end-
Hi,
I am using the authorizenet gem and I'm getting a 'nomethoderror transactionResponse' on the response object that is returned when the api for createtransaction times out. According to the api documentation, for a timed out or retry, the transactionResponse xml should have avsresultcode as 'R'. But looks the authoriznet gem is not getting(?)/returning this info in the responsexml?
Here's the code:
response = transaction.create_transaction(request)
transaction_response = response.transactionResponse
and here's the error:
NoMethodError (undefined method `transactionResponse' for #Errno::ETIMEDOUT:0x007f54a2c36ec0):
How do I handle a response where the api has timed out? Right now it throws the above exception.
It looks like the API has been updated and there is a operation that the gem does not support.
if response.messages.resultCode == MessageTypeEnum::Ok
# Payment is considered to be successful.
# Providing goods or services to the customer ...
end
This is taken from Hello World example and README of the current gem.
Successful charge:
<?xml version="1.0" encoding="utf-8"?>
<createTransactionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<transactionResponse>
<responseCode>1</responseCode>
<authCode>UZJ0KN</authCode>
<avsResultCode>Y</avsResultCode>
<cvvResultCode>P</cvvResultCode>
<cavvResultCode>2</cavvResultCode>
<transId>2249638815</transId>
<refTransID />
<transHash>8614D9C8EA2ED3869D3CBE33D118B68C</transHash>
<testRequest>0</testRequest>
<accountNumber>XXXX4242</accountNumber>
<accountType>Visa</accountType>
<messages>
<message>
<code>1</code>
<description>This transaction has been approved.</description>
</message>
</messages>
</transactionResponse>
</createTransactionResponse>
Failure:
<?xml version="1.0" encoding="utf-8"?>
<createTransactionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<messages>
<resultCode>Error</resultCode>
<message>
<code>E00027</code>
<text>The transaction was unsuccessful.</text>
</message>
</messages>
<transactionResponse>
<responseCode>3</responseCode>
<authCode />
<avsResultCode>P</avsResultCode>
<cvvResultCode />
<cavvResultCode />
<transId>0</transId>
<refTransID />
<transHash>137CBC40236BA3F51C96439EC93BEF10</transHash>
<testRequest>0</testRequest>
<accountNumber>XXXX4242</accountNumber>
<accountType>Visa</accountType>
<errors>
<error>
<errorCode>8</errorCode>
<errorText>The credit card has expired.</errorText>
</error>
</errors>
</transactionResponse>
</createTransactionResponse>
The transaction is declined:
<?xml version="1.0" encoding="utf-8"?>
<createTransactionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<transactionResponse>
<responseCode>2</responseCode>
<authCode />
<avsResultCode>N</avsResultCode>
<cvvResultCode>M</cvvResultCode>
<cavvResultCode />
<transId>8449440786</transId>
<refTransID />
<transHash>3BD3DB541ECEEE82758CABE23CF25B0B</transHash>
<testRequest>0</testRequest>
<accountNumber>XXXX3173</accountNumber>
<entryMode>Keyed</entryMode>
<accountType>MasterCard</accountType>
<errors>
<error>
<errorCode>2</errorCode>
<errorText>This transaction has been declined.</errorText>
</error>
</errors>
</transactionResponse>
</createTransactionResponse>
So according to documentation both
successful transaction and declined transaction are considered as paid (response.messages.resultCode == "Ok"
).
More accurate would be to check transactionResponse
message code:
if response.messages.resultCode == MessageTypeEnum::Ok &&
response.transactionResponse.messages &&
response.transactionResponse.messages.messages[0].code == "1"
# Payment is considered to be successful.
# Providing goods or services to the customer ...
end
I think this is serious vulnerability issue.
Thanks
I can now get Subscription IDs through Transaction Details API http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/ARB-Subscription-IDs-Available-Through-Transaction-Details-API/ba-p/40602
But is there a way to query the Transaction Details API by Subscription ID? We have lots of one time transactions and some recurring subscriptions. It's much easier to query by Subscription and also less load on Auth.net servers.
I have successfully created a customer profile via the CIM API using the gem, and I can call validate_payment_profile
to check that I can charge the card associated with the profile:
transaction.validate_payment_profile(u.cim_payment_profile_token, u.cim_profile_token).success?
=> true
Te problem I'm seeing is that attempting to create a transaction via create_transaction_auth_capture
fails every time with
The element 'createCustomerProfileTransactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'refId, transaction' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
Code used to send that attempt was:
transaction.create_transaction_auth_capture(100.99, u.cim_profile_token, u.cim_payment_profile_token)
The XML being sent to the API is:
<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>69...Ba</name>
<transactionKey>58W...du8sL</transactionKey>
</merchantAuthentication>
</createCustomerProfileTransactionRequest>
Which does seem to be missing more or less all of the detail required to make a charge. Is there something obvious I'm not doing / doing wrong?
The only lead I have at the moment is that the CIM_CREATE_TRANSACTION
fields are using the fields definition of CREATE_TRANSACTION_FIELDS
, which in turn only includes the following:
CREATE_TRANSACTION_FIELDS = [
REFID_FIELDS,
{:transaction => [], :_conditional => :select_transaction_type_fields},
{:extraOptions => :extra_options}
]
The TRANSACTION_FIELDS
should be included with the call to select_transaction_type_fields
, but it seems like they are not.
We identified a bug with ARB API rejecting credit cards that expire in January, February, March or April of years well into future.
This only happens if you pass expiration date as '04/20'. ARB works if you pass '0420'. But if you pass '05/20' than ARB also works. Donations also work if you pass '04/20'. Would be nice to fix to make system consistent.
Repro steps:
Create subscription when credit card expiring in January, February, March or April of 2020
ARB responds with: response_code = Error, response_reason_code = E00013, response_reason_text = The credit card has expired.
It works for May - December expiration dates. We tested this with various credit cards in sandbox and production, for years till 2025.
According to http://developer.authorize.net/tools/arberrorcodes/ E00013 means "The field is invalid"
I'm doing a list request to get all my subscriptions, but I get an empty response.
When checking for number of results I get 1 subscription:
response.totalNumInResultSet
"1"
But if I try to get the subscription details, I get an empty response:
response.subscriptionDetails
[]
This is the whole response I get from the API:
#<AuthorizeNet::API::ARBGetSubscriptionListResponse:0x007fd9544878a0 @refId=nil, @messages=#<AuthorizeNet::API::MessagesType:0x007fd9565c3488 @resultCode="Ok", @messages=[#<AuthorizeNet::API::MessagesType::Message:0x007fd95cba6318 @code="I00001", @text="Successful.", @roxml_references=[#<ROXML::XMLTextRef:0x007fd95cba6228 @opts=#<ROXML::Definition:0x007fd95630b790 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="code", @array=false, @blocks=[], @sought_type=:text, @attr_name="code", @name="code">, @instance=#<AuthorizeNet::API::MessagesType::Message:0x007fd95cba6318 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x007fd9565bff90 @opts=#<ROXML::Definition:0x007fd95630b088 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="text", @array=false, @blocks=[], @sought_type=:text, @attr_name="text", @name="text">, @instance=#<AuthorizeNet::API::MessagesType::Message:0x007fd95cba6318 ...>, @default_namespace="xmlns">]>], @roxml_references=[#<ROXML::XMLTextRef:0x007fd9565c3320 @opts=#<ROXML::Definition:0x007fd95630a9a8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="resultCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="resultCode", @name="resultCode">, @instance=#<AuthorizeNet::API::MessagesType:0x007fd9565c3488 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fd9565c32d0 @opts=#<ROXML::Definition:0x007fd95630a278 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="messages", @array=true, @blocks=[], @sought_type=AuthorizeNet::API::MessagesType::Message, @attr_name="messages", @name="message">, @instance=#<AuthorizeNet::API::MessagesType:0x007fd9565c3488 ...>, @default_namespace="xmlns">]>, @sessionToken=nil, @totalNumInResultSet="1", @subscriptionDetails=[], @roxml_references=[#<ROXML::XMLTextRef:0x007fd9544877b0 @opts=#<ROXML::Definition:0x007fd9563c0af0 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="refId", @array=false, @blocks=[], @sought_type=:text, @attr_name="refId", @name="refId">, @instance=#<AuthorizeNet::API::ARBGetSubscriptionListResponse:0x007fd9544878a0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fd954487788 @opts=#<ROXML::Definition:0x007fd9563c03e8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="messages", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::MessagesType, @attr_name="messages", @name="messages">, @instance=#<AuthorizeNet::API::ARBGetSubscriptionListResponse:0x007fd9544878a0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x007fd954487760 @opts=#<ROXML::Definition:0x007fd9561775c8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="sessionToken", @array=false, @blocks=[], @sought_type=:text, @attr_name="sessionToken", @name="sessionToken">, @instance=#<AuthorizeNet::API::ARBGetSubscriptionListResponse:0x007fd9544878a0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x007fd9544876e8 @opts=#<ROXML::Definition:0x007fd956174d78 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="totalNumInResultSet", @array=false, @blocks=[], @sought_type=:text, @attr_name="totalNumInResultSet", @name="totalNumInResultSet">, @instance=#<AuthorizeNet::API::ARBGetSubscriptionListResponse:0x007fd9544878a0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x007fd9544876c0 @opts=#<ROXML::Definition:0x007fd9563cbe28 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="subscriptionDetails", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::ArrayOfSubscription, @attr_name="subscriptionDetails", @name="subscriptionDetails">, @instance=#<AuthorizeNet::API::ARBGetSubscriptionListResponse:0x007fd9544878a0 ...>, @default_namespace="xmlns">]>
This is happening for all types of requests: SubscriptionActive
, SubscriptionInactive
, CardExpiringThisMonth
, SubscriptionExpiringThisMonth
I'm using a sandbox account. Not sure if that might be the issue.
Any ideas? Should I provide any additional information?
Reporting API is not returning SubscriptionID field for transaction per http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/ARB-Subscription-IDs-Available-Through-Transaction-Details-API/ba-p/40602.
I have a sandbox subscription ID 2343517. On March 18th, it charged $10 https://sandbox.authorize.net/UI/themes/sandbox/ARB/TransactionList.aspx?SubscrID=2343517
Here is what API returns:
โ{"id":"2230382467","submitted_at":"2015-03-18T09:45:10.000+00:00","status":"settledSuccessfully","account_type":"Visa","account_number":"XXXX4242","settle_amount":"10.0","customer":{"first_name":"Tanya","last_name":"Rowe"}}
โ
Here is my code snippet:
t1 = AuthorizeNet::Reporting::Transaction.new ...
response1 = t1.get_settled_batch_list(dates here)
if response1.success?
response1.batch_list.each do |batch|
t2 = AuthorizeNet::Reporting::Transaction.new ...
response2 = t2.get_transaction_list(batch.id)
if response2.success?
transactions = response2.transactions
transactions.each do |t|
When I submit a request to create_transaction_auth_capture
with an AuthorizeNet::Order
object that has a value for #invoice_num
, the value is not showing up in the transaction for my Authorize.net sandbox account.
When I dig a little deeper it seems that the :invoice_num
is being filtered from the XML generated for submission to AIM.
It appears that the AuthorizeNet::Order::Fields
may be looking for an field called :invoice_number
when submitting an Order through CIM but AuthorizeNet::Order
generates :invoice_num
field.
It's also interesting to note that a similar setting is defined for ARB::Fields::SUBSCRIPTION_FIELDS
but it looks for :invoice_num
.
The main API supports giving refunds to a credit card with an amount, I was wondering if you could implement that feature.
I have a user with three payment profiles. I want to retrieve all of the payment profiles. I would think that AuthorizeNet::CIM::Response#payment_profile_ids would return all of the IDs, but it is always nil. Here's some example code.
t = AuthorizeNet::CIM::Transaction.new(Rails.application.secrets.authorizenet["api_login_id"], Rails.application.secrets.authorizenet["transaction_key"], gateway: :sandbox)
=> AuthorizeNet::CIM::Transaction
p = t.get_profile(xxxxxxxx)
=> AuthorizeNet::CIM::Response
p.payment_profile_ids
=> nil
Calling #payment_profile_id will return only the ID of the first payment profile.
p.payment_profile_id
=> "xxxxxxxx"
How do I get all of the payment profiles for a specified profile?
Unfortunately Subscription status is almost useless as it doesn't give any details about the subscription, so we are using Get Subscription List. But we are not able to get the bill-date from that response. Is it possible to add this feature to the API?
When attempting to issue a partial refund to a transaction that has not been settled, the entire transaction is voided. Is there a specific way to handle partial refunds prior to settlement? If not, is there a method to check whether or not a transaction has settled?
Created like this:
myCustomList = Array.new
myCustomElement = UserField.new('cereal','specialk')
myCustomList.push(myCustomElement)
myCustomElement = UserField.new('coffee','sumatra')
myCustomList.push(myCustomElement)
request.transactionRequest.userFields = UserFields.new(myCustomList)
Then what is the syntax to read the value of "cereal' ('specialk") out of the response object?
response.transactionResponse.userFields ?
I've tried:
response.transactionResponse.userFields[0]
response.transactionResponse.userFields(:cereal)
response.transactionResponse.userFields('cereal')
response.transactionResponse.userFields[:name][:cereal]
response.transactionResponse.userFields::name
And a lot of similar ruby-style code.
I'm missing some basic principle of ROXML.
Hello,
This problem used to exist on the old gem and still has not been solved on the official fork. I forked the older authorize gem a while back and hacked it to make it work. I think that most use cases are going to want to store as much information about a customer as possible in the payment gateway?
I was trying to add this feature to your gem or at least figure out how to pass it along using the AIM method. Do you have a recommend way of doing this? It isn't documented and I am certain that many use cases will want to store things like customer name, shipping and billing address and contact information with the transactions.
Thank you.
This issue is not resolved: #63
Running:
$ rails generate authorize_net:direct_post payments [my_login] [my_trans_key] [my_md5_hash]
Crashes with the following error:
Could not find "README-AuthorizeNet" in any of your source paths. Your current source paths are:
/Users/jemminger/.rvm/gems/ruby-2.0.0-p481@syg/gems/authorizenet-1.8.0/generators/authorize_net_direct_post/templates
Version: 1.8.8
After updating our project to version 1.8.8 of the gem, we receive the following error:
==> default: LoadError: cannot load such file -- coveralls
==> default: /home/vagrant/useed/config/application.rb:14:in `<top (required)>'
==> default: /home/vagrant/useed/Rakefile:5:in `require'
==> default: /home/vagrant/useed/Rakefile:5:in `<top (required)>'
==> default: (See full trace by running task with --trace)
Seems related to a7630fb which looks like it should only be called in the spec_helper.rb
file.
I am following instructions on http://developer.authorize.net/api/transaction_details/ using the https://github.com/AuthorizeNet/sdk-ruby. When I use http://developer.authorize.net/api/reference/#transaction-reporting-get-transaction-list I get data back.
Here is my code snippet:
transaction = AuthorizeNet::Reporting::Transaction.new(auth_net_login, auth_net_key, gateway: :production)
response1 = transaction.get_settled_batch_list(DateTime.now() - 7.days, DateTime.now(), true)
batches = response1.batch_list if response1.success?
batches.each do |batch|
response2 = transaction.get_transaction_list(batch.id)
transactions = response2.transactions if response2.success?
end
I get the batch IDs (310442465", 310517224, 310608341, 310738305, 310870612) but response2 (get_transaction_list) ALWAYS comes back as nil.
I can see transaction and batch ID via the GUI.
I appreciate any advice you can provide. Thank you.
Response is this
@custom_fields={},
@fields=
{:response_code=>"1",
:response_subcode=>"1",
:response_reason_code=>"1",
:response_reason_text=>"This transaction has been approved.",
:authorization_code=>"9VHMMC",
:avs_response=>"Y",
:transaction_id=>"2241516704",
:invoice_number=>"",
:description=>"",
:amount=>#BigDecimal:b0079d0,'0.1E2',9(18),
:method=>"CC",
:transaction_type=>"auth_capture",
:customer_id=>"",
:first_name=>"",
:last_name=>"",
:company=>"",
:address=>"",
:city=>"",
:state=>"",
:zip_code=>"",
:country=>"",
:phone=>"",
:fax=>"",
:email_address=>"",
:ship_to_first_name=>"",
:ship_to_last_name=>"",
:ship_to_company=>"",
:ship_to_address=>"",
:ship_to_city=>"",
:ship_to_state=>"",
:ship_to_zip_code=>"",
:ship_to_country=>"",
:tax=>#BigDecimal:b0079a8,'0.0',9(9),
:duty=>#BigDecimal:b00796c,'0.0',9(9),
:freight=>#BigDecimal:b007930,'0.0',9(9),
:tax_exempt=>"",
:purchase_order_number=>"",
:md5_hash=>"something",
:card_code_response=>"",
:cardholder_authentication_verification_response=>"2",
:account_number=>"XXXX0002",
:card_type=>"American Express"},
@raw_response=#<Net::HTTPOK 200 OK readbody=true>,
@transaction=
#<AuthorizeNet::AIM::Transaction:0xb02cb7c
@allow_split_transaction=false,
@api_login_id="my_id",
@api_transaction_key=" my_key",
@cp_version=nil,
@custom_fields={},
@delimiter=",",
@device_type=1,
@encapsulation_character=nil,
@fields={:method=>"CC", :card_num=>"370000000000002", :exp_date=>"1120", :amount=>"10.00"},
@gateway="https://test.authorize.net/gateway/transact.dll",
@market_type=2,
@response=#<AuthorizeNet::AIM::Response:0xb00c354 ...>,
@test_mode=false,
@type="AUTH_CAPTURE",
@verify_ssl=false,
@Version="3.1">,
@Version="3.1">
I'm unable to use amount which I got from response.
response.amount
NoMethodError: undefined method `amount' for #AuthorizeNet::AIM::Response:0xb00c354
I need to access transaction details for payments made via mobile card readers for my app, but I'm running into an error coming from the authorizenet ruby sdk.
First step is to call get_transaction_details
on an instance of AuthorizeNet::Reporting::Transaction
to get a response object from the api (an instance of AuthorizeNet::Reporting::Response
). Next, calling the transaction
method on AuthorizeNet::Reporting::Response
yields this error:
NoMethodError (undefined method 'tax_amount=' for #<AuthorizeNet::Order:0x00557bae7c7048 @tax_exempt=false>):
The error is thrown from line 93 of AuthorizeNet::Reporting::Response
The root of the issue is that the response object expects several attributes to be available on an instance of AuthorizeNet::Order
, but the class does not declare attr_accessors for them. As far as I know, these are tax_amount, shipping_amount, shipping_name, shipping_description, and duty_amount.
When I modify AuthorizeNet::Order
in my bundled copy of the gem to declare attr_accessors for those fields, the error disappears and the feature works.
I'd be happy to submit a PR for the issue, though I'm not sure if there are any guidelines for what the maintainers would like to see, particularly around tests. I'm also not sure if there might be some reason behind the bug beyond a simple oversight that might affect what the fix should be. Any help/advice would be much appreciated!
Hi,
I tried to install version 1.9.2
of gem authorizenet from rubygems and run into issue.
For some reason it requires activesupport = 4.2.6 not >= 4.2.6 what makes it impossible to use with rails 5.
I checked gemspec and see that it should require activesupport >= 4.2.6 if RUBY_VERSION > 2.2, but you can see different dependency on rubygems page.
The code sample for "Create an Accept Payment Transaction" seems to be missing in the repo and hence the docs. Any pointers on usage?
It's a bit confusing to see authorize-net
and authorizenet
on RubyGems. In the past, we tried using authorize-net
, but went with an unofficial, forked version instead because it lacked a feature. I'm trying to use the official version again, but after some digging did I find that your official Ruby gem is called authorizenet
and on a new version.
I am using encryptedtrackdatatype to make a create_transaction request. I am getting the following error message in the response:
@text="The element 'encryptedTrackData' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'formOfPayment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'FormOfPayment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
I am not manually creating the xml. So why is it giving me this error? Is there a work around? My code is as follows:
transaction = Transaction.new('xxxxxx', 'xxxxxxxxxxxx', :gateway => :sandbox)
request = CreateTransactionRequest.new
request.transactionRequest = TransactionRequestType.new
request.transactionRequest.amount = 39.55
request.transactionRequest.payment = PaymentType.new
description ="4649443"
enc_data = "12321321"
scheme = KeyManagementScheme.new(KeyManagementScheme::DUKPT.new(OperationType::DECRYPT, KeyManagementScheme::DUKPT::Mode.new("DECRYPT","1"), KeyManagementScheme::DUKPT::DeviceInfo.new(description), KeyManagementScheme::DUKPT::EncryptedData.new(enc_data)))
keyblock = KeyBlock.new(KeyValue.new(EncodingType::Base64, EncryptionAlgorithmType::TDES,scheme))
request.transactionRequest.payment.encryptedTrackData = EncryptedTrackDataType.new(keyblock)
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
response = transaction.create_transaction(request)
Hello,
I'm trying to use v1.8.6
to get a list of ARB subscriptions. I'm using the sample code from the api docs, however when I try and iterate on subscriptionDetails
, it fails, as it is returning a String
. The schema appears, at least in comments, to be correct. I'm not familiar at all with ROXML
,so that's where my troubleshooting ended up.
response = transaction.get_subscription_list(request)
if response.messages.resultCode == MessageTypeEnum::Ok
p response.class
p "Subscription Count: #{response.totalNumInResultSet}"
p response.subscriptionDetails.class
response.subscriptionDetails.each do |subscriptonDetail|
p subscriptionDetail
end
# snip
output:
AuthorizeNet::API::ARBGetSubscriptionListResponse
"Subscription Count: 3"
String
NoMethodError: undefined method `each' for #<String:0x007f8f92061368>
EDIT:
I also tried the master branch at 248cc52, same result.
Can you fix that deprecation?
authorize-net-1.5.2/lib/authorize_net/aim/response.rb:7
@@digest = OpenSSL::Digest::Digest.new('md5')
authorize-net-1.5.2/lib/authorize_net/sim/response.rb:8
@@digest = OpenSSL::Digest::Digest.new('md5')
authorize-net-1.5.2/lib/authorize_net/sim/transaction.rb:10
@@digest = OpenSSL::Digest::Digest.new('md5')
When setting billTo
to a CustomerAddressType
for a TransactionRequestType
, I'm able to add all billing information fields except email.
I attempted forking the code to add an email XML accessor to CustomerAddressType
. I was able to assign the email, but it was not populated in the transaction details.
Any chance we could get a timeline for the next release?
Hey guys.
I've seen recent 1.8.7 update and it's great to see your responsiveness.
However, I found another one inconsistency.
For now it's possible to reuse customer payment profile object (by getting it through the API) when using charge_client method. I'm just passing the profile and I don't have to force user enter credit card data again.
For subscription creation, it isn't possible to pass profile and reuse its data for payment.
The example requires you to pass credit card data and I've tried to retrieve it from the response:
def get_customer_payment_profile(customer_profile_id, customer_payment_profile_id)
request = GetCustomerPaymentProfileRequest.new
request.customerProfileId = customer_profile_id
request.customerPaymentProfileId = customer_payment_profile_id
response = @@transaction.get_customer_payment_profile(request)
if response.messages.resultCode == MessageTypeEnum::Ok
response.paymentProfile
else
"Failed to get payment profile information with id #{request.customerPaymentProfileId}"
end
get_customer_payment_profile(user.customer_profile_id, user.customer_payment_profile_id)
cc_number = customer_payment_profile.payment.creditCard.cardNumber # "XXXX1111" :(
You can see that data is masked, so there's no way to direct reuse of this data.
It looks like the default for :verify_ssl
is false
. I would suggest making it true
.
Every time I run rails console, I get this warning message:
gems/authorizenet-1.8.3/lib/authorize_net/reporting/returned_item.rb:28: warning: duplicated key at line 28 ignored: :return_item_date_utc
I'm trying to test creating a customer profile (using CustomerProfiles/create-customer-profile.rb from the sample ruby code) and I keep getting the following error:
Failed to create a new customer payment profile: The record cannot be found.
The element 'paymentProfiles' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' cannot contain text. List of possible elements expected: 'customerType, billTo, payment, driversLicense, taxId, defaultPaymentProfile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
CustomerProfiles/create-customer-profile.rb:36:in `create_customer_profile': Failed to create a new customer profile. (RuntimeError)
this is the clone to
AuthorizeNet/sample-code-ruby#25
"It isn't clear how to "unzip" response and then retrieve data on back-end for further transaction like ARB, doesn't matter actually.
I've tried to do:
if response.messages.resultCode == MessageTypeEnum::Ok
#HERE
GetCustomerPaymentProfileResponse.new(nil, response.messages, nil, response.paymentProfile)
else
puts response.messages.messages[0].text
raise "Failed to get payment profile information with id #{request.customerPaymentProfileId}"
end
but I can't get any info from it :("
Sorry my issue got posted twise.
response is this
@custom_fields={},
@fields=
{:response_code=>"1",
:response_subcode=>"1",
:response_reason_code=>"1",
:response_reason_text=>"This transaction has been approved.",
:authorization_code=>"9VHMMC",
:avs_response=>"Y",
:transaction_id=>"2241516704",
:invoice_number=>"",
:description=>"",
:amount=>#BigDecimal:b0079d0,'0.1E2',9(18),
:method=>"CC",
:transaction_type=>"auth_capture",
:customer_id=>"",
:first_name=>"",
:last_name=>"",
:company=>"",
:address=>"",
:city=>"",
:state=>"",
:zip_code=>"",
:country=>"",
:phone=>"",
:fax=>"",
:email_address=>"",
:ship_to_first_name=>"",
:ship_to_last_name=>"",
:ship_to_company=>"",
:ship_to_address=>"",
:ship_to_city=>"",
:ship_to_state=>"",
:ship_to_zip_code=>"",
:ship_to_country=>"",
:tax=>#BigDecimal:b0079a8,'0.0',9(9),
:duty=>#BigDecimal:b00796c,'0.0',9(9),
:freight=>#BigDecimal:b007930,'0.0',9(9),
:tax_exempt=>"",
:purchase_order_number=>"",
:md5_hash=>"something",
:card_code_response=>"",
:cardholder_authentication_verification_response=>"2",
:account_number=>"XXXX0002",
:card_type=>"American Express"},
@raw_response=#<Net::HTTPOK 200 OK readbody=true>,
@transaction=
#<AuthorizeNet::AIM::Transaction:0xb02cb7c
@allow_split_transaction=false,
@api_login_id="my_id",
@api_transaction_key=" my_key",
@cp_version=nil,
@custom_fields={},
@delimiter=",",
@device_type=1,
@encapsulation_character=nil,
@fields={:method=>"CC", :card_num=>"370000000000002", :exp_date=>"1120", :amount=>"10.00"},
@gateway="https://test.authorize.net/gateway/transact.dll",
@market_type=2,
@response=#<AuthorizeNet::AIM::Response:0xb00c354 ...>,
@test_mode=false,
@type="AUTH_CAPTURE",
@verify_ssl=false,
@Version="3.1">,
@Version="3.1">
I'm unable to use amount which I got from response.
response.amount
NoMethodError: undefined method `amount' for #AuthorizeNet::AIM::Response:0xb00c354
Is it possible to use the createProfile flag currently when running a credit card transaction? I see it in the API documentation, but it doesn't show here:
Here's what I'm trying:
req = CreateTransactionRequest.new
req.transactionRequest = TransactionRequestType.new()
req.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
req.transactionRequest.amount = amount
req.transactionRequest.payment = PaymentType.new
req.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.ACCEPT.INAPP.PAYMENT', params[:subscription][:opaque_payment], nil)
req.transactionRequest.profile = PaymentProfile.new(createProfile: true)
Here's the response I'm seeing:
Transaction Failed
Error Code : E00003
Error Message : The element 'profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'paymentProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'createProfile, customerProfileId, paymentProfile, shippingProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Hi!
Considering it takes around 17 minutes to run specs on a decent machine with decent internet connection and that โ after running them few times โ one gets 78 emails to your inbox, have you maybe considered using VCR in specs?
We (very unfortunately) have a model named "transactions" in our system. The amount of regression testing, coordination with proven production RAKE CRON jobs, and work to rename that model in an app that is in heavy daily production use would be huge...
require 'authorizenet'
class MyCustomChildClass < MyCustomParentClass
include AuthorizeNet::API
def submit_request # payment # called by another internal method
api_login_id = params[:name]
transactionKey = params[transactionKey]
myTransaction = Transaction.new(api_login_id, transactionKey, :gateway => :sandbox) # ERROR
myTransaction = AuthorizeNet::API::Transaction.new(api_login_id, transactionKey, :gateway => :sandbox) # ERROR
myTransaction = AuthorizeNet::AIM::Transaction.new(api_login_id, transactionKey, :gateway => :sandbox) # NO IMMEDIATE ERROR
request = AuthorizeNet::API::CreateTransactionRequest.new # ERROR
request = AuthorizeNet::CreateTransactionRequest.new # ERROR
I generated a sample application of my own, and it works fine without the namespace (no transaction table to conflict), and it also works fine with the AuthorizeNet::API namespace.
But our production app does not work. I've tried a lot of random experiments with no luck.
The only clue is that AuthorizeNet::AIM is visible, but AuthorizeNet:API is not reachable.
Any ideas where I can look to find the source of this problem?
PS: We've found one laptop where the problem does not occur and another where it does - side-by-side so we're looking at the environment - maybe something that sets load paths...
I am not able to update the authorizenet gem because I am on nokogiri 1.6.6.2, and your gemspec specifies, in effect, that it only works with 1.6.4. Is there a reason why the dependency was changed to such a specific version (down to the minor version) of nokogiri? Any plans for updating it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.