Skip to content

Middleware to connect your PCI Enabled Twilio Account to your WorldPay Account to collect payments over the phone

Notifications You must be signed in to change notification settings

stuartlogan82/twilio-worldpay

Repository files navigation

Twilio Worldpay Integration

A Flask Application that captures basic credit card details over the phone and interacts with WorldPay APIs to process a payment. You can optionally pass in a caller_name and amount as query parameters for dynamic payment amounts.

Prerequisites

Installation

Recommended: Create and run the following in a Python3 Virtual Environment

pip install -r requirements.txt

Populate your .env file from the .env.example file or using configure-env.py

python configure-env.py

Install the Twilio CLI

Optional: Purchase a Twilio number (or use an existing one)

Optional: Search for available numbers in your region

twilio api:core:available-phone-numbers:local:list  --country-code=GB --voice-enabled

Optional: Buy a number

twilio api:core:incoming-phone-numbers:create --phone-number="+442038236401"

Develop locally

Start the server locally

flask run

or, for an https connection

flask run --cert=cert.pem --key=key.pem

Wire up your Twilio number with your endpoint on incoming calls. This will automatically start an ngrok tunnel to your machine.

twilio phone-numbers:update +442038236401 --voice-url=http://localhost:5000/make_payment

Deploy to AppEngine

gcloud app deploy

Point your Incoming Webhook to your AppEngine instance.

twilio phone-numbers:update +442038236401 --voice-url=https://YOUR-APPENGINE-INSTANCE.appspot.com/make_payment

Alternatively, you would probably want to identify the caller and work out how much they had to pay. This might be something you use Twilio Studio for and then use a TwiML Redirect widget to pass the call to this payment flow. You can pass them in as query params caller_name and amount.

Studio Flow

Capture Payment Details at the end of the Interaction

If you set END_OF_INTERACTION_URL in your .env file to a Webhook that you host, you can handle events. You will receive the response from WorldPay with confirmation of the transaction which you could use to update your billing system or CRM.

Caveats

There is no error handling currently for invalid inputs or failed payments.

About

Middleware to connect your PCI Enabled Twilio Account to your WorldPay Account to collect payments over the phone

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published