Worldpay Within SDK to allow payments within IoT. Written in Python.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
webapps/worldpaywithin
wpw-sdk-thrift @ ba49bf4
wpwithinpy
.gitignore
.gitmodules
.travis.sh
.travis.yml
ConsumerFlowTester.py
DeviceScanner.py
LICENSE.md
README.md
RunConsumerOWP.py
RunConsumerWT.py
RunProducerCallbacksOWP.py
RunProducerCallbacksWT.py
RunProducerOWP.py
RunProducerWT.py
TestProducer.py
pylintrc
setup.py
test_e2e.py

README.md

Worldpay Within - The Python SDK

The Python implementation for the Worldpay Within IoT payment SDK. This SDK, or Software Development Kit, enables smart devices to discover each other, negogiate a price for services, make a payment (through the Worldpay payments gateway) for services, and then consume services via a trusted trigger. For more information see our documentation website here: http://www.worldpaywithin.com

The Worldpay Within puzzle piece

Prerequisites

Before you started:

  • Install Python on your system. We've built the SDK to work with version 2.7.
    • We are using Apache Thrift, which implementation is not fully Python 3.x compatible.
    • Python binaries might have different names on your system (ex. python3 and pip3).
  • Install git.
  • Verify that the command python is available to run without specyfying the whole path and update PATH environment if required.
  • On some UNIX operating systems, such as Debian, you must additionally install setup-tools: sudo apt install python-setuptools
  • Create an account with Worldpay Online so that you can generate yor own test API key. You'll replace the Worldpay test keys with your own in the SDK.
    • ⚠️ Make sure you only use test API keys.

Get started

  1. Download this repo
    • git clone https://github.com/WPTechInnovation/wpw-sdk-python.git
  2. Change to the directory (for example cd wpw-sdk-python)
  3. Run git submodule update --init --recursive
  4. As an administrator run python setup.py install
    • On most UNIX systems this command becomes sudo python setup.py install

Run the examples

You can try the examples by running them in two different console windows. Or, if you're installing on two separate devices, they must be on the same network that allows UDP broadcast traffic. Make sure you're using rhw Online Worldpay (OWP) files rather than the Worldpay Total (WT) ones.

  1. python runProducerOWP.py OR python runProducerCallbacksOWP.py - in the other window
  2. python runConsumerOWP.py - in one window
  3. The two smart devices should communicate with each other and make a payment

See the payments:

  1. Sign up to https://online.worldpay.com if you haven't already done so
  2. Got to settings > API keys and get your test keys
  3. Make sure you are using test keys
  4. Find the config folder of the SDK and find the producer JSON files.
    • Add your Service and Client keys:
      • The pspConfig.merchant_client_key and pspConfig.hte_public_key must have the same key.
      • The pspConfig.merchant_service_key and pspConfig.hte_private_key must have the same keys.
    • Save your work.
  5. Re-run the examples and you should see the payments coming through on the WPOP (Worldpay Online) payments dashboard

Debugging:

  • If you get some odd error messages talking about a 'rpc-agent'
    • Try typing the following command: 'ps -e | grep rpc' to get the pid(s) of rpc-agents that are running.
    • Then do kill pid e.g. kill 13249234 to kill these processes.
  • Try re-running the examples - if this fails then please contact us at innovation@worldpay.com or on our slack channel or raise an issue in github.

So what does it do:

The Worldpay Within Flows sequence diagram

You can see there are four phases; discover, negotiation, payment and then service delivery, for more information visit our website at http://www.worldpaywithin.com.

What IoT devices can I run this on

Hopefully any - we've only tested this on RPi - Raspberry Pis at the moment, but welcome experiments on all other kinds of devices! Note that they will need to be on the same network - and that network should allow for UDP broadcast traffic. Most mobile hotspots do allow this, a lot of corporate networks however do not...

Want to contribute:

Want to contribute, then please clone the repo and create a branch, once you've made your changes create a pull request, we will review your code, and if accepted it will be merged into the code base. You can also raise issues here on github, or contact us direct at innovation@worldpay.com or alternatively join our slack channel at iotpay.slack.com.