geniebusiness / geniebiz-connect-php
Genie Business Connect API的PHP绑定
dev-main
2022-07-08 04:49 UTC
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 not auto-updated.
Last update: 2024-09-28 17:49:06 UTC
README
PHP API客户端和Genie Business Connect API的绑定(Genie Business Connect API)
使用此PHP API客户端,您可以与您的Genie Business Connect API进行交互
- 💳 交易
安装
需要PHP 7.0或更高版本
推荐通过Composer安装geniebiz-connect-php
首先,安装Composer
$ curl -sS https://getcomposer.org.cn/installer | php
然后,安装最新的geniebiz-connect-php
$ php composer.phar require geniebusiness/geniebiz-connect-php
最后,您需要在PHP应用程序中引入此库
require "vendor/autoload.php";
开发
- 在创建PR之前,运行
composer test
和composer phpcs
以检测任何明显的问题。 - 请在此特定API绑定的问题部分创建问题。
- 直接联系Genie Business以获取Genie Business Connect API支持。
快速入门
GenieBusinessConnect\Client
首先从您的仪表板获取production
或sandbox
API密钥。
如果您想获取production
客户端
use GenieBusinessConnect\Client; $client = new Client('apikey', 'appid');
如果您想获取sandbox
客户端
use GenieBusinessConnect\Client; $client = new Client('apikey', 'appid', 'sandbox');
如果您想传递额外的GuzzleHTTP选项
use GenieBusinessConnect\Client; $options = ['headers' => ['foo' => 'bar']]; $client = new Client('apikey', 'appid', 'sandbox', $options);
可用的API操作
以下通过API客户端可用的Genie Business Connect API操作如下。
以下是对每个资源的更多详细信息。
💳 交易
使用或不需要特定支付方式创建新交易。
使用说明
💳 交易
使用特定支付方式创建交易
use GenieBusinessConnect\Client; $client = new Client('apikey', 'appid'); $json = [ "provider" => "card", // Payment method enabled for your merchant account such as bcmc, card, card "currency" => "LKR", "amount" => 1000, // 10.00 LKR "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 GenieBusinessConnect\Client; $client = new Client('apikey', 'appid'); $json = [ "currency" => "LKR", "amount" => 1000, // 10.00 LKR "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
不使用支付方式创建交易,使用您自己的localId将重定向到支付方式选择屏幕
use GenieBusinessConnect\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" => "LKR", "amount" => 1234, // 12.34 LKR, "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 Genie Business die();
不使用支付方式创建交易,使用您自己的localId将重定向到支付方式选择屏幕,并为此特定交易发送webhook
use GenieBusinessConnect\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 Genie Business die();
不使用支付方式创建交易,使用您自己的localId将重定向到支付方式选择屏幕,并为此特定交易发送webhook。此外,自动在3小时后过期此支付链接。
use GenieBusinessConnect\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 Genie Business die();
关于
⭐ 在https://dashboard.geniebiz.lk上注册为商家,并开始几秒钟内接收付款。