Skip to content

Accept payments on your Python/Flask based website with cards, wallets, and key local payment methods

License

Notifications You must be signed in to change notification settings

adyen-examples/adyen-python-online-payments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adyen online payment integration demos

Run this integration in seconds using Gitpod

NOTE: To allow the Adyen Drop-In and Components to load, you have to add https://*.gitpod.io as allowed origin for your chosen set of API Credentials

Open in Gitpod
 First time with Gitpod?

Details

This repository showcases a PCI-compliant integration of the Sessions Flow, the default integration that we recommend for merchants. Explore this simplified e-commerce demo to discover the code, libraries and configuration you need to enable various payment options in your checkout experience.

Card Checkout Demo

The Demo leverages Adyen's API Library for Python GitHub | Docs.

Requirements

  • Python 3.5 or greater
  • Python libraries:
    • flask
    • uuid
    • Adyen v12.0.0 or higher

Installation

  1. Clone this repo
git clone https://github.com/adyen-examples/adyen-python-online-payments.git
  1. Run source ./setup.sh to:

    • Create and activate a virtual environment
    • Download the necessary python dependencies
  2. Create a .env file with all required configuration

Remember to include http://localhost:8080 in the list of Allowed Origins

    PORT=8080
    ADYEN_API_KEY="your_API_key_here"
    ADYEN_MERCHANT_ACCOUNT="your_merchant_account_here"
    ADYEN_CLIENT_KEY="your_client_key_here"
    ADYEN_HMAC_KEY="your_hmac_key_here"

Usage

  1. Run ./start.sh to:

    • Initialize the required environment variables. This step is necessary every time you re-activate your venv
    • Start Python app
  2. Visit http://localhost:8080 and select an integration type.

To try out integrations with test card numbers and payment method details, see Test card numbers.

Webhooks

Webhooks deliver asynchronous notifications about the payment status and other events that are important to receive and process. You can find more information about webhooks in this blog post.

Webhook setup

In the Customer Area under the Developers → Webhooks section, create a new Standard webhook.

A good practice is to set up basic authentication, copy the generated HMAC Key and set it as an environment variable. The application will use this to verify the HMAC signatures.

Make sure the webhook is enabled, so it can receive notifications.

Expose an endpoint

This demo provides a simple webhook implementation exposed at /api/webhooks/notifications that shows you how to receive, validate and consume the webhook payload.

Test your webhook

The following webhooks events should be enabled:

  • AUTHORISATION

To make sure that the Adyen platform can reach your application, we have written a Webhooks Testing Guide that explores several options on how you can easily achieve this (e.g. running on localhost or cloud).

About

Accept payments on your Python/Flask based website with cards, wallets, and key local payment methods

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published