Skip to main content

How to process payments


Create Transaction

When the customer clicks on one of the checkout button (either normal or express checkout) you need to create a Transaction on Pay iO.

A transaction in Pay iO represents an order or a cart on your platform and the same transaction is used throughout the payment process with Pay iO.

Each transaction needs a unique identifier from your platform that we name cartId

Each transaction needs to have a unique random, unguessable token generated by the platform of origin. This is used to ensure only Pay iO can update the information about this order on your platform.

Generate secure token:

Bellow are some examples on how to generate this random token. But you can use any other methodology that is more secure.

$secretToken = bin2hex(random_bytes(8));

Transaction Structure

{
"cartId": "string",
"totalAmount": "string or number",
"lineItems": [
{
"id": "string",
"name": "string",
"quantity": "string or number",
"imageUrl": "string",
"price": "string or number",
"sku": "string",
"tax": "string or number"
}
],
"countryCode": "string",
"currency": "string",
"publicOrderReference": "string",
"secureToken": "string",
"paymentSuccessUrl": "string",
"checkoutUrl": "string",
"customerEmail": "string",
"customerFirstName": "string",
"customerLastName": "string"
}

Transaction Example

{
"cartId": "wc_cart_12345678ab",
"totalAmount": "28.95",
"lineItems": [
{
"id": "25",
"name": "iPad Cover - White",
"quantity": "3",
"imageUrl": "https://store.storeimages.cdn-apple.com/4668/as-images.apple.com/is/MQ4M2_AV1_GOLD?wid=1144&hei=1144&fmt=jpeg&qlt=80&.v=1536881956864",
"price": 20,
"sku": "white",
"tax": 4
}
],
"countryCode": "UK",
"currency": "GBP",
"publicOrderReference": "Order 25",
"shippingType": "express-delivery",
"secureToken": "f9bf78b9a18ce6d46a0cd2b0b86df9da",
"paymentSuccessUrl": "https://my-shop.co.uk/success?order=12345678ab",
"checkoutUrl": "https://my-shop.co.uk/checkout",
"customerEmail": "customer@gmail.com",
"customerFirstName": "John",
"customerLastName": "Doe"
}

Find more information

Send request to create the transaction

fetch('https://secure.payio.co.uk/api/transaction/create', {  headers: {    'X-API-KEY': '123456789abcdef',  },  method: 'PUT',  body: transactionData,});

Find more information

Send Customer to payment Gateway

When creating the transaction, Pay iO API returns the query string that the Pay iO payment gateway needs to identify and process the transaction. The query string contains an encrypted key and an encrypted cartId.

exemple response from /api/transaction/create

{
"gatewayUrl": "http://secure.payio.co.uk/gateway?key=1d9184fbd99952026f32b4d3838822c0db22d364e5c1d7e774c52d737490460bcd6d1f967ad6f1145ed77f5eb493bfbcf1225e1248d623fa749312ddfa4f6ba3cf9b870fc9452d8dcde3f3cb8c37c1201fdb1b5fadf4376e0211eabdedfebb890192b799cd524c3ae2eb35c25277c1de5aa76b913237ac2f130549160242723efc93c403c7b60add6ea7c6c7e70f2ff8d1db7f2ee8de45d691b6db9d78989a66306cb89a1c67db2867e40e7a4cd9e4e17699be9f21e8e5c74261b0762a8a3c92472af091989ae27a0209089862e9fafe64b892daf0aae90a9161e9899327f64b284a0963345ef45bfa3c5b18d20a517e41754efa556803b9a436eb66f06689d19ca033f16f146794c963fddcb8d7cf0eb6e892bc1c517563d717c713bc30775ca4dfd1ffa0408507e7611369179a7e3f013156fe3e648398ad83f6be668575fba98889cb93e47d589b3f92472ae98463bdbfde1a09ecbf0be158913e2ff63c3f3a8922716c14f02969e596f6b2a28aeada3b88660a2996c4ebacd3d08c9d4a85&cartId=a8b33cc33a3ffc17b25e44f455043072b985ed313bec133022d14f03ee70026dfc543a92c85b980128dd35381d8e4c2ee5701d49ae6269b27b559147f89de06c16bbc096e02105d9759f1e9237b2b8225059e895675d8f473451b7e290fbacba2c1f0e104e09d4fb8942307729616a83a39dc57b1dd4d4a3b761ccd9ba0ebf08be7d3b950bd00524c6030a261bd253a284b1c8c827390d9a33b55a5219cceaf1f19a7806894de5220dfe4c10105de66a8e71994f6d79d8d23fbe9e47a455856c4c3d8be98a4f76ab23fe62490958788ccdb223e029370173b18eba6607a68b89c41f32edff4ffe8265d8dc10a6f1899b9b82c362c0b4499115d268b5231e33e0157a16248b41ea913ea78431b115c3a3aad661d8077aa84752b5c5f12e693edbafc666dc891f5ff57c045d29a8e0aa0c467cc6fda3a4732da8860132d3f5e82bb73d097208981977bd347f4533cdc532464a01d24b98ce6966281778517cae81e55c9b0d1f3ca38a71ee05b3a8a61127db5f4f2a8756ffc497b1c56429c919fc"
}

Save this gatewayUrl field and redirect your customer to that address for them to process the payment.

The user will be directed straight to the payment confirmation page: Payment Confirmation