PHP code example of pomelopay / pomelopay-connect-php
1. Go to this page and download the library: Download pomelopay/pomelopay-connect-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pomelopay / pomelopay-connect-php example snippets
use PomeloPayConnect\Client;
$client = new Client('apikey', 'appid');
use PomeloPayConnect\Client;
$client = new Client('apikey', 'appid', 'sandbox');
use PomeloPayConnect\Client;
$options = ['headers' => ['foo' => 'bar']];
$client = new Client('apikey', 'appid', 'sandbox', $options);
use PomeloPayConnect\Client;
$options = ['baseUrl' => 'my-custom-url'];
$client = new Client('apikey', 'appid', 'sandbox', $options);
use PomeloPayConnect\Client;
$client = new Client('apikey', 'appid');
$json = [
"provider" => "card", // Payment method enabled for your merchant account such as bcmc, card, card
"currency" => "GBP",
"amount" => 1000, // 10.00 GBP
"redirectUrl" => "https://foo.bar/order/123" // Optional redirect after payment completion
];
$transaction = $client->transactions->create($json);
header('Location: '. $transaction->url); // Go to transaction payment page
use PomeloPayConnect\Client;
$client = new Client('apikey', 'appid');
$json = [
"currency" => "GBP",
"amount" => 1000, // 10.00 GBP
"redirectUrl" => "https://foo.bar/order/987" // Optional redirect after payment completion
];
$transaction = $client->transactions->create($json);
header('Location: '. $transaction->url); // Go to payment method selection screen
use PomeloPayConnect\Client;
// Get your API Key and App ID from the "Connect" screen on your merchant dashboard
$client = new Client('apikey', 'appid');
// Currency should be your merchant account currency or the payment would be rejected
$json = [
"currency" => "EUR",
"amount" => 1234, // 12.34 EUR,
"localId" => "INVOICE-2020-0001",
"redirectUrl" => "https://your.webshop.domain.url/my_order/2020_0001" // Optional redirect after payment completion, the payment portal will redirect to this URL and attach queryParameters to this URL, fully optional
];
$transaction = $client->transactions->create($json);
header('Location: '. $transaction->url); // Go to payment screen on Pomelo Pay
die();
use PomeloPayConnect\Client;
// Get your API Key and App ID from the "Connect" screen on your merchant dashboard
$client = new Client('apikey', 'appid');
// Currency should be your merchant account currency or the payment would be rejected
$json = [
"currency" => "EUR",
"amount" => 1234, // 12.34 EUR,
"localId" => "INVOICE-2020-0001",
"webhook" => "https://foo.bar/incoming/1234",
"redirectUrl" => "https://your.webshop.domain.url/my_order/2020_0001" // Optional redirect after payment completion, the payment portal will redirect to this URL and attach queryParameters to this URL, fully optional
];
$transaction = $client->transactions->create($json);
header('Location: '. $transaction->url); // Go to payment screen on Pomelo Pay
die();
use PomeloPayConnect\Client;
// Get your API Key and App ID from the "Connect" screen on your merchant dashboard
$client = new Client('apikey', 'appid');
// Currency should be your merchant account currency or the payment would be rejected
$json = [
"currency" => "EUR",
"amount" => 1234, // 12.34 EUR,
"validForHours" => 3,
"localId" => "INVOICE-2020-0001",
"webhook" => "https://foo.bar/incoming/1234",
"redirectUrl" => "https://your.webshop.domain.url/my_order/2020_0001" // Optional redirect after payment completion, the payment portal will redirect to this URL and attach queryParameters to this URL, fully optional
];
$transaction = $client->transactions->create($json);
header('Location: '. $transaction->url); // Go to payment screen on Pomelo Pay
die();