PHP code example of devinweb / payment
1. Go to this page and download the library: Download devinweb/payment 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/ */
devinweb / payment example snippets
Devinweb\Payment\PaymentServiceProvider::class,
'Payment' => Devinweb\Payment\Facades\Payment::class,
'payfort' => [
'callback_urls' => [
'error-page' => '/api/error',
'success-page' => '/api/success',
],
'sandboxMode' => env('PAYFORT_SAND_BOX_MODE', true),
/**
* language used to specify the response language returned from payfort
*/
'language' => env('LANGUAGE', 'en'),
/**
* your Merchant Identifier account (mid)
*/
'merchantIdentifier' => env('MERCHANT_IDENTIFIER', ''),
/**
* your access code
*/
'accessCode' => env('ACCESS_CODE', ''),
/**
* SHA Request passphrase
*/
'SHARequestPhrase' => env('SHA_REQUEST_PASSPHRASE', ''),
/**
* SHA Response passphrase
*/
'SHAResponsePhrase' => env('SHA_RESPONSE_PASSPHRASE', ''),
/**
* SHA Type (Hash Algorith)
* expected Values ("sha1", "sha256", "sha512")
*/
'SHAType' => env('SHA_TYPE', 'sha256'),
/**
* command
* expected Values ("AUTHORIZATION", "PURCHASE")
*/
'command' => env('COMMAND', 'AUTHORIZATION'),
/**
* order currency
*/
'currency' => env('CURRENCY', 'USD'),
]
// App\Config\payments.php
// you can configure you callback routes here
'payfort' => [
'callback_urls' => [
'error-page' => '', // redirection to error page
'success-page' => '', // redirection to success page
],
// ...
]
use Illuminate\Http\Request;
Route::post('/payment', function (Request $request) {
// ...
$merchant_reference = rand(0, getrandmax());
return Payment::use('payfort', $merchant_reference)->pay();
});
$request->add([
'amount' => '',
'email' => '',
'hold_name' => ''
])
'payfort_apple_pay' => [
'sandboxMode' => true,
'language' => 'ar',
'merchantIdentifier' => '',
'accessCode' => '',
'SHARequestPhrase' => '',
'SHAResponsePhrase' => '',
'SHAType' => 'sha256',
'command' => 'PURCHASE',
'currency' => 'SAR',
]
return Payment::use('payfort_apple_pay', $merchant_reference)->pay();
return Payment::use('payfort')->viaReactNative()->pay();
use Illuminate\Http\Request;
Route::match(['get', 'post'], '/payfort-callback', function(Request $request) {
return Payment::use('payfort')->webHook();
});
[
"response_code" => "18000",
"card_number" => "400555******0001",
"card_holder_name" => "CUSTOMER_HOLDER_NAME",
"signature" => "d641d71c13da959cba92371d70c686b602e2b62796dfca5286c760c6b5d9e3b1",
"merchant_identifier" => "YOUR_MERCHANT_IDENTIFIER",
"expiry_date" => "2105",
"access_code" => "YOUR_ACCESS_CODE",
"language" => "ar",
"service_command" => "TOKENIZATION",
"response_message" => "عملية ناجحة",
"merchant_reference" => "278245857",
"token_name" => "dced12c0eeeb444185dcc450b917d987",
"return_url" => "YOUR_RETURN_URL"
"card_bin" => "400555"
"status" => "18"
]
[
"response_code" => "00016",
"card_number" => "400550******0001",
"card_holder_name" => "CUSTOMER_HOLDER_NAME",
"signature" => "signature_value",
"merchant_identifier" => "YOUR_MERCHANT_IDENTIFIER",
"expiry_date" => "2105",
"access_code" => "YOUR_ACCESS_CODE",
"language" => "ar",
"service_command" => "TOKENIZATION",
"response_message" => "رقم البطاقة غير صحيح",
"merchant_reference" => "158151963",
"return_url" => "YOUR_RETURN_URL",
"status" => "00",
"error_msg" => "رقم البطاقة غير صحيح",
]
bash
php artisan vendor:publish --provider="Devinweb\Payment\PaymentServiceProvider" --tag="config"