By continuing to navigate on this website, you accept the use of cookies to serve you more relevant services & content.
For more information and to change the setting of cookies on your computer, please read our Cookie Policy.

Integration of 2checkout with django

Integration of payment gateways is an important part of developing an e-commerce application which includes communication with several banks with different ways online banking/debit credit cards. and also providing security is the most important feature for all payment gateways integration. We are having payment gateways like paypal,braintree,payumoney,2checkout...    In this post,we will see how to integrate 2checkout with our django application.

To integrate it to the application,it offers 3 different integration methods.

1.inline checkout

In inline chekout,we displays a secure payment form as an overlay on your checkout page. .It collects the buyers's billing/shipping address and finalize the cart total sum
the function of inline checkout is same as standard checkout, but when the required parameter is missing(buyer's name,email address and billing address),it willredirect to the standard checkout.

 
To know about request parameters, and response please refer to https://www.2checkout.com/documentation/checkout/inline-checkout

2.standard checkout 
It can handle every part of the buyer’s checkout process on a single page. You can customize the whole checkout process to your needs by passing user billing/shipping information details, currency details, language and checkout steps.

 
 
To know about request parameters, and response please refer to https://www.2checkout.com/documentation/checkout/standard-checkout

3.Payment Api

In payment api,we are taking the credit card information with a simple HTML form on our website, and use our 2co.js JavaScript library to convert the credit card information into a secure token. We're sending the secure token to your server and submit the transaction using 2checkout API.

a)create token:

Here we collect the payment details using a form(#myform) and generate a secure token 


b) create sale: after token has been created, you can use it to charge the customer through our server-side authorization API call.

# Setup credentials and environment

    twocheckout.Api.auth_credentials({

        'private_key': 'sandbox-private-key',

        'seller_id': 'sandbox-seller_id',

        'mode': 'sandbox'

    })

    # Setup arguments for authorization request
    args = {
        'merchantOrderId': '123',
        'token': request.form["token"],
        'currency': 'USD',
        'total': '1.00',
        'billingAddr': {
            'name': 'Testing Tester',
            'addrLine1': '123 Test St',
            'city': 'Columbus',
            'state': 'OH',
            'zipCode': '43123',
            'country': 'USA',
            'email': 'example@micropyramid.com',
            'phoneNumber': '555-555-5555'
        }
    }

    # Make authorization request
    try:
        result = twocheckout.Charge.authorize(args)
        return result.responseMsg
    except TwocheckoutError as error:
        return error.msg

for more details refer  to https://www.2checkout.com/documentation/payment-api/

Return Process:

after successful transaction using 3 methods,we can redict to the website by giving the return url in the production account,or we can also mention in the form using the input field x_receipt_link_url=http://www.yoursite.com/return

    Posted On
  • 21 May 2015
  • By
  • Micropyramid

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Export html web page to pdf using jspdf

jsPDF is used to generate pdf files in client-side Javascript. You can find the links for jsPDF here and also you can find the link ...

Continue Reading...
Understanding Routers in Django-Rest-Framework

By using routers in django-rest-framework we can avoid writing of url patterns for different views. Routers will save a lot of time for developing the ...

Continue Reading...
Basics of Django templates

Django template engine comes as part of django framework and its very easy, extensible and handy to develop complex web applications with simplest efforts. Lets ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties