Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
NafezlyDotCom committed Oct 17, 2022
1 parent ca7dac0 commit e1469b2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ return [
#KASHIER
'KASHIER_ACCOUNT_KEY' => env('KASHIER_ACCOUNT_KEY'),
'KASHIER_IFRAME_KEY' => env('KASHIER_IFRAME_KEY'),
'KASHIER_TOKEN' => env('KASHIER_TOKEN'),
'KASHIER_URL' => env('KASHIER_URL', "https://checkout.kashier.io"),
'KASHIER_MODE' => env('KASHIER_MODE', "test"), //live or test
'KASHIER_CURRENCY'=>env('KASHIER_CURRENCY',"EGP"),
Expand Down Expand Up @@ -163,6 +164,7 @@ $payment->verify($request);
//outputs
[
'success'=>true,//or false
'payment_id'=>"PID",
'message'=>"Done Successfully",//message for client
'process_data'=>""//payment response
]
Expand Down
1 change: 1 addition & 0 deletions config/nafezly-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#KASHIER
'KASHIER_ACCOUNT_KEY' => env('KASHIER_ACCOUNT_KEY'),
'KASHIER_IFRAME_KEY' => env('KASHIER_IFRAME_KEY'),
'KASHIER_TOKEN' => env('KASHIER_TOKEN'),
'KASHIER_URL' => env('KASHIER_URL', "https://checkout.kashier.io"),
'KASHIER_MODE' => env('KASHIER_MODE', "test"), //live or test
'KASHIER_CURRENCY'=>env('KASHIER_CURRENCY',"EGP"),
Expand Down
30 changes: 27 additions & 3 deletions src/Classes/KashierPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Nafezly\Payments\Classes;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Nafezly\Payments\Interfaces\PaymentInterface;
use Nafezly\Payments\Classes\BaseController;

Expand All @@ -12,6 +13,7 @@ class KashierPayment extends BaseController implements PaymentInterface
public $kashier_mode;
private $kashier_account_key;
private $kashier_iframe_key;
private $kashier_token;
public $app_name;
private $verify_route_name;

Expand All @@ -21,6 +23,7 @@ public function __construct()
$this->kashier_mode = config("nafezly-payments.KASHIER_MODE");
$this->kashier_account_key = config("nafezly-payments.KASHIER_ACCOUNT_KEY");
$this->kashier_iframe_key = config("nafezly-payments.KASHIER_IFRAME_KEY");
$this->kashier_token = config("nafezly-payments.KASHIER_TOKEN");
$this->currency = config('nafezly-payments.KASHIER_CURRENCY');
$this->app_name = config('nafezly-payments.APP_NAME');
$this->verify_route_name = config('nafezly-payments.VERIFY_ROUTE_NAME');
Expand Down Expand Up @@ -90,22 +93,43 @@ public function verify(Request $request): array
if ($signature == $request["signature"]) {
return [
'success' => true,
'payment_id'=>$request['transactionId'],
'payment_id'=>$request['merchantOrderId'],
'message' => __('nafezly::messages.PAYMENT_DONE'),
'process_data' => $request->all()
];
} else {
return [
'success' => false,
'payment_id'=>$request['transactionId'],
'payment_id'=>$request['merchantOrderId'],
'message' => __('nafezly::messages.PAYMENT_FAILED'),
'process_data' => $request->all()
];
}
}else if($request['signature']==null){
$url_mode = $this->kashier_mode == "live"?'':'test-';
$response = Http::withHeaders([
'Authorization' => $this->kashier_token
])->get('https://'.$url_mode.'api.kashier.io/payments/orders/'.$request['merchantOrderId'])->json();
if(isset($response['response']['status']) && $response['response']['status']=="CAPTURED"){
return [
'success' => true,
'payment_id'=>$request['merchantOrderId'],
'message' => __('nafezly::messages.PAYMENT_DONE'),
'process_data' => $request->all()
];
}else{
return [
'success' => false,
'payment_id'=>$request['merchantOrderId'],
'message' => __('nafezly::messages.PAYMENT_FAILED'),
'process_data' => $request->all()
];
}

} else {
return [
'success' => false,
'payment_id'=>$request['transactionId'],
'payment_id'=>$request['merchantOrderId'],
'message' => __('nafezly::messages.PAYMENT_FAILED'),
'process_data' => $request->all()
];
Expand Down

0 comments on commit e1469b2

Please sign in to comment.