Unofficial BoaCompra billing PHP library
, (*1)
This package is compliant with PSR-1, PSR-2 and PSR-4. If you notice compliance oversights,
please send a patch via pull request., (*2)
Requirements
The following versions of PHP are supported:, (*3)
- PHP 5.4
- PHP 5.5
- PHP 5.6
- PHP 7
- HHVM
The following extensions are also required:, (*4)
Usage
Create a payment
``` php
$vsi = new VirtualStoreIdentification($yourStoreId, $yourSecretKey);, (*5)
try {
$endUser = new EndUser('me@example.com');
$endUser->setName('John Doe')
// ...
->setLanguage('en_US');, (*6)
$payment = new Payment(
$vsi,
$endUser,
$yourReturnUrl,
$yourNotifyUrl,
$yourCurrencyIso,
$yourOrderId,
$orderDescription,
$amount // without dot or comma (ie: 500 for $5.00)
);
$payment->setTestMode(1)
->setProjectId(1)
->setPaymentId(1);
} catch (\Exception $e) {
// Log or anything ...
}, (*7)
$form = new PaymentFormGenerator($payment);, (*8)
// Then in your HTML code, just call :
$form->render();, (*9)
### Validate BoaCompra notification
``` php
try {
// $payment is your previously set Payment object
$notif = new PaymentNotification(
$payment,
$_POST['store_id'],
$_POST['transaction_id'],
$_POST['order_id'],
$_POST['amount'],
$_POST['currency_code'],
$_POST['payment_id'],
$_SERVER['REMOTE_ADDR']
);
$postback = new PaymentPostBack($notif);
$postback->validatePayment();
return 'Ok !';
} catch (\Exception $e) {
return 'Error validating the payment : '.$e->getMessage();
}
Check the status of a payment
``` php
try {
$notif = new PaymentNotification(
$payment,
$storeId,
$transactionId,
$orderId,
$amount,
$currencyCode,
$paymentId
);
$status = new PaymentCheckStatus($notif);
$status->validatePayment();
return 'Ok !';
} catch (\Exception $e) {
return 'Error validating the payment : '.$e->getMessage();
}, (*10)
## API
The API documentation is available on [Github Pages](http://benoth.github.io/boa-compra/api/Benoth/BoaCompra.html)
## Testing
``` bash
$ vendor/bin/phpunit
License
The MIT License (MIT). Please see License File for more information., (*11)