Omnipay: Pesapal
Skeleton gateway for the Omnipay PHP payment processing library, (*1)
, (*2)
Omnipay is a framework agnostic, multi-gateway payment
processing library for PHP 5.3+. This package implements pesapal support for Omnipay., (*3)
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what
PSRs you support to avoid any confusion with users and contributors., (*4)
Install
Via Composer, (*5)
``` bash
$ composer require fruitcakestudio/omnipay-pesapal:"1.x@alpha", (*6)
## Usage
The following gateways are provided by this package:
* Pesapal
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository.
## Example
bootstrap.php
```php
require 'vendor/autoload.php';
$gateway = \Omnipay\Omnipay::create('Pesapal');
$gateway->initialize(array(
'key' => 'your-consumer-key',
'secret' => 'your-consumer-secret',
'testMode' => false,
));
purchase.php, (*7)
require 'bootstrap.php';
// Make a purchase request
$response = $gateway->purchase(array(
'amount' => "6.84",
'description' => "Testorder #1234",
'currency' => 'USD',
'card' => array(
'email' => 'barry@fruitcakestudio.nl',
'firstName' => 'Barry',
'lastName' => 'vd. Heuvel',
'phone' => '+1234567890',
),
'returnUrl' => 'http://my-domain.com/return.php',
))->send();
$transactionId = $response->getTransactionId();
if ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo "Error " .$response->getCode() . ': ' . $response->getMessage();
}
return.php, (*8)
require 'bootstrap.php';
// Check the payment status
$response = $gateway->completePurchase()->send();
// Show status to user
if ($response->isSuccessful()) {
echo "Transaction '" . $response->getTransactionId() . "' succeeded!";
} else {
echo "Status: " .$response->getCode() . ': ' . $response->getMessage();
}
notify.php, (*9)
require 'bootstrap.php';
// Check the payment status
$response = $gateway->completePurchase()->send();
$reference = $response->getTransactionReference(); // TODO; Check the reference/id with your database
$transactionId = $response->getTransactionId();
if($response->isSuccessful()){
// Save state
}
// Return message for the gateway
echo $response->getNotificationMessage(); // Or ->getNotificationResponse() for Symfony Response
The transactionReference is pesapal_transaction_tracking_id, which is set by Pesapal.
The transactionId is your own id (pesapal_merchant_reference), which will be generated if not provided., (*10)
See the documentation on http://developer.pesapal.com/how-to-integrate/step-by-step, (*11)
Sandbox / Demo
When you set testMode to true, the Demo sandbox will be used., (*12)
You need a different consumer key/secret. Follow these steps to use the testMode:, (*13)
- Create a business account on http://demo.pesapal.com/
- Login to your demo account, the key/secret are on the dashboard.
- Start a transaction and send dummy money
- Use the same phonenumber (eg.
700123456) and amount. Copy the confirmation code after submitting.
Support
If you are having general issues with Omnipay, we suggest posting on
Stack Overflow. Be sure to add the
omnipay tag so it can be easily found., (*14)
If you want to keep up to date with release anouncements, discuss ideas for the project,
or ask more detailed questions, there is also a mailing list which
you can subscribe to., (*15)
If you believe you have found a bug, please report it using the GitHub issue tracker,
or better yet, fork the library and submit a pull request., (*16)
Change log
Please see CHANGELOG for more information what has changed recently., (*17)
Testing
bash
$ composer test, (*18)
Contributing
Please see CONTRIBUTING for details., (*19)
Security
If you discover any security related issues, please email info@fruitcake.nl instead of using the issue tracker., (*20)
Credits
License
The MIT License (MIT). Please see License File for more information., (*21)