1. Go to this page and download the library: Download paynow/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paynow / php-sdk example snippets
o stuff
o stuff
$paynow = new Paynow\Payments\Paynow(
'INTEGRATION_ID',
'INTEGRATION_KEY',
'http://example.com/gateways/paynow/update',
// The return url can be set at later stages. You might want to do this if you want to pass data to the return url (like the reference of the transaction)
'http://example.com/return?gateway=paynow'
);
// Passing in the name of the item and the price of the item
$payment->add('Bananas', 2.50);
$payment->add('Apples', 3.40);
// Save the response from paynow in a variable
$response = $paynow->send($payment);
if($response->success()) {
// Redirect the user to Paynow
$response->redirect();
// Or if you prefer more control, get the link to redirect the user to, then use it as you see fit
$link = $response->redirectLink();
// Get the poll url (used to check the status of a transaction). You might want to save this in your DB
$pollUrl = $response->pollUrl();
}
// Save the response from paynow in a variable
$response = $paynow->sendMobile($payment, '077777777', 'ecocash');
if($response->success()) {
// Get the poll url (used to check the status of a transaction). You might want to save this in your DB
$pollUrl = $response->pollUrl();
// Get the instructions
$instrutions = $response->instructions();
}
// Check the status of the transaction with the specified pollUrl
// Now you see why you need to save that url ;-)
$status = $paynow->pollTransaction($pollUrl);
if($status->paid()) {
// Yay! Transaction was paid for
} else {
print("Why you no pay?");
}
$paynow = new Paynow\Payments\Paynow(
'INTEGRATION_ID',
'INTEGRATION_KEY',
'http://example.com/gateways/paynow/update',
// The return url can be set at later stages. You might want to do this if you want to pass data to the return url (like the reference of the transaction)
'http://example.com/return?gateway=paynow'
);
# $paynow->setResultUrl('');
# $paynow->setReturnUrl('');
$payment = $paynow->createPayment('Invoice 35', '[email protected]');
$payment->add('Sadza and Beans', 1.25);
$response = $paynow->send($payment);
if($response->success()) {
// Redirect the user to Paynow
$response->redirect();
// Or if you prefer more control, get the link to redirect the user to, then use it as you see fit
$link = $response->redirectLink();
$pollUrl = $response->pollUrl();
// Check the status of the transaction
$status = $paynow->pollTransaction($pollUrl);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.