Skip to content

Commit

Permalink
==== BREAKING CHANGES ====
Browse files Browse the repository at this point in the history
- Rename MESOMB_API_KEY env property to MESOMB_APP_KEY
- Add MESOMB_SSL_VERIFY in env to disable ssl verification on http request
  • Loading branch information
hachther committed Nov 30, 2023
1 parent f0209a9 commit cae7222
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hachther/laravel-mesomb",
"description": "A laravel wrapper on top of Mesomb Payment API",
"license": "MIT",
"version": "1.7.1",
"version": "1.7.2",
"authors": [
{
"name": "Hachther LLC",
Expand Down
13 changes: 6 additions & 7 deletions config/mesomb.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
* MeSomb Application Key
* Copy from https://mesomb.hachther.com/en/applications/{id}
*/
'key' => env('MESOMB_API_KEY'),

/*
* MeSomb API Application Key
* Copy from https://mesomb.hachther.com/en/applications/{id}
*/
'api_key' => env('MESOMB_API_KEY'),
'app_key' => env('MESOMB_APP_KEY'),

/*
* MeSomb Access Key
Expand All @@ -36,6 +30,11 @@
*/
'secret_key' => env('MESOMB_SECRET_KEY'),

/*
* Set MESOMB_SSL_VERIFY to false if you want to run your http request without verification
*/
'ssl_verify' => env('MESOMB_SSL_VERIFY', true),

/*
* Number of second to wait before timeout a transaction
*/
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ Setting the following parameters from MeSomb

Get the below information from MeSomb after followed the above tutorial.
```dotenv
MESOMB_API_KEY=<ApplicationKey>
MESOMB_APP_KEY=<ApplicationKey>
MESOMB_API_HOST=https://mesomb.hachther.com
MESOMB_API_VERSION=v1.1
MESOMB_ACCESS_KEY=<AccessKey>
MESOMB_SECRET_KEY=<SecretKey>
MESOMB_SSL_VERIFY=true
```

Publish configurations file
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Payment/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function status()
*/
public static function checkStatus(): array
{
$applicationKey = config('mesomb.api_key');
$applicationKey = config('mesomb.app_key');
$url = self::generateURL('status/');
$date = new DateTime();
$nonce = "";
Expand Down
15 changes: 12 additions & 3 deletions src/Operation/Payment/Collect.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public function pay(): ?PaymentModel
{
$data = $this->prepareData();
$data['source'] = 'Laravel/v'.\app()->version();
$ip = request()->ip();
if (empty($data['location'])) {
$data['location'] = array(
'ip' => $ip
);
}
$nonce = Signature::nonceGenerator();
$date = new \DateTime();
$url = $this->generateURL();
Expand All @@ -139,14 +145,17 @@ public function pay(): ?PaymentModel
'x-mesomb-nonce' => $nonce,
'Authorization' => $authorization,
'Content-Type' => 'application/json',
'X-MeSomb-Application' => config('mesomb.key'),
'X-MeSomb-Application' => config('mesomb.app_key'),
'X-MeSomb-OperationMode' => config('mesomb.mode'),
'X-MeSomb-TrxID' => $this->paymentModel->id,
];

$response = Http::withHeaders($headers)
->timeout(config('mesomb.timeout'))
->post($url, $data);
->timeout(config('mesomb.timeout'));
if (!config('mesomb.ssl_verify')) {
$response = $response->withoutVerifying();
}
$response = $response->post($url, $data);

if ($response->failed()) {
$this->handleException($response);
Expand Down
14 changes: 11 additions & 3 deletions src/Operation/Payment/Deposit.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public function pay(): DepositModel
{
$data = $this->prepareData();
$data['source'] = 'Laravel/v'.\app()->version();
$ip = request()->ip();
if (empty($data['location'])) {
$data['location'] = array(
'ip' => $ip
);
}
$nonce = Signature::nonceGenerator();
$date = new \DateTime();
$url = $this->generateURL();
Expand All @@ -142,9 +148,11 @@ public function pay(): DepositModel
];

$response = Http::withHeaders($headers)
->timeout(config('mesomb.timeout'))
->post($url, $data);

->timeout(config('mesomb.timeout'));
if (!config('mesomb.ssl_verify')) {
$response = $response->withoutVerifying();
}
$response = $response->post($url, $data);

if ($response->failed()) {
$this->handleException($response);
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Payment/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function checkStatus($model)
$url = self::generateURL('transactions/', $ids);
$date = new DateTime();
$nonce = "";
$applicationKey = config('mesomb.api_key');
$applicationKey = config('mesomb.app_key');

$authorization = SignedRequest::getAuthorization('GET', $url, $date, $nonce);

Expand Down

0 comments on commit cae7222

Please sign in to comment.