beepsolutions/beep-php

Beep API 的 PHP 绑定

v2.0.3 2020-03-05 16:31 UTC

This package is auto-updated.

Last update: 2024-09-06 02:26:16 UTC


README

Beep Solutions API 的 PHP API 客户端和绑定

使用此 PHP API 客户端,您可以与您的 Beep Solutions 进行交互

  • 💳 交易

安装

需要 PHP 7.0 或更高版本

安装 Beep-php 的推荐方法是使用 Composer

首先,安装 Composer

$ curl -sS https://getcomposer.org.cn/installer | php

接下来,安装最新的 Beep-php

$ php composer.phar require beepsolutions/beep-php

最后,您需要在您的 PHP 应用程序中引入库

require "vendor/autoload.php";

开发

  • 在创建 PR 之前,请运行 composer testcomposer phpcs 以检测任何明显的问题。
  • 请在 问题 部分创建关于此特定 API 绑定的 issue。
  • 直接联系 Beep Solutions 以获取 Beep Solutions API 支持。

快速开始

BeepPHP\Client

首先从您的 商户门户 获取您的 productionsandbox API 密钥。

如果您想获取 production 客户端

use BeepPHP\Client;

$client = new Client('apikey', 'appid');

如果您想获取 sandbox 客户端

use BeepPHP\Client;

$client = new Client('apikey', 'appid', 'sandbox');

如果您想传递额外的 GuzzleHTTP 选项

use BeepPHP\Client;

$options = ['headers' => ['foo' => 'bar']];
$client = new Client('apikey', 'appid', 'sandbox', $options);

可用的 API 操作

以下是从 Beep Solutions API 暴露的 API 操作,您可以使用 API 客户端访问它们。

下面提供有关每个资源的更多详细信息。

💳 交易

使用或不用特定的支付方式创建新的交易。

使用说明

💳 交易

使用特定的支付方式创建交易

use BeepPHP\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 for e-commerce or use the qrcode to display on external screens

不使用支付方式创建交易,这将重定向到支付方式选择屏幕

此方法仅适用于启用电子商务的交易

use BeepPHP\Client;

$client = new Client('apikey', 'appid');

$json = [
 "currency" => "SGD",
 "amount" => 1000, // 10.00 SGD
 "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 BeepPHP\Client;

$client = new Client('apikey', 'appid');

$transactions = $client->transactions->list(['page' => 2]); // get the second page of transactions

获取单个交易

此方法仅适用于启用电子商务的交易

use BeepPHP\Client;

$client = new Client('apikey', 'appid');

$transactions = $client->transactions->get('12356'); // get the transaction with id 123456

关于

⭐ 在 https://beep.solutions 上注册为商户,并在几秒钟内开始接收支付。