$ composer require jm/balancedpayment-bundle dev-master
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Jm\BalancedPaymentBundle\JmBalancedPaymentBundle(),
);
}
# app/config/config.yml
jm_balanced_payment:
api_key: 'BALANCED API KEY'
user_class: Acme\UserBundle\Entity\User
marketplace_user_id: '1'
doctrine_listener: true
There are 3 parameters required to configured the bundle.
It's the Balanced Payment API key we need to interact with them.
CreditCard, BankAccount and BalancedPayment are attached to an user. We need to know your application user entity class (for example Acme\CoreBundle\Entity\User)
This is your marketplace user ID. Payment are done between 2 users. For example a debit is set from a user X (->setFromUser(X)) to this marketplace user id (->setToUser(marketplace_user_id)) and inverse for debit.
Activate the Doctrine listener which keep CreditCard and BankAccount transparently in sync with BalancedPayment: https://github.com/jeremymarc/JmBalancedPaymentBundle/blob/master/Doctrine/Listener/PaymentSourceListener.php
You need to configure Doctrine to map the BalancedUserInterface to your user class:
# app/config/config.yml
doctrine:
orm:
resolve_target_entities:
Jm\BalancedPaymentBundle\Entity\BalancedUserInterface: Acme\UserBundle\Entity\User
Your User class must implements Jm\BalancedPaymentBundle\Entity\BalancedUserInterface : https://github.com/jeremymarc/JmBalancedPaymentBundle/blob/master/Entity/BalancedUserInterface.php
To update your application schema, just run the command :
./app/console doctrine:schema:update --force
That's it. You can now use the bundle.