File tree Expand file tree Collapse file tree 2 files changed +49
-6
lines changed
Expand file tree Collapse file tree 2 files changed +49
-6
lines changed Original file line number Diff line number Diff line change 3030 "summary" : " Start a transaction" ,
3131 "description" : " Start a transaction using the given parameters" ,
3232 "operationId" : " start" ,
33+ "headers" : {
34+ "Signature" : {
35+ "$ref" : " #/components/headers/Signature"
36+ }
37+ },
3338 "requestBody" : {
3439 "description" : " The transaction object you would like to start." ,
3540 "required" : true ,
4651 "description" : " Success response" ,
4752 "headers" : {
4853 "Signature" : {
49- "description" : " The signature created by the SimplePay back-end." ,
50- "schema" : {
51- "type" : " string"
52- }
54+ "$ref" : " #/components/headers/Signature"
5355 }
5456 },
5557 "content" : {
104106 }
105107 }
106108 }
109+ },
110+ "/finish" : {
111+ "post" : {}
107112 }
108113 },
109114 "components" : {
115+ "headers" : {
116+ "Signature" : {
117+ "description" : " The signature created by the SimplePay back-end." ,
118+ "schema" : {
119+ "type" : " string" ,
120+ "example" : " 3WGqCnWJArhA224xVdUY1fPh91tpd6va6JvBrPNuHK449TZTgsRn3DBu5UBGbcTn"
121+ }
122+ }
123+ },
124+ "parameters" : {
125+
126+ },
110127 "schemas" : {
111128 "Transaction" : {
112129 "required" : [
Original file line number Diff line number Diff line change 44
55class Client
66{
7+ /**
8+ * The client version.
9+ */
10+ public const VERSION = '1.0.0 ' ;
11+
712 /**
813 * Create a new SimplePay Client instance.
914 */
10- public function __construct (protected string $ merchantId , protected string $ secretKey )
11- {
15+ public function __construct (
16+ protected string $ merchantId ,
17+ protected string $ secretKey ,
18+ protected bool $ sandbox = false
19+ ) {
1220 // $this->config()->setApiKey('X-API-KEY', $apiKey);
1321 }
1422
23+ /**
24+ * Sign the given data.
25+ */
26+ public function sign (string $ data ): string
27+ {
28+ return base64_encode (
29+ hash_hmac ('sha384 ' , $ data , $ this ->secretKey , true )
30+ );
31+ }
32+
33+ /**
34+ * Validate the signature.
35+ */
36+ public function validateSignature (string $ hash , string $ data ): bool
37+ {
38+ return hash_equals ($ hash , $ this ->sign ($ data ));
39+ }
40+
1541 /**
1642 * Get the configuration instance.
1743 */
You can’t perform that action at this time.
0 commit comments