litwicki/chargify-bundle

Chargify计费服务集成

安装: 52

依赖项: 0

建议者: 0

安全性: 0

星标: 2

关注者: 1

分支: 4

开放问题: 0

类型:symfony-bundle

dev-master 2018-11-06 22:23 UTC

This package is not auto-updated.

Last update: 2024-09-22 03:52:24 UTC


README

一个旨在通过他们的API无缝集成到Chargify的包。

Development Status Seeking Maintainers License Symfony PHP

Build Accessibility Simplicity Bugs

设置

安装和配置需要三个简单步骤。

1. 下载包

重要 由于处于早期开发阶段,您需要将您的 minimum-stability 设置为 dev-master 以使用此包。

$ composer require "litwicki/chargify-bundle"

2. 启用包

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Litwicki\Bundle\ChargifyBundle\LitwickiChargifyBundle(),
        );

        // ...
    }
}

3. 配置包

# app/config/config.yml
litwicki_chargify:
    test_mode: false
    data_format: json
    route_prefix: /chargify
    domain: ~
    api_key: ~
    shared_key: ~

可选地,您可以包括Chargify Direct(API V2)的集成

# app/config/config.yml
litwicki_chargify:
    # ...
    direct:
        api_id: ~
        api_secret: ~
        api_password: ~

4. 序列化

为了通过API处理对象,需要序列化,因此您需要确保已启用序列化器。

如果没有,您可以按照这些说明进行操作

# app/config/config.yml
framework:
    # ...
    serializer:
        enabled: true

# app/config/services.yml
services:
    # ...
    get_set_method_normalizer:
        class: Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
        tags:
            - { name: serializer.normalizer }

使用方法

此包作为您的Symfony应用程序和Chargify之间的中间层。每个实体的处理程序利用可用的RESTful操作。

请确保参考Chargify API文档以了解每个对象的可用参数。

GET - 查找一个对象。

//example load a Subscription by Id.
$id = 12345;
$handler = $this->get('chargify.handler.subscription');
$subscription = $handler->get($id);

POST - 创建一个新的对象。

//let's create an example customer
$data = array(
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => 'john.doe@example.com'
);

$handler = $this->get('chargify.handler.customer');
$customer = $handler->post($data);

PUT - 更新一个现有对象。

让我们更新我们刚刚创建的客户记录(如上例所示)。

//...
$customer->setFirstName('Jonathan');
$customer = $handler->put($customer);

DELETE - 删除一个对象。

我们改变了主意,让我们删除这个客户。

$response = $handler->delete($customer);

贡献

感谢您考虑为此包做出贡献!此包处于早期开发阶段,正在积极寻找维护者。

我对以下方面的帮助特别感兴趣

  • 测试所有事物
  • 识别和修补任何安全问题
  • 持续支持和改进

进行中项目

  • 开发v2 API层(处理程序)以处理调用、注册和卡片更新
  • 强制所有提交都通过表单验证
  • 设置序列化组,以便在序列化完整实体时,只通过POST或PUT提交只读字段。

许可

此包是开源软件,受MIT许可的许可。