承接 recurringstack/recurringstack-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

recurringstack/recurringstack-php

最新稳定版本:v0.1.0-beta

Composer 安装命令:

composer require recurringstack/recurringstack-php

包简介

This repository houses the official php client for the RecurringStack API. Official Release

README 文档

README

Alt text

recurringstack-php

This repository houses the official php client for the RecurringStack™ API. Create and manage account, subscriptions, products, support tickets, and more.

Documentation for the RecurringStack™ API can be found at https://recurringstack.com/docs.

Requirements

PHP 7 or later

guzzle/guzzle (dependency)

Composer

We recommend using Composer to install the bindings.

composer require recurringstack/recurringstack-php

Don't forget to include Composers autoload at the top of your project/script.

require_once 'vendor/autoload.php';

Creating a Client and Authenticating

$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)
]);

Error Handling & Exceptions

The RecurringStack™ API client includes custom error handling methods.

try { 

    # Delete a customer account
    $rs->deleteAccount('8247cf79-9296-4372-b39c-6370c70372ee');

} catch (recurringstack\apiException $e) { 

    /* The following custom error handling functions are available /*

    $debug = debugError(); //Return the exception message, code, request, and the response as an object. Great for debugging!
    $errorObj = $e->errorAsObject(); //Return the code and message in an object
    $errorMessage = getExceptionMessage(); //Return just the message
    $errorCode = getExceptionCode(); //Return just the status code
    */

    }

Usage Examples

# 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" => "",
  "coupon_code" => '',
  "custom_field_1" => '',
  "custom_field_2" => '',
  "attached_components" => '',  
  "override_initial_billing" => ""
);

$rs->createSubscription($subConfig);
# Manually create an invoice for a customer
$billableItems = array(
  array('item_name' => 'Programming Services Base Charge','item_price' => '25.00','tax_exempt' => 'Y'),
  array('item_name' => '25 Hours @ $15.00 Ea','item_price' => '375.00','tax_exempt' => 'Y'),
);

$invoiceConfig = array(
 "attached_items" => json_encode($billableItems),
 "custom_field_1" => '',
 "custom_field_2" => ''
);

$rs->createInvoice($invoiceConfig);

NOTES:

  • We recommend wrapping your code in a try block as all errors returned locally or from the API will be returned as exceptions
  • Find more example code in the official RecurringStack™ documentation at https://recurringstack.com/docs/api

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-12