This is a composer package that aims to encapsulate most of the server side set needed when integrating your site to the Mula express checkout. Features included:
- Encryption
- Decryption
- Response formatting. (Returns the format expected by the payment callback. Visit Mula express checkout documentation for more on this.)
This is a composer package and can thus pull it in by adding;
"mula/express-checkout": "dev-master"
to your composer.json require
object and running
composer update
Before you send your parameters to the express checkout, you are required to encrypt them so as to protect your data from being read or changed by any man-in-the-middle attacks.
...
// Build the mula express checkout payload.
$mulaPayload = (new RequestProcessor(
config('IV_KEY'),
config('KEY'),
config('ACCESS_KEY'),
config('COUNTRY_CODE')
))->process($parameterArray)
...
The payload has the following structure;
...
array(
'PARAMS' => $encrypted, // The encrypted parameter string
'ACCESS_KEY' => $access_key, // The merchant's access key
'COUNTRY_CODE' => $country_code // The merchant's country code
);
...
When the express checkout is sending the payment details for you to acknowledge the payments, the details are encrypted and thus you need to decrypt the passed encrypted string to get the payment details.
...
// Decrypt the payload from the express checkout web hook integration.
$data = (new ResponseProcessor(
config('IV_KEY'),
config('KEY')
))->process($passedEncryptedString);
...
Please make sure you protect your access, secret and iv keys from the public as they may be used to masquerade as you to your customers and/ or used to intercept between your communication with mula Express checkout.