sverraest / pomelo-php
PHP Bindings for the Pomelo Pay API
Requires
- php: >= 7.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ~5.0
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-10-13 01:37:04 UTC
README
PHP API Client and bindings for the Pomelo Pay API
Using this PHP API Client you can interact with your Pomelo Pay:
- 💳 Transactions
Installation
Requires PHP 7.0 or higher
The recommended way to install pomelo-php is through Composer:
First, install Composer:
$ curl -sS https://getcomposer.org/installer | php
Next, install the latest pomelo-php:
$ php composer.phar require sverraest/pomelo-php
Finally, you need to require the library in your PHP application:
require "vendor/autoload.php";
Development
- Run
composer test
andcomposer phpcs
before creating a PR to detect any obvious issues. - Please create issues for this specific API Binding under the issues section.
- Contact Pomelo Pay directly for Pomelo Pay API support.
Quick Start
PomeloPHP\Client
First get your production
or sandbox
API key from Pomelo Pay.
If you want to get a production
client:
use PomeloPHP\Client; $client = new Client('apikey', 'appid');
If you want to get a sandbox
client:
use PomeloPHP\Client; $client = new Client('apikey', 'appid', 'sandbox');
If you want to pass additional GuzzleHTTP options:
use PomeloPHP\Client; $options = ['headers' => ['foo' => 'bar']]; $client = new Client('apikey', 'appid', 'sandbox', $options);
Available API Operations
The following exposed API operations from the Pomelo Pay API are available using the API Client.
See below for more details about each resource.
💳 Transactions
Create a new transaction with or without a specific payment method.
Usage details
💳 Transactions
Create transaction with a specific payment method
use PomeloPHP\Client; $client = new Client('apikey', 'appid'); $json = [ "provider" => "alipay", // Payment method enabled for your merchant account such as bcmc, alipay, 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
Create transaction without a payment method that will redirect to the payment method selection screen
use PomeloPHP\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
About
➡️ You can follow me on 🐦 Twitter or ✉️ email me at simon[-at-]pomelopay.com.
⭐ Sign up as a merchant at https://pomelopay.com and start receiving payments in seconds.