The Python 2.7 wrapper
- Download or clone the repo from github
- Download the latest exectubles for the rpc-agent in the release on github
- Put the python wrapper in a folder where you want to use it
- Copy in the rpc-agent of your choice e.g. if mac 64 bit copy in the rpc-agent-mac-64 and rename to rpc-agent
- Download the python Thrift library from apache
- Extract this somewhere useful, change to the directory and change to './lib/py'
- Run the command 'sudo python setup.py install' to install thrift
- Edit the device name and description in the runProducer.py runConsumer.py and runProducerCallbacks.py
- Setup a DEV account on online.worldpay.com
- Copy the API keys to the runProducer.py and runProducerCallbacks.py, client key first, service key second
The python code
runConsumer.py - runs the example consumer
runProducer.py - runs the example producer
runProducerCallbacks.py - runs the example producer with the call back functionality
The wrapper methods
WPWithinWrapperImpl.py - contains the api service methods which you should use
- setup - Sets up the wrapper to be able to start communicating with the underlying SDK.
- addService - Adds a service of type WWSerive to the producer, used if the device you are operating on is a producer, if added to a device you intend as a consumer this will give that device producer functionality.
- removeService - This removes the service from the producer
- initConsumer - This initiates the device as a consumer, which enables it to find services, negotiate prices, make payments and receive services.
- initProducer - This initiates the device as a producer / or initialises the devices producer capability.
- getDevice - This is able to provide back details of the the current device that the SDK is running on, and it credentials / information
- startServiceBroadcast - This enables the producer device to start broadcasting itself via UDP broadcast over the network to notifiy devices it is available to be consumed.
- stopServiceBroadcast - This method stops the SDK from broadcasting the current service messages that it is broadcasting
- deviceDiscovery - This enables the consumer device to discovery other devices (producers) on the network that are UDP broadcasting.
- requestServices - Get a list of services that are avaialble from the broadcasting device.
- getServicePrices - This is used by the consumer to get the list of prices associated with a particular serviceId
- selectService - Selection of a service is performed by the consumer, providing details of the service, the amount and at what price point it wants to purchase the service.
- makePayment - This allows the consumer to request a payment be made at the producer device, by providing the total price response object as the request. The producer will then make the payment (or attempt to) and send back a Payment Response detailing whether it was successful or not.
- beginServiceDelivery - This begins the service delivery, and is requested by the consumer, and will proceed as long as the correct information is provided to the producer. If the correct credentials are passed through, then the producer will start releasing the service known as a 'trusted trigger'
- endServiceDelivery - This ends the service delivery, a request initiated by the consumer.
The wrapper objects
WWTypes.py - contains all the Worldpay Within objects that you should use
- WWTotalPriceResponse - The calculated price details to return to the consumer before the payment is made
- WWServiceMessage - Get the details of the producer device, including the description, and details of how to connect to it
- WWServiceDetails - Gives you the serice ID and description of the service
- WWServiceDeliveryToken - The token than contains details of the service, and used to exchange for release of the service
- WWService - Details of the service, including ID and prices and description
- WWPricePerUnit - The price per unit, including the amount and currency code
- WWPrice - Contains details of the price, and price per unit
- WWPaymentResponse - The response when a payment attempt has been made, with details of the payment and service
- WWHCECard - The payment card credentials - there are test payment card credentials available
- WWDevice - The IoT device and details about the IoT device
- WPWithinGeneralException - A exeption to capture and protect against the deep Thrift errors
Please note the low level service messaging json spec can be found here