recurringstack/recurringstack-php

此仓库包含RecurringStackT API的官方PHP客户端。官方版本

dev-main 2024-06-13 23:25 UTC

This package is auto-updated.

Last update: 2024-09-14 00:01:56 UTC


README

Alt text

recurringstack-php

此仓库包含RecurringStack™ API的官方PHP客户端。创建和管理账户、订阅、产品、支持工单等。

RecurringStack™ API的文档可以在https://recurringstack.com/docs找到。

要求

PHP 7或更高版本

guzzle/guzzle (依赖项)

Composer

我们建议使用Composer安装绑定。

composer require recurringstack/recurringstack-php

不要忘记在项目/脚本顶部包含Composers的自动加载。

require_once 'vendor/autoload.php';

创建客户端和认证

$rs = new recurringstack\api([
  'key' => "rs_key_....",
  'user_key' => "rs_user_....",
  'brand_id' => "",
  'response_format' => 'xml', //xml or json
  'response_type' => 'clean' //empty or clean (returns results as object)
]);

使用示例

# List one or multiple customer accounts
$rs->listAccount(array('customer_account_id' => '8247cf79-9296-4372-b39c-6370c70372ee'))
# Delete a customer account
$rs->deleteAccount('8247cf79-9296-4372-b39c-6370c70372ee');
# Create a new subscription for a customer
$subConfig = array(
  "customer_account_id" => '8247cf79-9296-4372-b39c-6370c70372ee',
  "product_id" => "",
  "auto_pay" => "",
  "override_initial_billing" => ""
);

$rs->createSubscription($subConfig);
# Manually create an invoice for a customer
$invoiceConfig = array(
 "attached_items" => '[{"item_name":"Programming Services Base Charge","item_price":"25.00","tax_exempt":"N"},{"item_name":"25 Hours of Programming","item_price":"250.00","tax_exempt":"Y"}]',
 "custom_field_1" => '',
 "custom_field_2" => ''
);

$rs->createInvoice($invoiceConfig);

注意:我们建议将您的代码包裹在try块中,因为所有本地或从API返回的错误都将作为异常返回

贡献

欢迎提交拉取请求。对于重大更改,请先提交问题以讨论您想要更改的内容。

许可证

MIT