lunarphp / opayo
Opayo payment driver for Lunar.
Installs: 1 616
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Type:project
Requires
- php: ^8.2
- lunarphp/core: 1.0.0-beta.6
- dev-main
- 1.x-dev
- 1.0.x-dev
- 1.0.0-beta.6
- 1.0.0-beta.5
- 1.0.0-beta.4
- 1.0.0-beta.3
- 1.0.0-beta.2
- 1.0.0-beta.1
- 1.0.0-alpha.37
- 1.0.0-alpha.36
- 1.0.0-alpha.35
- 1.0.0-alpha.34
- 1.0.0-alpha.33
- 1.0.0-alpha.32
- 1.0.0-alpha.31
- 1.0.0-alpha.30
- 1.0.0-alpha.29
- 1.0.0-alpha.28
- 1.0.0-alpha.27
- 1.0.0-alpha.26
- 1.0.0-alpha.25
- 1.0.0-alpha.24
- 1.0.0-alpha.23
- 1.0.0-alpha.22
- 1.0.0-alpha.21
- 1.0.0-alpha.20
- 1.0.0-alpha.19
- 1.0.0-alpha.18
- 1.0.0-alpha.17
- 1.0.0-alpha.16
- 1.0.0-alpha.15
- 1.0.0-alpha.14
- 1.0.0-alpha.13
- 1.0.0-alpha.12
- 1.0.0-alpha.11
- 1.0.0-alpha.10
- 1.0.0-alpha.9
- 1.0.0-alpha.8
- 1.0.0-alpha.7
- 1.0.0-alpha.6
- 1.0.0-alpha.5
- 1.0.0-alpha.4
- 1.0.0-alpha.3
- 1.0.0-alpha.2
- 1.0.0-alpha.1
- 0.x-dev
- 0.8.x-dev
- 0.8.0
- 0.7.x-dev
- 0.7.0
- 0.6.x-dev
- 0.6.0
- 0.5.x-dev
- 0.5.0
- 0.4.x-dev
- 0.4.0
- 0.3.x-dev
- 0.3.0
- 0.2.x-dev
- 0.2.0
- 0.2-rc1
- 0.1.x-dev
- 0.1.0-rc.1
- dev-1.0.0-alpha
- dev-1.0.0-beta
- dev-alecritson-patch-1
- dev-feat/stripe-refactor
- dev-namespace-update
This package is auto-updated.
Last update: 2024-12-20 00:00:40 UTC
README
This addon enables Opayo payments on your Lunar storefront.
Alpha Release
This addon is currently in Alpha, whilst every step is taken to ensure this is working as intended, it will not be considered out of Alpha until more tests have been added and proved.
Minimum Requirements
- Lunar
1.x
- An Elavon merchant account
Installation
Require the composer package
composer require lunarphp/opayo
Configure the service
Add the opayo config to the config/services.php
file.
// ... 'opayo' => [ 'vendor' => env('OPAYO_VENDOR'), 'env' => env('OPAYO_ENV', 'test'), 'key' => env('OPAYO_KEY'), 'password' => env('OPAYO_PASSWORD'), 'host' => env('OPAYO_HOST'), ],
Enable the driver
Set the driver in config/lunar/payments.php
<?php return [ // ... 'types' => [ 'card' => [ // ... 'driver' => 'opayo', ], ], ];
Configuration
Below is a list of the available configuration options this package uses in config/lunar/opayo.php
Backend Usage
Get a merchant key
Lunar\Opayo\Facades\Opayo::getMerchantKey();
Authorize a charge
$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();
When authorizing a charge, you may be required to submit extra authentication in the form of 3DSV2, you can handle this in your payment endpoint.
if (is_a($response, \Lunar\Opayo\Responses\ThreeDSecureResponse::class)) { return response()->json([ 'requires_auth' => true, 'data' => $response, ]); }
$response
will contain all the 3DSV2 information from Opayo.
You can find more information about this using the following links:
- 3-D Secure explained
- 3D Secure Transactions
- Stack overflow SagePay 3D Secure V2 Flow
Once you have handled the 3DSV2 response on your storefront, you can then authorize again.
$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); }
Opayo card tokens
When authenticated users make an order on your store, it can be good to offer the ability to save their card information for future use. Whilst we don't store the actual card details, we can use card tokens which represent the card the user has used before.
You must have saved payments enabled on your Opayo account because you can use these.
To save a card, pass in the saveCard
data key when authorizing a payment.
$response = \Lunar\Facades\Payments::driver('opayo')->cart( $cart = CartSession::current()->calculate() )->withData([ // ... 'saveCard' => true ])->authorize();
Assuming everything went well, there will be a new entry in the opayo_tokens
table, associated to the authenticated user. You can then display these card representations at checkout for the user to select. The token
is what replaces the card_identifier
data key.
$response = \Lunar\Facades\Payments::driver('opayo')->cart( $cart = CartSession::current()->calculate() )->withData([ // ... 'card_identifier' => $request->get('cardToken'), 'reusable' => true ])->authorize();
Responses are then handled the same as any other transaction.
Contributing
Contributions are welcome, if you are thinking of adding a feature, please submit an issue first so we can determine whether it should be included.