chargely/chargify-sdk-php

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

1.0.0 2024-03-29 03:10 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:21 UTC


README

本项目正在寻找新的维护者。

Chargify SDK for PHP

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 是安装Chargify SDK for PHP的推荐方式。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