Skip to content

Instantly share code, notes, and snippets.

@iannsp
Last active August 29, 2015 13:57
Show Gist options
  • Save iannsp/9840920 to your computer and use it in GitHub Desktop.
Save iannsp/9840920 to your computer and use it in GitHub Desktop.
A study/usage case for Ecomz\Payment Bundle
<?php
$config = new Config();
// empty configuration just for example
$config->fromArray(array());
$payment = new Payment($config);
/* this is a BankBillet payment Operation using the Supported Service Provider named PaymentProvider. The obligatory data are the UPPERCASE ONE's.
always need a client identifier, so CLIENTID
always need a Service Provider, so PROVIDER (initial configuration can provide a default provider)
always need a Service Provider Method for perform the payment, so METHOD (example: BankBillet, CreditCard, DebitCard)
*/
$operation = array(
'PROVIDER'=>'PaymentProvider',
'METHOD'=>'Boleto',
'value'=>150.00,
'duedate'=>'2014-05-13',
'CLIENTID'=>4250,
'TRANSACTIONID'=>42424242
);
$operationDescriptor = new Container();
$operationDescriptor->fromArray($operation);
try{
// exceptions can be: Method not supported, Provider not supported, Perform Failure
$response = $payment->request($operationDescriptor);
}catch(\Ecomz\Payment\Exception $E){
$myPersistentService = new PersistentService();
$myPersistentService->paymentResponse($response);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment