Skip to main content

Redirect method

The Redirect method is the easiest way of integrating with Pomelo Connect. You can still control the experience and maintain your brand's look and feel by configuring the background images, colors, and fonts of this hosted payment page. Set a logo, background, and styling on the merchant dashboard under Settings → Branding.

When creating the redirect payment, you'll receive a URL in return. This URL is where you can redirect your user, either on web or mobile. To ensure a smooth transition back to your website after payment, specify a redirectUrl in the API request.

Once the payment process concludes, Pomelo will redirect the user back to your specified redirectUrl with the state and transactionId appended as query parameters. To ensure the redirect is genuine and to fetch the final transaction state, you should always query the API.

Creating a redirect payment

NodeJS:

const axios = require('axios');

async function createPayment() {
// setup your API request
const request = {
amount: 1000, // 10.00 GBP
currency: 'GBP',
localId: 'my-invoice-123',
redirectUrl: 'https://yourwebsite.com/checkout-complete',
locale: 'en', // or th_TH, en_GB, etc.
// ... additional parameters
};

// send the request
const response = await axios.post(
'https://api.pomelopay.com/public/v2/transactions',
request,
);

// extract the redirect URL from the response and send the user there
return response.data.url;
}

PHP:

<?php

require 'vendor/autoload.php';
use GuzzleHttp\Client;

function createPayment() {
$request = [
'amount' => 1000, // 10.00 GBP
'currency' => 'GBP',
'localId' => 'my-invoice-123',
'redirectUrl' => 'https://yourwebsite.com/checkout-complete',
'locale' => 'en', // or th_TH, en_GB, etc.
// ... additional parameters
];

$client = new Client();
$response = $client->post(
'https://api.pomelopay.com/public/v2/transactions',
['json' => $request],
);

return json_decode($response->getBody(), true)['url'];
}

Example response

{
"created": "2023-06-09T06:16:16.372Z",
"updated": "2023-06-09T06:16:16.385Z",
"amount": 510,
"currency": "GBP",
"payCurrency": "GBP",
"state": "INITIATED",
"merchantId": "64646727335b730008db10f8",
"redirectUrl": "https://yourwebsite.com/checkout-complete",
"url": "https://transaction.example.com/6482c3b0dd653100088ab08b",
"shortUrl": "https://pay.example.com/mQLbGgy31N",
"urlHash": "mQLbGgy31N",
"expires": "2023-06-16T06:16:16.371Z",
"id": "6482c3b0dd653100088ab08b",
"amountAsDecimal": "5.10",
"amountFormatted": "GBP 5.10",
"history": [
{ "state": "INITIATED", "updatedDate": "2023-06-09T06:16:16.372Z", "trigger": "SYSTEM" }
],
"isPaymentLink": true,
"signMethod": "sha1"
}

For all fields you can send (customer details, payment expiry, etc.), see the Create Transaction (v2) operation in the API reference.

The shortUrl field is a shortened version of the full gateway URL. Use it on social media or messaging apps where character count matters.

Handling the redirect back

After the payment process completes the user is sent to your redirectUrl with parameters appended:

https://yourwebsite.com/checkout-complete?transactionId=6482c3e7dd653100088ab08c&state=CONFIRMED&signature=cfc90cd8b2566a2447f9b866a3967f58c79b2b6f

We provide state and signature so you can validate the redirect, but always perform a server-side query with Get Transaction to obtain the authoritative final state — the redirect itself can be tampered with by anything sitting between the user and your server.

NodeJS:

const axios = require('axios');

async function queryPaymentStatus(transactionId) {
const response = await axios.get(
`https://api.pomelopay.com/public/v2/transactions/${transactionId}`,
);
console.log(`Transaction state: ${response.data.state}`);
}

PHP:

<?php

require 'vendor/autoload.php';
use GuzzleHttp\Client;

function queryPaymentStatus($transactionId) {
$client = new Client();
$response = $client->get("https://api.pomelopay.com/public/v2/transactions/{$transactionId}");
$state = json_decode($response->getBody(), true)['state'];
echo "Transaction state: {$state}";
}

Transaction states

StatusDescriptionNotes
INITIATEDPayment has been createdUser can pay the transaction
QR_CODE_GENERATEDPayment is pending and has a QR-code image availableUser can pay the transaction
CONFIRMEDPayment completedFunds are confirmed
CANCELLEDUser has cancelled or timed outPayment link can no longer be used
FAILEDPayment failed and is permanently cancelledThe payment method or link can no longer be used for this transaction