PHP code example of tamkeen-tech / laravel-payfort
1. Go to this page and download the library: Download tamkeen-tech/laravel-payfort 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/ */
Payfort::tokenization(
1000, # Bill amount
'redirect_url', # the recirect to url after tokenization
true # either to return form html or not (optional)
);
$response = Payfort::purchase(
[], # Request body coming from the tokenization
100, # Bill amount
'[email protected]', # User email
'redirect_url', # The return back url after purchase
[] # installment data (optional)
);
$response = Payfort::authorize(
[], # Request body coming from the tokenization
100, # Bill amount
'[email protected]', # User email
'redirect_url' # The return back url after purchase
);
if ($response->should3DsRedirect()) {
return redirect()->away($response->get3DsUri());
}
$response->getResponseFortId();
$response->getResponsePaymentMethod()
Payfort::processResponse(
[] # the response array
);
$response->getResponseFortId();
$response->getResponsePaymentMethod()
Payfort::capture(
'fort_id', # fort id for the payment transaction
100.0 # bill amount
);
Payfort::void(
'fort_id' # fort id for the payment transaction
);
Payfort::refund(
'fort_id', # fort id for the payment transaction
1000 # amount to be reunded must not exceed the bill amount
);
Payfort::setMerchantExtra('test')->tokenization(
1000, # Bill amount
'redirect_url', # the recirect to url after tokenization
true # either to return form html or not (optional)
);
Payfort::applePay(
[], # fort params (please make sure to match the fort params mentioned below)
1000, # bill amount
'[email protected]', # User email
'PURCHASE', # command to be sent to apple pay either PURCHASE or AUTHORIZE
);