Introducing litwicki/chargify-bundle

This implementation leverages an object-oriented approach to replicating all of the entities available via the API. From there, each of the Model entities are manipulated with Handlers that allow full control of the entire API layer.

As of this post, v1 is the only integrated support, but v2 (Chargify Direct) is being developed as I write this.

Installation

Follow installation instructions on the repository README

Usage

<?php

//use statements
use Litwicki\Bundle\ChargifyBundle\Model\Customer;

public function showCustomersAction(Request $request)
{
    //check permissions and stuff here..

    $handler = $this->container->get('litwicki_chargify.handler.customers');

    //$customers is an array of customer objects
    $customers = $handler->findAll();

    //do stuff, return to twig, or return as json
}

public function newCustomerAction(Request $request)
{
    //Create the Customer object
    $customer = new Customer();
    $customer->setFirstName('John');
    $customer->setLastName('Doe');
    $customer->setEmail('john.doe@gmail.com'):
    $customer->setReference($customer->getEmail());
    
    //Load the Customer Handler service
    $handler = $this->container->get('litwicki_chargify.handler.customers');

    //Save the customer object, and repopulate with all auto generated fields
    $customer = $handler->create($customer);

}

Full Documentation

Full documentation can be found here: Litwicki Chargify Bundle Documentation

Categories: Random

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *