require_once(PATH_TO_RKFL.'../src/WEBHOOK_CLASS.php');
use RKFL\Client\WEBHOOK_CLASS as rkflWebhook
/**
* $_REQUEST wont work because the webhook is application/json format and not formdata format
*/
$payload = file_get_contents('php://input'); //use for receiving payload from RKFL SERVER
$payload = json_decode($payload);
$result = rkflWebhook::verify_callback($payload->data->data, $payload->signature);
if ($result) {
echo "verified \n";
} else {
echo 'not verified';
return;
}
rkflWebhook::validate_payment($payload->data);
FRONTEND
Once we get the response with the UUID from the backend. We will initialise an object of the above included script. We pass the following :
After initialising the object, start the payment by calling the initPayment method of the above script.
function startPayment(){
rkfl.initPayment();
}
Callback payload
// In case of Bank/Exchange payment
{
paymentMode: 'Bank/Exchange',
txn_id:
status:
meta:
},
Sample response:
{
paymentMode: 'Bank/Exchange',
txn_id: "7df55d22-fa5e-4ca2-9af4-a39c95f18b3a"
status: 0
meta: {offerId: "1630402767550"}
},
// In case of Wallet payment
{
paymentMode: 'Wallet',
status:
recievedAmount:
currency:
},
Sample response:
{
paymentMode: 'Wallet',
status:"completed",
recievedAmount:10.00,
currency:"ETH"
}
SSO Login
### JS Code snippet
var merchantAuth = function(merchantId) {
var buffer = Buffer.from(merchantId);
var encrypted = crypto.publicEncrypt(process.env.PUBLIC_KEY, buffer);
return encrypted.toString("base64");
}
RKFL Token usage
Autosignup
const payload = {
firstName: firstName,
lastName, lastName,
email: email,
merchantAuth: "<%= merchantAuth %>",
}
rkfl = new RocketFuel({ environment: "<%= developmentEnv %>", });
rkfl.rkflAutoSignUp(payload, environment = "<%= developmentEnv %>").then((res) => {
// save this rkflToken for reference in the DB
// It is unique to each customer
res.result.rkflToken;
})})
The environment refers to the type of details you are using. You should choose production for real transactions and select sandbox when you are testing.
You can also retrieve Merchant Id from the same page. Simply scroll up on the settings page and copy from the section highlighted below