|
@@ -8,10 +8,14 @@ use Illuminate\Http\Request;
|
8
|
8
|
use Illuminate\Support\Facades\Response as Res;
|
9
|
9
|
use MirfalahTech\Laravel\Payment\Contracts\PayableEntity;
|
10
|
10
|
use MirfalahTech\Laravel\Payment\Contracts\PaymentGatewayDriver;
|
|
11
|
+use MirfalahTech\Laravel\Payment\Facade\Payment;
|
|
12
|
+use MirfalahTech\Laravel\Payment\Traits\BillStatusBoolean;
|
11
|
13
|
use Symfony\Component\HttpFoundation\Response;
|
12
|
14
|
|
13
|
15
|
class SenangPayDriver implements PaymentGatewayDriver
|
14
|
16
|
{
|
|
17
|
+ use BillStatusBoolean;
|
|
18
|
+
|
15
|
19
|
/**
|
16
|
20
|
* @var string
|
17
|
21
|
*/
|
|
@@ -43,22 +47,34 @@ class SenangPayDriver implements PaymentGatewayDriver
|
43
|
47
|
$amount = sprintf('%0.2f', $amount);
|
44
|
48
|
$hash = md5($this->secret_key.$detail.$amount.$order_id);
|
45
|
49
|
|
46
|
|
- return "$this->endpoint/payment/$this->merchant_id?'".
|
|
50
|
+ return "$this->endpoint/payment/$this->merchant_id?".
|
47
|
51
|
http_build_query(compact('detail', 'order_id', 'amount', 'hash'));
|
48
|
52
|
}
|
49
|
53
|
|
50
|
54
|
public function verifyGatewayReturn(Request $request): bool
|
51
|
55
|
{
|
52
|
|
- return true;
|
|
56
|
+ $hash = $request->query->get('hash');
|
|
57
|
+ return $hash == $this->computeHash($request->request->all());
|
53
|
58
|
}
|
54
|
59
|
|
55
|
60
|
public function verifyGatewayCallback(Request $request, Response &$response = null): bool
|
56
|
61
|
{
|
57
|
62
|
$response = Res::make('OK');
|
58
|
|
- return true;
|
|
63
|
+ $hash = $request->request->get('hash');
|
|
64
|
+ return $hash == $this->computeHash($request->request->all());
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ public function getBillIdFromRequest(Request $request): ?string{
|
|
68
|
+ return $request->get('order_id');
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ public function getBillStatus(Request $request): ?int
|
|
72
|
+ {
|
|
73
|
+ return $request->request->get('status') == 1 ? Payment::SUCCESS : Payment::PENDING;
|
59
|
74
|
}
|
60
|
75
|
|
61
|
|
- public function getBillIdFromRequest(Request $request){
|
62
|
|
- return $request->query->get('order_id');
|
|
76
|
+ public function computeHash($payload){
|
|
77
|
+ $payload['hash'] = '[HASH]';
|
|
78
|
+ return md5($this->secret_key.'?'.http_build_query($payload));
|
63
|
79
|
}
|
64
|
80
|
}
|