GithubHelp home page GithubHelp logo

jazzband / django-payments Goto Github PK

View Code? Open in Web Editor NEW
977.0 40.0 275.0 1.01 MB

Universal payment handling for Django.

Home Page: https://django-payments.readthedocs.io

License: Other

Python 98.40% JavaScript 0.67% HTML 0.93%
django payments python stripe paypal google-wallet sofort sagepay braintree

django-payments's Introduction

django-payments's People

Contributors

artursmet avatar bogdal avatar browniebroke avatar derenio avatar emesik avatar esistgut avatar hugovk avatar illing2005 avatar jezdez avatar jskarie avatar juanpsenn avatar jxltom avatar krzysztofwolski avatar maarcingebala avatar mariofix avatar mociepka avatar natureshadow avatar pacu2 avatar pankti459 avatar patrys avatar petrdlouhy avatar pre-commit-ci[bot] avatar romanlv avatar sarathak avatar sergiobrr avatar szymi- avatar whynothugo avatar whyscream avatar wtayyeb avatar xavitorello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-payments's Issues

less 'gaps' in the documentation

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.

cybersource payment provider doesn't work on windows development machine

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

Replace `get_payment_model` with a parametrized `process_data` view

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))),
    ...)

Braintree only works in sandbox mode

 __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.

Improve large price handling

  1. Find out what is optimal value for max_digits in payment, so that all databases are OK with it and it seems sufficient (currently 9 digits are allowed)

Example customer_ip_address may not be NULL

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',)

Urgent Issue Post

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 :)))

Cant get paypal working

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.

Hide Secret keys in DEBUG console

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!

Improve documentation for Stripe payments provider

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 decimal places

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)

PayPal sub_total

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?

get_form() not adding action to the object

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?

Authorize.Net doesn't change captured amount.

#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.

screen shot 2015-06-02 at 2 11 38 pm

PayPal Backend state

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?

Paypal Card Provider refund does not work

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'

Forms shouldn't require whole Payment object instance

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.

Paypal authorization/capture - capture link

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.

stripe cannot pass data-email to widget

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.

provider_factory function raises TypeError

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

Authorize.Net's get_form doesn't call is_valid.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.