Universal payment handling for Django
Documentation: https://django-payments.readthedocs.org/
Universal payment handling for Django.
Home Page: https://django-payments.readthedocs.io
License: Other
Universal payment handling for Django
Documentation: https://django-payments.readthedocs.org/
Currently we only document the generic API.
Current version of wsdl allows to perform only test requests.
Now we can add normal form (ex. credit card form) so get_hidden_fields
method is useless.
It's a self-contained fork of PyCrypto that works on Windows:
Do you guys have any plans to support recurring payments?
The documentation has some good examples of how to use the module, but it doesn't really show how to integrate it into existing django apps.
Its easy to see some ambiguity in this documentation right here https://django-payments.readthedocs.org/en/latest/usage.html#making-a-payment
Where the code belongs isn't stated, its just an example of how to create an arbitrary payment, no explanation to novices where they should be putting that code, model method? view? signal? Redirect to the payment handling view? do i need to pass context? why / why not?
The installation page is closer to what the docs need.
I ask because it appears that your project is the only python 3 compatible django payments module that supports multiple payment providers, which feels worthy of some effort, ensuring people wanting python 3 django support also deserve well documented payment tools.
Id write better docs myself but I don't really understand the library well enough. Without more docs, or some working examples to compare to, I'm not even sure I'm using the library correctly / as intended, and I don't want to write incorrect / unhelpful docs.
It was moved on 2afa08e to payments.core. Is that intended behavior?
I want to use Sourcegraph code search and code review with django-payments. A project maintainer needs to enable it to set up a webhook so the code is up-to-date there.
Could you please enable django-payments on @sourcegraph by going to https://sourcegraph.com/github.com/mirumee/django-payments and clicking on Settings? (It should only take 15 seconds.)
Thank you!
When installing django-payments from github using pip none of the templates directories or their contents appear to be being installed.
Remove variant
from args
. Use self.payment.variant
instead.
URLError at /payments/process/cybersource/
<urlopen error [Error 3] : '\xml\CyberSourceTransaction_1.101.test.wsdl'>
Request Method: GET
Request URL: http://localhost/payments/process/cybersource/
Django Version: 1.7.1
Exception Type: URLError
Exception Value:
<urlopen error [Error 3] : '\xml\CyberSourceTransaction_1.101.test.wsdl'>
Exception Location: C:\Python27\lib\urllib2.py in open_local_file, line 1357
Python Executable: C:\Python27\python.exe
Python Version: 2.7.8
Python Path:
['d:\Dropbox\workspace\dss\src',
'C:\Python27\lib\site-packages\mysql_python-1.2.4-py2.7-win32.egg',
'd:\dropbox\workspace\saleor',
'C:\Python27\lib\site-packages\satchless-1.1.3-py2.7.egg',
'C:\Python27\lib\site-packages\prices-0.5.1-py2.7.egg',
'C:\Python27\lib\site-packages\google_measurement_protocol-0.1.3-py2.7.egg',
'C:\Python27\lib\site-packages\fake_factory-0.4.2-py2.7.egg',
'C:\Python27\lib\site-packages\django_selectable-0.8.0-py2.7.egg',
'C:\Python27\lib\site-packages\django_prices-0.3.4-py2.7.egg',
'C:\Python27\lib\site-packages\django_mptt-0.6.1-py2.7.egg',
'C:\Python27\lib\site-packages\django_model_utils-2.0.3-py2.7.egg',
'C:\Python27\lib\site-packages\django_images-0.4.1-py2.7.egg',
'C:\Python27\lib\site-packages\babeldjango-0.2.2-py2.7.egg',
'C:\Python27\lib\site-packages\babel-1.3-py2.7.egg',
'C:\Windows\SYSTEM32\python27.zip',
'C:\Python27\DLLs',
'C:\Python27\lib',
'C:\Python27\lib\plat-win',
'C:\Python27\lib\lib-tk',
'C:\Python27',
'C:\Python27\lib\site-packages']
Server time: Fri, 19 Dec 2014 14:55:52 +0000
I want to pass "x_invoice_num" to Authorize.net for payments. How can I do this? Is there an example?
The current Stripe backend only supports the embedded form, am I right?
Is there any ongoing effort to integrate custom forms https://stripe.com/docs/tutorials/forms support?
Currently we require an explicit setting pointing to a payment model but there is no technical requirement for that. Instead we could offer a view that accepts the model and let people bind the URLs themselves:
def build_urls(payment_model):
return patterns(
'',
url(
r'^process/(?P<token>[\w-]+)$',
process_data, {'model': payment_model},
name='process_payment'),
url(r'^static/(?P<variant>[\w-]+)$', static_callback,
name='static_process_payment'))
urlpatterns = patterns(
'',
url('^payment/', include(build_urls(MyPayment))),
...)
__init__() got an unexpected keyword argument 'sandbox'
when I have
PAYMENT_VARIANTS = {
'braintree': ('payments.braintree.BraintreeProvider', {
'merchant_id': MERCHANT_ID,
'public_key': PUBLIC_KEY,
'private_key': PRIVATE_KEY,
'sandbox': IS_SANDBOX
})}
In my settings, works fine when I remove it, but only works in sandbox.
Try to create example app using payments.dummy.DummyProvider
and get error, when create payment object:
payment = Payment.objects.create(
variant='default', # this is the variant from PAYMENT_VARIANTS
description='Book purchase',
total=Decimal(120),
tax=Decimal(20),
currency='USD',
delivery=Decimal(10),
billing_first_name='Sherlock',
billing_last_name='Holmes',
billing_address_1='221B Baker Street',
billing_address_2='',
billing_city='London',
billing_postcode='NW1 6XE',
billing_country_code='UK',
billing_country_area='Greater London',)
... and move to readthedocs preferably.
We start using it because of windows. Can we check OS as long as Legrandin/pycryptodome#6 exists? If windows we will use pycryptodome
otherwise we use pycrypto
?
Hi comrads!
In new release 0.7.2 there is an issue from commit by:
Adam (20.07.2015) commit message: Add tests for capture, refund and renew token
In his commit he replaces some logic in 'def process_data' function. It's all ok BUT:
He renames value from:
payment = self.execute_payment(payer_id)
to
execute_payment = self.execute_payment(payment, payer_id)
and forgets to change it at line 230:
payment.attrs.payer_info = payment['payer']['payer_info']
should be:
payment.attrs.payer_info = execute_payment['payer']['payer_info']
(I hope that I shouldn't explain why payment['payer']['payer_info']
wouldn't work)
and all goes well...
p/s I wondering how is your tests gone and you build it :)))
As the title says, it would be nice to have Stripe support out of the box.
I get a 400 error mesage when trying to connect to sandbox:
/home/tickets/views.py in internet_checkout
form = payment.get_form(data=request.POST or None) ...
▶ Local vars
/home/_env/local/lib/python2.7/site-packages/payments/models.py in get_form
return provider.get_form(data=data) ...
▼ Local vars
Variable Value
self
<Payment: default>
data
None
provider
<payments.paypal.PaypalProvider object at 0x7f62206f85d0>
/home/_env/local/lib/python2.7/site-packages/payments/paypal/init.py in get_form
response.raise_for_status() ...
▼ Local vars
Variable Value
self
<payments.paypal.PaypalProvider object at 0x7f62206f85d0>
extra_data
{}
data
None
response
<Response [400]>
redirect_to
None
/home/_env/local/lib/python2.7/site-packages/requests/models.py in raise_for_status
raise HTTPError(http_error_msg, response=self) ...
▼ Local vars
Variable Value
self
<Response [400]>
http_error_msg
'400 Client Error: Bad Request'
I dont know why this none and whi not raise exception and do redirect here:
try:
form = payment.get_form(data=request.POST or None)
except RedirectNeeded as redirect_to:
return redirect(str(redirect_to))
Thank you.
The payment providers' Secret keys appears in CLEAR in the the debug console.
PAYMENT_VARIANTS {'stripe': ('payments.stripe.StripeProvider', {'public_key': 'pk_test_i7RTWcR0w8aK3KZB2yEfeGVi', 'secret_key': 'sk_test_k4aH2sWIisUK0TqtPwdUmJ6o'})}
For security, hide the secret keys in the debug console.
By renaming the parameter: PAYMENT_VARIANTS
to SECRET_PAYMENT_VARIANTS
for example.
(can use any of these keywords: API TOKEN KEY SECRET PASS SIGNATURE
)
And the keys will appears like that: SECRET_KEY u'********************'
See conversation about this issued here:
http://stackoverflow.com/questions/29351830/django-payments-how-to-keep-the-secret-key-secret
Thanks!
Currently documentation for Stripe payment backand states that developers should attach form.media
to the payment form. But this setup is insufficient and won't ever produce a successfull payment. In saleor stripe payment form template includes stripe payment button that seems to be necessary and should be included in the documentation
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="{{ form.stripeToken.field.widget.attrs.data_key }}"
data-image="{{ STATIC_URL }}img/logo.png"
data-name="Site Name"
data-description="{{ form.stripeToken.field.widget.attrs.data_description }}"
data-amount="{{ form.stripeToken.field.widget.attrs.data_amount }}"
data-currency="{{ form.stripeToken.field.widget.attrs.data_currency }}">
</script>
Paypal allows only 2 decimal places in all price fields.
If price contains more places, this results in 400 error. Currently, Price field in almost all prices modules contains more decimal places. We should have a method to cut them to two in paypal gateway, like so:
{0:.2f}".format(price)
It should be passed to appropriate methods thus making the provider stateless. This would allow us to instantiate the providers exactly once.
Hi,
I see you calculate the sub_total for PayPal like this:
sub_total = self.payment.total - self.payment.delivery
however based on documentation and common sense, you should also subtract taxes from sub_total as well?
sub_total = self.payment.total - self.payment.delivery - self.payment.tax
right?
I am following the documentation and getting the form on my view with
payment.get_form(request.POST or None)
That object should have an attribute named action, for use in the context:
<form action="{{ form.action }}" method="{{ form.method }}">
{{ form.as_p }}
<p><input type="submit" value="Proceed" /></p>
</form>
Action is None for the backends i tried(Dummy, authorize.net, stripe). It should return something valid if possible, and None is not. A blank string or request.path would make more sense maybe?
#60 made it so that the transaction is posted up to Authorize.Net. It does function, including setting the payment as "Confirmed" and placing the transaction into Authorize.Net's unsettled queue (which does properly settle whenever Authorize.Net runs settlements). However, no amount is ever recorded as captured in the payment.
Hi, what state is the PayPal Backend in? I tried to figure out how to use it, but I think the implementation is too old! Today I need User, Pass and Signature (and maybe API Version) or even better I should use adaptive payments...
Am I wrong?
PaymentError
can be thrown by CyberSource backend, when current payment can't be processed:
https://github.com/mirumee/django-payments/blob/master/payments/cybersource/__init__.py#L126
I think that it should set status to error
without throwing an exception.
Now app has to override process()
view and catch the exception manually. Maybe this exception should be catched in default process()
view?
I am getting this error message:
File .../payments/models.py", line 171, in refund
amount = provider.refund(amount)
File ".../payments/paypal/__init__.py", line 295, in refund
url = self.links['refund']['href']
KeyError: u'refund'
Now when I want to render payment form (example with Stripe) I have to do something like this:
payment = Payment(variant='stripe', total=1, currency='USD')
payment_form = payment.get_form()
And it will return blank form. Sometimes we don't exactly know total amount, before payment form initialization, for example for single page checkouts.
Also there is a bug I think, when I want to initialize form with data:
payment_form = payment.get_form(request.POST or None)
It performs validation and save at this step
https://github.com/mirumee/django-payments/blob/master/payments/stripe/__init__.py#L33
In my opinion get_form()
method shouldn't try to validate the form and for sure it shouldn't save the form.
With payment data relying on strings for API is a Bad Idea™. We should provide an enum similar to https://pypi.python.org/pypi/enum34.
When trying to capture a payment that has been authorized I am getting an error that is traced back to the _get_links method within the PaypalProvider class:
def _get_links(self, payment):
extra_data = json.loads(payment.extra_data or '{}')
links = extra_data.get('links', {})
return links
In order for the capture links to be extracted from extra_data the following line is required to replace links = extra_data.get('links', {}) :
links = extra_data['response']['transactions'][0]['related_resources'][0]['authorization']['links']
otherwise incorrect links are pulled and a PayPal error is raised.
Hi there,
We would like to pass data-email to the checkout.js in the widget so the email field is pre-filled. It seems not possible because the strip form checks for is_bound and if anything is passed to the form when there isn't a stripetoken, the payment just gets rejected.
payments.provider_factory()
raises a TypeError exception when from __future__ import unicode_literals
is used in the module.
The exception occurs on line 91:
module = __import__(module_path, globals(), locals(), [klass_name])
where klass_name should be a string, but with unicode_literals is assumed to be unicode.
I've written a simple test here: https://github.com/brew/django-payments/blob/master/payments/tests.py
If I comment out the unicode_literals import in the init.py file it passes.
I'm using Django 1.6.2 / Python 2.7.6 / OS X 10.7.5
This behavior doesn't match other providers. Using a common interface (such as in Saleor) never calls up to the Authorize.Net form's clean method, meaning that the communication doesn't happen, nor does the payment's information get updated.
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.