Symfony 2 Bundle for Braintree's PHP client library
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
DependencyInjection
Exception
Factory Added phpDoc May 7, 2013
Resources/config Created the Braintree bundle May 7, 2013
spec/CometCult/BraintreeBundle Created the Braintree bundle May 7, 2013
.gitignore
.travis.yml
CometCultBraintreeBundle.php Created the Braintree bundle May 7, 2013
README.md
composer.json

README.md

CometCultBraintreeBundle

Build Status Scrutinizer Quality Score

Symfony 2 Bundle for Braintree's PHP client library

Installation

Composer

Just add to your composer.json file:

{
    "require": {
        "cometcult/braintree-bundle": "dev-master"
    }
}

Application Kernel

Add the bundle to your application's kernel:

// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new CometCult\BraintreeBundle\CometCultBraintreeBundle(),
        // ...
    );
}

Configuration

# app/config/config.yml
# ...
comet_cult_braintree:
  environment: sandbox
  merchant_id: your_merchant_id
  public_key: your_public_key
  private_key: your_private_key

For more info about the configuration variables see Braintree docs

Usage

Braintree php client library comes with a bunch of services for the Braintree API. They are usually prefixed by Braintree_. To see all available Braintree services head over to braintree_php or the official documentation.

Factory

One of the methods for getting a desired service is to call the get method from the BraintreeFactory:

// in your controller
$factory = $this->get('comet_cult_braintree.factory');
$customerService = $factory->get('customer');

Defining a service

Instead of calling the factory you can define a custom service in your own bundle:

# ../services.yml
services:
    customer_custom_service:
        class:            Braintree_Customer
        factory_service:  comet_cult_braintree.factory
        factory_method:   get
        arguments: ["customer"]

Then in your controller you can go with:

$customerService = $this->get('customer_custom_service');