Giter Club home page Giter Club logo

cartridge-payments's Introduction

cartridge-payments

NOTE: Requires cartridge 0.8.2 or higher The shop/checkout.html template has 3 blocks that are required. nav-buttons, before-form, and after-form.

Cartridge multiple payment options module.

Features

This package lets you specify an optional Primary Payment Processor (in the normal cartridge way) and any number of extra processors. (ones that link out like Paypal Standard or Google Wallet ).

On the payment page the regular form shows up, if enabled, as well as buttons to submit form data out to the secondary payment providers.

Installation

Install the package by running the following command in your virtual environment:

pip install cartridge-payments

Add the following minimum settings to your settings file:

INSTALLED_APPS = (
    # ...
    "payments.multipayments",
    # ...
)

TEMPLATE_CONTEXT_PROCESSORS = (
    # ...
    "payments.multipayments.context_processors.settings",
    # ...
)

# USE or EXTEND the custom callback-uuid form
SHOP_CHECKOUT_FORM_CLASS = 'payments.multipayments.forms.base.CallbackUUIDOrderForm'

# Add the callback_uuid field to orders. This field is helpful for identifying
# orders being checked out.
EXTRA_MODEL_FIELDS = (
    # ...
    (
        "cartridge.shop.models.Order.callback_uuid",
        "django.db.models.CharField",
        (),
        {"blank" : False, "max_length" : 36, 'default': 0},
    ),
    # ...
)


# WHEN TRUE, Users will be able to submit payment using the regular paradigm
# as well as the secondary payment processors.  WHEN FALSE the regular paradigm
# will be hidden / disabled.
PRIMARY_PAYMENT_PROCESSOR_IN_USE = True

# These processors are forms to submit to remote URLs for processing.
SECONDARY_PAYMENT_PROCESSORS = (
    ('payment-key1', {
        'name' : 'Button Name 1',
        'form' : 'dot.separarted.form.Class1'
    }),
    ('payment-key2', {
        'name' : 'Button Name 2',
        'form' : 'dot.separarted.form.Class2'
    })
)

Migrate Existing Database

python manage.py schemamigration cartridge.shop --auto
python manage.py migrate shop

PayPal Configuration

One built-in processor is for PayPal. PayPal IPN is not implemented by default, but is supported by specifying the PAYPAL_IPN_URL setting.

Add PayPal as a secondary payment processor.

SECONDARY_PAYMENT_PROCESSORS = (
    # ...
    ('paypal', {
        'name' : 'Pay With Pay-Pal',
        'form' : 'payments.multipayments.forms.paypal.PaypalSubmissionForm'
    }),
    # ...
)

Configure PayPal

# Currency type.
PAYPAL_CURRENCY = "USD"

# Business account email. Sandbox emails look like this.
PAYPAL_BUSINESS = '[email protected]' 

# Use this to enable https on return URLs.  This is strongly recommended! (Except for sandbox)
PAYPAL_RETURN_WITH_HTTPS = True 

# Function that returns args for `reverse`. 
# URL is sent to PayPal as the for returning to a 'complete' landing page.
PAYPAL_RETURN_URL = lambda cart, uuid, order_form: ('shop_complete', None, None)

# Function that returns args for `reverse`. 
# URL is sent to PayPal as the URL to callback to for PayPal IPN.
# Set to None if you do not wish to use IPN.
PAYPAL_IPN_URL = lambda cart, uuid, order_form: ('my_paypal_ipn', None, {'uuid' : uuid})
    
# URL the secondary-payment-form is submitted to
# Dev example
PAYPAL_SUBMIT_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
# Prod example
PAYPAL_SUBMIT_URL = 'https://www.paypal.com/cgi-bin/webscr'

Google Wallet Configuration

Another built-in processor is for Google Wallet. Google wallets callbacks are not implemented but are supported because callback_uuid's are sent to Google Wallet as merchant-private-data.

Add Google Wallet as a secondary payment processor.

SECONDARY_PAYMENT_PROCESSORS = (
    # ...
    ('google', {
        'name' : 'Pay With Google Wallet',
        'form' : 'payments.multipayments.forms.google.GoogleSubmissionForm'
    }),
    # ...
)

Configure Google Wallet

# URL the secondary-payment-form is submitted to
# Dev example
GOOGLE_CHECKOUT_SUBMIT_URL = \
    'https://sandbox.google.com/checkout/api/checkout/v2/checkoutForm/Merchant/<my-merchant-id>'
# Prod example
GOOGLE_CHECKOUT_SUBMIT_URL = \
    'https://checkout.google.com/api/checkout/v2/checkout/Merchant/<my-merchant-id>'

cartridge-payments's People

Contributors

joshbatchelor avatar kulak avatar nychng avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

cartridge-payments's Issues

invalid syntax (paypal.py, line 2)

Hi i am getting these error:

Error during template rendering

In template /home/django/planeta/templates/shop/payment.html, error at line 15
invalid syntax

line 15 is
{% multipayment_forms request form as multipayment_forms %}

What do you think i am doing wrong?
Any advice would be great, thank you!

Discount codes not applied in amount sent to PayPal

My cartridge shop offers a discount code on some products. When applied, this discount appears taken correctly in the cart total in shop.cart view, but the PaypalSubmissionForm does not pass the discount along to the PayPal submit URL. Looking at the code, I see that it is adding a field for each line item including the amount, but does not do anything to handle discount codes that I can see.

I will be happy to work on this myself and submit a PR at some point, but I thought I'd bring it up here in case anyone has a better idea how to do this that I do. For the moment, I'm pretty stumped tbh. Thanks!

Invalid logic in PaypalSubmissionForm

Cartridge ver. > 0.8.4 up to current does not save order in database until last checkout step is executed.
PaypalSubmissionForm from cartridge-payments.payments.multipayments.forms ignores this logic and saves session data in its constructor during its instantiation, ie. before payment form is submitted. User can push back-button to update billing/shipping data, but those changes don't get reflected as PaypalSubmissionForm retrieves old data from a database, not current from a session.

A bug ? An intended behavior ?

Paypal Example Configuration Does Not Work

Sorry for raising and issue about this but I thought it best to ask the person what wrote the software. I am building an eCommerce site and using your module to integrate paypal to start with and Google wallet when I have proven there is enough custom. The issue I am having is I have set all the settings you have shown and I am not getting a button displayed for paypal and I have set the primary payment method to False and it is still showing up do you have any Idea what might cause this.

I apologise again for using the issues

Reverse Issue With Settings

I am running into an issue when trying to get to the payment page I followed the guide on the readme but the ipn is giving me this issues if I set it to be commented out it says it is not set so I uncommented it and get this issue and I am unsure why it happens.

Reverse for 'my_paypal_ipn' with arguments '()' and keyword arguments '{u'uuid': u'85a8b22d-e17f-49ce-8147-b13cb2b209c2'}' not found. 0 pattern(s) tried: []

Documentation inaccurate for newer Python versions

When running cartridge-payments under python3.4.1 with Mezzanine3.1.10 and cartridge 0.9.5, the instructions on the main git page of the project won't work. For these users, the following modifications have to be made:

Firstly, SHOP_CHECKOUT_FORM_CLASS is deprecated, so instead the following line has to be inserted into the urlpatterns in urls.py:

url("^shop/checkout/$", "cartridge.shop.views.checkout_steps", name="checkout_steps", kwargs=dict(form_class=CallbackUUIDOrderForm)),

Secondly, having the line

{"blank" : False, "max_length" : 36, 'default': 0},

in EXTRA_MODEL_FIELDS will cause checkout to fail silently during the address screen because of a malformed UUID (0). The current EXTRA_MODEL_FIELDS in settings.py should be replaced by this:

from uuid import uuid4
def generateUUID():
return str(uuid4())

EXTRA_MODEL_FIELDS = (
(
"cartridge.shop.models.Order.callback_uuid",
"django.db.models.CharField",
(),
{"blank" : False, "max_length" : 36, "default" : generateUUID},
),
)

Users that already experience this latter error must first do a schemamigration with the entire EXTRA_MODEL_FIELDS commented out, then do another with the new EXTRA_MODEL_FIELDS, or else the schemamigration won't recognize the changed default UUID and the error will persist.

pip install does not work

(crafttoyz)nai@nyc:~/Work/crafttoyz(develop○) » pip install cartridge-payments
Downloading/unpacking cartridge-payments
  Could not find any downloads that satisfy the requirement cartridge-payments
No distributions at all found for cartridge-payments
Storing complete log in /Users/nai/.pip/pip.log
(crafttoyz)nai@nyc:~/Work/crafttoyz(develop○) »

Recommended Approach to handle Order Complete workflow

I was just wondering how would you go about implementing the order.complete(request) function from cartridge if you were using Paypal IPN method given that the request object of the user won't be available during Paypal's IPN call?

multipayment payment form never being called

I have set up the secondary payment processor as per the README in an effort to get PayPal intergrated, however the multipayment form is never being shown, instead the default cartridge order form is being shown. Is there anything missing from the README that could be causing this? Thanks

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.