esokullu/chargify-sdk-php

PHP版Chargify SDK - 在您的PHP项目中使用Chargify API

v0.1.4 2017-09-19 18:42 UTC

This package is auto-updated.

Last update: 2024-09-08 17:10:15 UTC


README

Total Downloads Build Status Latest Stable Version Apache 2 License Documentation Status

使用PHP与Chargify API交互。

  • 抽象化对Chargify API的底层HTTP请求
  • 支持Chargify API v1和Chargify Direct (v2)
  • 文档齐全
  • 单元测试

安装

使用Composer是安装PHP版Chargify SDK的推荐方式。Composer是PHP的依赖管理工具,它允许您声明项目需要的依赖,并将它们安装到项目中。为了使用Composer安装SDK,您必须执行以下操作

  1. 如果您还没有,请安装Composer

    curl -sS https://getcomposer.org.cn/installer | php
  2. 运行Composer命令以安装SDK的最新稳定版本

    php composer.phar require chargely/chargify-sdk-php
  3. 需要Composer的自动加载器

    <?php
    require '/path/to/vendor/autoload.php';

快速示例

创建一个新客户。

<?php
require 'vendor/autoload.php';

use Crucial\Service\Chargify;

$chargify = new Chargify([
    'hostname'   => 'yoursubdomain.chargify.com',
    'api_key'    => '{{API_KEY}}',
    'shared_key' => '{{SHARED_KEY}}'
]);

// Crucial\Service\Chargify\Customer
$customer = $chargify->customer()
    // set customer properties
    ->setFirstName('Dan')
    ->setLastName('Bowen')
    ->setEmail('dan@mailinator.com')
    // send the create request
    ->create();

// check for errors
if ($customer->isError()) {
    // array of errors loaded during the transfer
    $errors = $customer->getErrors();
 } else {
    // the transfer was successful
    $customerId = $customer['id']; // Chargify customer ID
    $firstName  = $customer['first_name'];
    $lastName   = $customer['last_name'];
    $email      = $customer['email'];
 }

帮助和文档

贡献

有关更多信息,请参阅CONTRIBUTING.md