drewisme / authorizesauce Goto Github PK
View Code? Open in Web Editor NEWAn awesome-sauce Python library for accessing the Authorize.net API. Sweet!
Home Page: http://authorizesauce.readthedocs.org/
License: MIT License
An awesome-sauce Python library for accessing the Authorize.net API. Sweet!
Home Page: http://authorizesauce.readthedocs.org/
License: MIT License
E00007: User authentication failed due to invalid authentication values.
That is the error I am receiving, the default test information that is included works well but when i generate my own transaction key and API Login key I receive the above error.
My account is in test mode.
Has anyone else experienced this problem?
Curious if there is a way to include the Order Information such as Invoice ID and Description?
It would also be nice to submit the Customers Company Name, Phone Number, and Customer ID
Hi @jeffschenck
I am new to use Authorize.net, I am facing this issue from several days, installed everything related to authorizesause but still getting following ImportError error. Please let me know what I am missing?
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 93, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 75, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/sreekanth/Desktop/myproject/myproject/main_site/models.py", line 10, in <module>
from app.admin.booking import DateRangeListFilter
File "/home/sreekanth/Desktop/myproject/myproject/app/admin/__init__.py", line 1, in <module>
from .booking import *
File "/home/sreekanth/Desktop/myproject/myproject/app/admin/booking.py", line 14, in <module>
from notifications.models import BookingConfirmationEmail,ItineraryEmail
File "/home/sreekanth/Desktop/myproject/myproject/notifications/models.py", line 4, in <module>
from app.models import MembershipRequest, Booking, ConciergeRequest, Trip
File "/home/sreekanth/Desktop/myproject/myproject/app/models.py", line 16, in <module>
import app.payment_helpers
File "/home/sreekanth/Desktop/myproject/myproject/app/payment_helpers.py", line 1, in <module>
from authorize import AuthorizeClient, CreditCard, Address
ImportError: cannot import name AuthorizeClient
Thanks in advance
Is it possible to use a single instance of a given API (the Customer API, for example) for all requests in a web application? I am considering only initializing each API once for my application and sharing them over all HTTP requests. Or, will I need to initialize each API I want to use for each request individually?
Authorize.net has a setting to send payment notifications to users. For this to work, the user's email address needs be sent along with the address data; is this currently supported by AuthorizeSauce?
I have an implementation of authorizesauce that's been working for months and suddenly I'm getting this error. I reverted my code to my last known working configuration and it still errors the same. I'm not understanding what it's complaining about.
The error is :<urlopen error [Errno -2] Name or service not known>
/usr/lib/python2.7/urllib2.py in do_open, line 1184
and it seems to be occurring after the transaction is set
try:
transaction = client.card(cc).capture(20.00)
except..
..
except..
else:
saved_card = client.card(cc).save()
client.card(cc).save() takes it into
/usr/local/lib/python2.7/dist-packages/authorize/apis/customer.py(79)create_saved_profile()
-> response = self._make_call('CreateCustomerProfile', profile, 'none')
and then eventually into
/usr/local/lib/python2.7/dist-packages/suds/client.py(581)invoke()
-> result = self.send(soapenv)
/usr/local/lib/python2.7/dist-packages/suds/client.py(586)send()
-> def send(self, soapenv):
/usr/local/lib/python2.7/dist-packages/suds/client.py(594)send()
self.location()
self.location outputs: https://oce-ex-cert-api.authorize.net/soap/v1/Service.asmx
which appears to be invalid and is maybe why this method fails?
it continues into:
/usr/local/lib/python2.7/dist-packages/suds/client.py(608)send()
-> request = Request(location, soapenv)
/usr/local/lib/python2.7/dist-packages/suds/client.py(613)send()
-> reply = self.options.transport.send(request)
/usr/local/lib/python2.7/dist-packages/suds/transport/https.py(66)send()
-> return HttpTransport.send(self, request)
/usr/local/lib/python2.7/dist-packages/suds/transport/http.py(77)send()
->u2request = urllib2.Request(url, msg, headers)
url is that same location above which doesnt return anything in a browser:
'https://oce-ex-cert-api.authorize.net/soap/v1/Service.asmx'
/usr/lib/python2.7/urllib2.py(210)init()
-> self.headers = {}
(Pdb) self.data
'<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://api.authorize.net/soap/v1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">SOAP-ENV:Header/ns0:Bodyns1:CreateCustomerProfilens1:merchantAuthenticationns1:name9XbVU3pNB2u/ns1:namens1:transactionKey9999b425h9GskTHR/ns1:transactionKey/ns1:merchantAuthenticationns1:profilens1:merchantCustomerId7701676e7a5f4895ac4c/ns1:merchantCustomerIdns1:paymentProfilesns1:CustomerPaymentProfileTypens1:customerTypeindividual/ns1:customerTypens1:billTons1:firstNamedennis 1/ns1:firstName/ns1:billTons1:paymentns1:creditCardns1:cardNumber4111111111111111/ns1:cardNumberns1:expirationDate2100-12/ns1:expirationDatens1:cardCode222/ns1:cardCode/ns1:creditCard/ns1:payment/ns1:CustomerPaymentProfileType/ns1:paymentProfiles/ns1:profilens1:validationModenone/ns1:validationMode/ns1:CreateCustomerProfile/ns0:Body/SOAP-ENV:Envelope'
214 -> if origin_req_host is None:
215 origin_req_host = request_host(self)
request_host(self) outputs> 'oce-ex-cert-api.authorize.net'
-> self.unverifiable = unverifiable
(Pdb) unverifiable
False
/usr/local/lib/python2.7/dist-packages/suds/transport/http.py(82)send()
-> fp = self.u2open(u2request)
(Pdb) self.u2open(u2request)
*** URLError: <urlopen error [Errno -2] Name or service not known>
/usr/local/lib/python2.7/dist-packages/suds/transport/http.py(129)u2open()
-> if (sys.version_info < (3, 0)) and (self.u2ver() < 2.6):
(Pdb) sys.version_info
sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
/usr/local/lib/python2.7/dist-packages/suds/transport/http.py(132)u2open()
-> return url.open(u2request, timeout=tm)
(Pdb) url.open(u2request, timeout=tm)
/usr/lib/python2.7/urllib2.py(404)open()
(Pdb) req.dict
{'_Request__r_type': '//oce-ex-cert-api.authorize.net/soap/v1/Service.asmx', '_Request__original': 'https://oce-ex-cert-api.authorize.net/soap/v1/Service.asmx', 'data': '<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://api.authorize.net/soap/v1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">SOAP-ENV:Header/ns0:Bodyns1:CreateCustomerProfilens1:merchantAuthenticationns1:name9XbVU3pNB2u/ns1:namens1:transactionKey9999b425h9GskTHR/ns1:transactionKey/ns1:merchantAuthenticationns1:profilens1:merchantCustomerIdf8943d36ac104fd8a8e0/ns1:merchantCustomerIdns1:paymentProfilesns1:CustomerPaymentProfileTypens1:customerTypeindividual/ns1:customerTypens1:billTons1:firstNamedennis 1/ns1:firstName/ns1:billTons1:paymentns1:creditCardns1:cardNumber4111111111111111/ns1:cardNumberns1:expirationDate2222-11/ns1:expirationDatens1:cardCode123/ns1:cardCode/ns1:creditCard/ns1:payment/ns1:CustomerPaymentProfileType/ns1:paymentProfiles/ns1:profilens1:validationModenone/ns1:validationMode/ns1:CreateCustomerProfile/ns0:Body/SOAP-ENV:Envelope', '_tunnel_host': None, 'host': 'oce-ex-cert-api.authorize.net', 'origin_req_host': 'oce-ex-cert-api.authorize.net', 'headers': {'Soapaction': '"https://api.authorize.net/soap/v1/CreateCustomerProfile"', 'Content-type': 'text/xml; charset=utf-8'}, '_Request__fragment': None, 'timeout': 90, '_Request__r_host': '/soap/v1/Service.asmx', 'unredirected_hdrs': {'Content-length': '1080', 'Host': 'oce-ex-cert-api.authorize.net', 'User-agent': 'Python-urllib/2.7'}, 'unverifiable': False, 'type': 'https', 'port': None}
where it fails in /usr/lib/python2.7/urllib2.py(1222)https_open()
Can anyone help??
Several hours ago software using this library started throwing exceptions in createCustomerProfile
:
Traceback (most recent call last):
File "authsauce_test.py", line 13, in <module>
saved_card = card.save()
File "/home/alexey/git/authorizesauce/authorize/client.py", line 147, in save
.create_saved_profile(unique_id, [payment], email=self.email)
File "/home/alexey/git/authorizesauce/authorize/apis/customer.py", line 80, in create_saved_profile
response = self._make_call('CreateCustomerProfile', profile, 'none')
File "/home/alexey/git/authorizesauce/authorize/apis/customer.py", line 51, in _make_call
response = method(self.client_auth, *args)
File "/home/alexey/.virtualenvs/authorize/lib/python3.6/site-packages/suds/client.py", line 521, in __call__
return client.invoke(args, kwargs)
File "/home/alexey/.virtualenvs/authorize/lib/python3.6/site-packages/suds/client.py", line 581, in invoke
result = self.send(soapenv)
File "/home/alexey/.virtualenvs/authorize/lib/python3.6/site-packages/suds/client.py", line 619, in send
description=tostr(e), original_soapenv=original_soapenv)
File "/home/alexey/.virtualenvs/authorize/lib/python3.6/site-packages/suds/client.py", line 677, in process_reply
raise Exception((status, description))
Exception: (550, 'Unknown')
The API tester here https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile works fine.
Any insights?
saved_card_id = save_card('4111111111111111', 2018, '01', '911', 'Joe', 'Blow')
uid = preauth(saved_card_id, 200)
settle(uid)
refund(uid,'1111')
throws "AuthorizeResponseError: A valid amount is required."
As per Authorize.net security updates, as of June 30, for transaction calls, the requests have to be sent via POST
, not GET
. We got an email from authorize.net taht we are making GET
requests, and based on that, as well and urlopen()
usage in the library, I assume the library relies on GET
requests.
Is it possible to change this, so the transaction parameters are sent via POST
? This will affect all users of the library since its a system wide change on their end, announced last year due to TLS requirements and PCI compliance.
@drewisme seems to be the new project maintainer :) Could you maybe confirm this and give us some feedback regarding this?
Hi @jeffschenck , thanks for this API, it's really useful. I want to ask, how can I pass the phone number and description to authorize.net while capturing a card?
Currently I have:
client = AuthorizeClient(settings.AUTHNET_LOGIN_ID, settings.AUTHNET_TRANSACTION_KEY, debug=False, test=settings.AUTHNET_TEST_MODE)
credit_card = CreditCard(cc_number, cc_year, cc_month, ccv, firstname, lastname)
address = Address(street=street,city=city,state=state,zip_code=zip_code,country=country)
card = client.card(credit_card, address=address, email=email)
cc_trans = card.capture(settings.CHARGE)
It seems authorizesauce does not support these fields out of the box. I thought about modifying your code (auth
, and _add_params
methods I think if I am reading your code right) to pass through the extra params - but I see all the fieldnames have custom names begin with x (x_address
, x_card_code
, x_city
, etc). I cannot find a list of these x_
fieldnames in Authorize.net's documentation - are you able to point me to the supported list of fieldnames? If you are able to help me find that, I think I can fix it myself.
If I offer up a pull request with this change then you might be open to merging it into the plugin?
Or perhaps this is something you can more easily fix yourself?
Either way, I need to solve it, hope you can help...
I saw this issue of yours and I sent an answer to your email address because I can't save comments to qmk_firmware for some reason. Did you see it? Sorry I had to make an off-topic issue in this repository.
Right now, it does not appear that the recurring
method for setting up a recurring payment is implemented on the SavedCard
object. This should be added.
I just found your code and it looks exactly what I am looking for. I did notice when following your directions to save a credit card for a customer, it looked like the address info on a charge is all blank. Is saving the address info already built in, and I am just not seeing how to go about saving that as well? Or is that something that was on the roadmap to be added in later?
Hi,
I saved the credit card
on authorize.net successfully. But when I try to make the recurring
payment. I get error message.
saved_card = client.card(cc).save()
Making recurring payment.
saved_card = client.saved_card('uid')
saved_card.recurring(20, date(2012, 12, 1), months=1)
Error
'AuthorizeSavedCard' object has no attribute 'recurring'
Here is full traceback.
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/subscriptions/subscribe/
Django Version: 1.6.8
Python Version: 2.7.8
Installed Applications:
(u'mezzanine.boot',
u'django.contrib.auth',
u'django.contrib.redirects',
u'django.contrib.contenttypes',
u'django.contrib.sessions',
u'django.contrib.sites',
u'django.contrib.messages',
u'django.contrib.staticfiles',
u'tastypie',
u'cartridge.shop',
u'mezzanine.conf',
u'mezzanine.core',
u'mezzanine.generic',
u'mezzanine.blog',
u'mezzanine.forms',
u'mezzanine.pages',
u'mezzanine.galleries',
u'mezzanine.twitter',
u'utilities',
u'cj_models',
u'subscriptions',
u'filebrowser_safe',
u'south',
u'grappelli_safe',
u'django.contrib.admin',
u'django.contrib.comments')
Installed Middleware:
(u'django.contrib.sessions.middleware.SessionMiddleware',
u'django.middleware.locale.LocaleMiddleware',
u'django.contrib.auth.middleware.AuthenticationMiddleware',
u'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
u'django.middleware.common.CommonMiddleware',
u'django.middleware.csrf.CsrfViewMiddleware',
u'django.contrib.messages.middleware.MessageMiddleware',
u'cartridge.shop.middleware.ShopMiddleware',
u'mezzanine.core.request.CurrentRequestMiddleware',
u'mezzanine.core.middleware.TemplateForDeviceMiddleware',
u'mezzanine.core.middleware.TemplateForHostMiddleware',
u'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware',
u'mezzanine.core.middleware.SitePermissionMiddleware',
u'mezzanine.pages.middleware.PageMiddleware')
Traceback:
File "/Users/sandhu/Envs/carjojo/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/sandhu/Envs/carjojo/lib/python2.7/site-packages/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/Users/sandhu/Envs/carjojo/lib/python2.7/site-packages/braces/views/_access.py" in dispatch
64. request, *args, **kwargs)
File "/Users/sandhu/Envs/carjojo/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
87. return handler(request, *args, **kwargs)
File "/Users/sandhu/Envs/carjojo/lib/python2.7/site-packages/django/views/generic/edit.py" in post
171. return self.form_valid(form)
File "/Users/sandhu/projects/carjojo_project/carjojo/subscriptions/views.py" in form_valid
55. saved_card.recurring(20, date(2012, 12, 1), months=1)
Exception Type: AttributeError at /subscriptions/subscribe/
Exception Value: 'AuthorizeSavedCard' object has no attribute 'recurring'
Thanks,
Kulbir
I am wondering is is possible to somehow validate transaction which is being done on saved card?
I am doing a cron in my app, which does some auto purchases daily, and generates invoices in my app. So, when the transaction is declined, the process shouldn't continue.
client = AuthorizeClient('abc', '123', debug=False)
saved_card = client.saved_card(id)
transaction = saved_card.capture(price)
I checked the docs and haven't found a way to figure this out.
How can i validate the card on authorize? In the CIM documentation there's a validationMode. How can i set this var on liveMode?
Jeff, this is an amazingly simple interface to use. Thanks for your hard work!
The one thing I'm stuck on is the ability to update the credit card for a recurring payment. We allow our customers to update their cards at any time without affecting their subscription. But I currently have to delete and recreate the recurring payments as there's no interface to update the card.
Any thought of adding that in?
I see there is a transaction object in this library, but not sure how to go about getting a list of transactions.
Do you currently support the API found at http://developer.authorize.net/api/transaction_details/ ?
Looks like a small issue with parsing the response from Authorize.net. Possibly they slightly changed something?
Hi I am using authorizesauce - been using it for awhile and started getting errors on 7/7/17.
They are not recorded in authorize.net at all, they are denying my transaction.
The response returned is this:
[Mon Jul 10 23:10:13 2017] [error] Error response code returned from API. <class 'authorize.exceptions.AuthorizeResponseError'> - This transaction cannot be accepted for processing. full_response={'cvv_response': '', 'authorization_code': '', 'response_code': '3', 'amount': '120.00', 'transaction_type': 'auth_capture', 'avs_response': 'P', 'response_reason_code': '66', 'response_reason_text': 'This transaction cannot be accepted for processing.', 'transaction_id': '0'}
I have no idea what changed, or why I would be the only one getting this error -- but I can't seem to find any one else complaining about it on the web.
I did happen to notice that authorize.net changed their API code but it's not supposed to have any effect on past implementations.
(see change log for API changes on 7/7/17 here: http://developer.authorize.net/api/changes/)
Note: my first transaction after 7/7 was actually on 7/10 which is when i started having this issue of not being able to process credit card payments. And Yes, I'm still on https.
Any insight, suggestions or tips are appreciated!
I'm currently working on developing my own solution, but I'd like to stay using authorizeSauce - it's been very reliable up til now.
Thanks!
Jeff,
Thanks so much for building an outstanding API - your approach precisely matches my needs and I'm very grateful! The care you've put into your documentation is outstanding.
I am experiencing problem when attempting to "settle" a transaction, while following your tutorial at:
http://authorize-sauce.readthedocs.org/en/latest/intro.html
Specifically, executing "transaction.settle()" resulted in an error from Authorize.Net stating:
'The transaction cannot be found.', 'transaction_id': '0'
It seems that the transaction.uid value is not being passed to (or not being acknowledged by) the Authorize.Net API.
The exact sequence is as follows:
In [1]: from authorize import AuthorizeClient
In [2]: client = AuthorizeClient('285tUPuS', '58JKJ4T95uee75wd')
In [3]: from authorize import CreditCard
In [4]: cc = CreditCard('4111111111111111', '2018', '01', '911', 'Joe', 'Blow')
In [5]: transaction = client.card(cc).capture(100)
In [6]: transaction.uid
Out[6]: '2176015209'
In [7]: transaction = client.transaction('2176015209')
In [8]: transaction.settle()
AuthorizeResponseError Traceback (most recent call last)
in ()
----> 1 transaction.settle(50)
/usr/lib/python2.6/site-packages/AuthorizeSauce-0.2-py2.6.egg/authorize/client.pyc in settle(self, amount)
218 instance representing the settlement transaction.
219 """
--> 220 response = self._client._transaction.settle(self.uid, amount=amount)
221 transaction = self._client.transaction(response['transaction_id'])
222 transaction.full_response = response
/usr/lib/python2.6/site-packages/AuthorizeSauce-0.2-py2.6.egg/authorize/apis/transaction.pyc in settle(self, transaction_id, amount)
101 amount = Decimal(str(amount)).quantize(Decimal('0.01'))
102 params['x_amount'] = str(amount)
--> 103 return self._make_call(params)
104
105 def credit(self, card_num, transaction_id, amount):
/usr/lib/python2.6/site-packages/AuthorizeSauce-0.2-py2.6.egg/authorize/apis/transaction.pyc in _make_call(self, params)
51 (fields['response_reason_text'], fields))
52 e.full_response = fields
---> 53 raise e
54 return fields
55
AuthorizeResponseError: The transaction cannot be found. full_response={'cvv_response': '', 'authorization_code': '', 'response_code': '3', 'amount': '100.00', 'transaction_type': 'prior_auth_capture', 'avs_response': 'P', 'response_reason_code': '16', 'response_reason_text': 'The transaction cannot be found.', 'transaction_id': '0'}
I have tried this using the test account referenced in your documentation, my own test account, and my production account. In searching for more information, I read that Authorize.Net only "settles" transactions once per day.
Is it the case that "settlements" simply happen once every 24 hours by Authorize.Net and developers do not need to send a specific instruction to settle - or is this a bug?
Many thanks!
Gary
Hi, I'm receiving this error when trying to test for a transaction in debug mode under sandbox environment. The production environment works just fine, only the sandbox keep showing up the error. As there are only a few documents about this error, I'm not really sure what is going wrong here. I would like to ask under what condition might this error happen? My production and sandbox environment basically share the same code and I'm pretty sure my sandbox account is configured correctly... the problem occurs after we updated authorizesauce to 5.0
In light of #5 and #24, I'm guessing you don't have an interest in supporting this, but is there a simple way for me to hack this in? It looks like I'd need to add an order
that has an invoiceNumber
property. Rather than add a whole Order
class to data.py
, can I get away with calling _add_params
directly and passing in {"order": {"invoiceNumber": "xyz"}}
?
If a user enters unicode characters in their submission details e.g. address
An attempt to urlencode the unicode is made here:
File /authorize/apis/transaction.py", line 42, in _make_call
params = urllib.urlencode(params)
This causes the UnicodeEncodeError
After no problem for many years, I started intermittently getting the following exception when submitting a payment transaction: Authorize.Net error. E00027: A duplicate transaction has been submitted.
There is no obvious cause, i.e. no duplicate transaction from my end.
I spoke with Authorize.net tech support and said they are seeing a duplicate transaction coming through a few seconds apart, and suggested that sometimes the API framework does this for technical reasons.
It's a mystery to me because nothing has changed in my Django app. The error started a few days ago and since then has been varying between happening more than half the time to happening less than 10% of the time.
Now authorize don't save any cvv code on the Customer Information. So now, we need to pass the cvv on the transaction, i think that we have to save cvv in another place, and send to the transaction call? How we can do this?
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.