This is implementation of a library to process SISP https://www.sisp.cv/ vinti4 https://www.vinti4.cv/ payment in a easy way.
Download the project folder on your project. Or install it using composer:
composer require faxi-online/sisp-php:dev-main
Import the library file;
include "../Sisp.php";
Or include the composer autoload
include "vendor/autoload.php";
Create the transaction object from the Sisp class. You can pass three parameters:
- Your POS Id/Identifier
- The respective POS authentication code
- The VBV api URL, and it is set by default as "https://mc.vinti4net.cv/BizMPIOnUsSisp", remember to define it value in production, without the path "/CardPayment" because it will be added automatically according the transaction code
use Faxi\Sisp;
$payment = new Sisp(
"90000045",
"kfyhhKJH875ndu44"
);
Generate your transaction id, it can be max of 15 characters, after a successful payment you should not reuse that id for new transaction.
// sample to generate id from timestamp
$transaction_id = "T" . date('YmdHms');
You can generate the HTML form by calling the buyForm method. It receives three parameters:
- The transaction Id, you will receive it in the transaction callback
- The amount of the transaction
- The callback url, the transaction result will be sent to here
$buyForm = $payment->buyForm(
$transaction_id,
1000,
"http://localhost/sisp-php/src/Faxi/samples/callback-buy.php"
);
Just put that form in your HTML page and submit it by calling document.forms[0].submit();
<html>
<head>
<title>Do payment</title>
</head>
<body>
<div>
<h5>Do payment</h5>
<?= $buyForm ?>
<button onclick="startTransaction()">
Start Transaction
</button>
</div>
<script>
function startTransaction()
{
document.forms[0].submit();
}
</script>
</body>
</html>
After submitted the form, you should be redirect to a page like the below.
To process callback result we should use the method onTransactionResult, it receive three parameters:
- The success callback function
- The error callback function
- The cancellation callback function
$payment = new Sisp(
"90000045",
"kfyhhKJH875ndu44"
);
$payment->onTransactionResult(
// success callback
function ($transaction_id, $clearingPeriod, $sisp_transaction_id){
echo "<p>Payment sucessfully for $transaction_id</p>";
// save clearingPeriod and sisp_transaction_id
// you will need them to do refund later
echo "<p>merchantRespCP: " . $clearingPeriod. "</p>";
echo "<p>merchantRespTid: " . $sisp_transaction_id . "</p>";
},
// error callback
function ($transaction_id, $errorDescription, $errorDetail, $errorAdditionalMessage){
echo "<p>Error on transaction $transaction_id</p>";
echo "<p>Error: description $errorDescription</p>";
echo "<p>Error: detail $errorDetail</p>";
echo "<p>Error: additional $errorAdditionalMessage</p>";
},
// cancellation callback
function (){
echo "<p>Transaction cancelled</p>";
}
);
You can generate the HTML form by calling the phoneRechargeForm method. It receives five parameters:
- The transaction Id, you will receive it in the transaction callback, it can be max of 15 characters
- The amount of the transaction
- The phone number you want to recharge
- The operator id (it will be provided by SISP)
- The callback url, the transaction result will be sent to here
$buyForm = $payment->phoneRechargeForm(
$transaction_id,
1000,
9112233,
2,
"http://localhost/sisp-php/src/Faxi/samples/callback-buy.php"
);
You can generate the HTML form by calling the servicePaymentForm method. It receives five parameters:
- The transaction Id, you will receive it in the transaction callback, it can be max of 15 characters
- The amount of the transaction
- The reference number of the bill you want to pay
- The enity id (it will be provided by SISP)
- The callback url, the transaction result will be sent to here
$buyForm = $payment->servicePaymentForm(
$transaction_id,
1000,
"123456789",
"6",
"http://localhost/sisp-php/src/Faxi/samples/callback-buy.php"
);
Call the refundForm method. It receives five parameters:
- The transaction Id, you will receive it in the transaction callback, it can be max of 15 characters, (It must not be the same as the transaction to be refunded)
- The amount to be refunded
- The clearing period number of transaction that is being refunded, it is received in transaction result
- The SISP transaction id received in transaction result
- The callback url, the refund result will be sent to here
$transaction_id = "T" . date('YmdHms');
$refundForm = $payment->refundForm(
$transaction_id,
1000,
1765,
76133,
"http://localhost/sisp-php/src/Faxi/samples/callback-refund.php"
);
To handle the refund result you must do the following code.
$payment->onRefundResult(
// success callback
function ($transaction_id){
echo "<p>Refunded done for $transaction_id</p>";
},
// error callback
function ($transaction_id, $errorDescription, $errorDetail, $errorAdditionalMessage){
echo "<p>Error on refund for $transaction_id</p>";
echo "<p>Error: description $errorDescription</p>";
echo "<p>Error: detail $errorDetail</p>";
echo "<p>Error: additional $errorAdditionalMessage</p>";
},
// cancellation callback
function (){
echo "<p>Refund cancelled</p>";
}
);
If you want you can change the language of payment form presented to user, it supports en and pt.
$payment->lang = "pt";