PHP code example of lunarphp / opayo
1. Go to this page and download the library: Download lunarphp/opayo 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/ */
lunarphp / opayo example snippets
// ...
'opayo' => [
'vendor' => env('OPAYO_VENDOR'),
'env' => env('OPAYO_ENV', 'test'),
'key' => env('OPAYO_KEY'),
'password' => env('OPAYO_PASSWORD'),
'host' => env('OPAYO_HOST'),
],
return [
// ...
'types' => [
'card' => [
// ...
'driver' => 'opayo',
],
],
];
Lunar\Opayo\Facades\Opayo::getMerchantKey();
$response = \Lunar\Facades\Payments::driver('opayo')->cart(
$cart = CartSession::current()->calculate()
)->withData([
'merchant_key' => $request->get('merchantSessionKey'),
'card_identifier' => $request->get('cardToken'),
'browserLanguage' => $request->get('browserLanguage'),
'challengeWindowSize' => $request->get('challengeWindowSize'),
'browserIP' => $request->ip(),
'browserAcceptHeader' => $request->header('accept'),
'browserUserAgent' => $request->get('browserUserAgent'),
'browserJavaEnabled' => $request->get('browserJavaEnabled', false),
'browserColorDepth' => $request->get('browserColorDepth'),
'browserScreenHeight' => $request->get('browserScreenHeight'),
'browserScreenWidth' => $request->get('browserScreenWidth'),
'browserTZ' => $request->get('browserTZ'),
'status' => 'payment-received',
])->authorize();
if (is_a($response, \Lunar\Opayo\Responses\ThreeDSecureResponse::class)) {
return response()->json([
'
$response = Payments::driver('opayo')->cart(
$cart = CartSession::current()->calculate()
)->withData([
'cres' => $request->get('cres'),
'pares' => $request->get('pares'),
'transaction_id' => $request->get('transaction_id'),
])->threedsecure();
if (! $response->success) {
abort(401);
}
$response = \Lunar\Facades\Payments::driver('opayo')->cart(
$cart = CartSession::current()->calculate()
)->withData([
// ...
'saveCard' => true
])->authorize();
$response = \Lunar\Facades\Payments::driver('opayo')->cart(
$cart = CartSession::current()->calculate()
)->withData([
// ...
'card_identifier' => $request->get('cardToken'),
'reusable' => true
])->authorize();