1+ <?php
2+
3+ namespace Otnansirk \SnapBI \Services \BCA \Traits ;
4+
5+ use Otnansirk \SnapBI \Interfaces \HttpResponseInterface ;
6+ use Otnansirk \SnapBI \Services \BCA \BcaConfig ;
7+ use Otnansirk \SnapBI \Support \Signature ;
8+ use Otnansirk \SnapBI \Support \Http ;
9+
10+
11+ trait HasVirtualAccount
12+ {
13+
14+ /**
15+ * This service is used to VA BillPresentment.
16+ *
17+ * @return HttpResponseInterface
18+ */
19+ public static function vaInquiry (): HttpResponseInterface
20+ {
21+ // Required access token
22+ self ::authenticated ();
23+ $ path = "/openapi/v1.0/transfer-va/inquiry " ;
24+
25+ $ timestamp = currentTimestamp ()->toIso8601String ();
26+ $ accessToken = self ::$ token ;
27+
28+ $ body = array_merge (BcaConfig::defaultBody (), self ::$ body );
29+
30+ $ headers = array_merge (
31+ BcaConfig::defaultHeaders (),
32+ [
33+ 'X-TIMESTAMP ' => $ timestamp ,
34+ 'X-SIGNATURE ' => Signature::symmetric (BcaConfig::class, 'POST ' , $ path , $ body , $ timestamp , $ accessToken ),
35+ ],
36+ self ::$ headers
37+ );
38+
39+ $ url = BcaConfig::get ('base_url ' ) . $ path ;
40+ return Http::withToken ($ accessToken )
41+ ->withHeaders ($ headers )
42+ ->post ($ url , $ body );
43+ }
44+
45+ /**
46+ * This service is used to VA Payment Status.
47+ *
48+ * @return HttpResponseInterface
49+ */
50+ public static function vaInquiryStatus (): HttpResponseInterface
51+ {
52+ // Required access token
53+ self ::authenticated ();
54+ $ path = "/openapi/v1.0/transfer-va/status " ;
55+
56+ $ timestamp = currentTimestamp ()->toIso8601String ();
57+ $ accessToken = self ::$ token ;
58+
59+ $ body = array_merge (BcaConfig::defaultBody (), self ::$ body );
60+
61+ $ headers = array_merge (
62+ BcaConfig::defaultHeaders (),
63+ [
64+ 'X-TIMESTAMP ' => $ timestamp ,
65+ 'X-SIGNATURE ' => Signature::symmetric (BcaConfig::class, 'POST ' , $ path , $ body , $ timestamp , $ accessToken ),
66+ ],
67+ self ::$ headers
68+ );
69+
70+ $ url = BcaConfig::get ('base_url ' ) . $ path ;
71+ return Http::withToken ($ accessToken )
72+ ->withHeaders ($ headers )
73+ ->post ($ url , $ body );
74+ }
75+
76+ /**
77+ * This service is used to VA Payment Flag.
78+ *
79+ * @return HttpResponseInterface
80+ */
81+ public static function vaPayment (): HttpResponseInterface
82+ {
83+ // Required access token
84+ self ::authenticated ();
85+ $ path = "/openapi/v1.0/transfer-va/payment " ;
86+
87+ $ timestamp = currentTimestamp ()->toIso8601String ();
88+ $ accessToken = self ::$ token ;
89+
90+ $ body = array_merge (BcaConfig::defaultBody (), self ::$ body );
91+
92+ $ headers = array_merge (
93+ BcaConfig::defaultHeaders (),
94+ [
95+ 'X-TIMESTAMP ' => $ timestamp ,
96+ 'X-SIGNATURE ' => Signature::symmetric (BcaConfig::class, 'POST ' , $ path , $ body , $ timestamp , $ accessToken ),
97+ ],
98+ self ::$ headers
99+ );
100+
101+ $ url = BcaConfig::get ('base_url ' ) . $ path ;
102+ return Http::withToken ($ accessToken )
103+ ->withHeaders ($ headers )
104+ ->post ($ url , $ body );
105+ }
106+
107+ /**
108+ * This service is used to VA transfer BillPresentment.
109+ *
110+ * @return HttpResponseInterface
111+ */
112+ public static function vaInquiryIntrabank (): HttpResponseInterface
113+ {
114+ // Required access token
115+ self ::authenticated ();
116+ $ path = "/openapi/v1.0/transfer-va/inquiry-intrabank " ;
117+
118+ $ timestamp = currentTimestamp ()->toIso8601String ();
119+ $ accessToken = self ::$ token ;
120+
121+ $ body = array_merge (BcaConfig::defaultBody (), self ::$ body );
122+
123+ $ headers = array_merge (
124+ BcaConfig::defaultHeaders (),
125+ [
126+ 'X-TIMESTAMP ' => $ timestamp ,
127+ 'X-SIGNATURE ' => Signature::symmetric (BcaConfig::class, 'POST ' , $ path , $ body , $ timestamp , $ accessToken ),
128+ ],
129+ self ::$ headers
130+ );
131+
132+ $ url = BcaConfig::get ('base_url ' ) . $ path ;
133+ return Http::withToken ($ accessToken )
134+ ->withHeaders ($ headers )
135+ ->post ($ url , $ body );
136+ }
137+
138+ /**
139+ * SNAP Virtual Account Payment to VA from Intrabank
140+ * This service is used to VA transfer.
141+ *
142+ * @return HttpResponseInterface
143+ */
144+ public static function vaPayIntrabank (): HttpResponseInterface
145+ {
146+ // Required access token
147+ self ::authenticated ();
148+ $ path = "/openapi/v1.0/transfer-va/payment-intrabank " ;
149+
150+ $ timestamp = currentTimestamp ()->toIso8601String ();
151+ $ accessToken = self ::$ token ;
152+
153+ $ body = array_merge (BcaConfig::defaultBody (), self ::$ body );
154+
155+ $ headers = array_merge (
156+ BcaConfig::defaultHeaders (),
157+ [
158+ 'X-TIMESTAMP ' => $ timestamp ,
159+ 'X-SIGNATURE ' => Signature::symmetric (BcaConfig::class, 'POST ' , $ path , $ body , $ timestamp , $ accessToken ),
160+ ],
161+ self ::$ headers
162+ );
163+
164+ $ url = BcaConfig::get ('base_url ' ) . $ path ;
165+ return Http::withToken ($ accessToken )
166+ ->withHeaders ($ headers )
167+ ->post ($ url , $ body );
168+ }
169+
170+ /**
171+ * This service is used to Notification VA transfer.
172+ *
173+ * @return HttpResponseInterface
174+ */
175+ public static function vaNotifyPayIntrabank (): HttpResponseInterface
176+ {
177+ // Required access token
178+ self ::authenticated ();
179+ $ path = "/openapi/v1.0/transfer-va/notify-payment-intrabank " ;
180+
181+ $ timestamp = currentTimestamp ()->toIso8601String ();
182+ $ accessToken = self ::$ token ;
183+
184+ $ body = array_merge (BcaConfig::defaultBody (), self ::$ body );
185+
186+ $ headers = array_merge (
187+ BcaConfig::defaultHeaders (),
188+ [
189+ 'X-TIMESTAMP ' => $ timestamp ,
190+ 'X-SIGNATURE ' => Signature::symmetric (BcaConfig::class, 'POST ' , $ path , $ body , $ timestamp , $ accessToken ),
191+ ],
192+ self ::$ headers
193+ );
194+
195+ $ url = BcaConfig::get ('base_url ' ) . $ path ;
196+ return Http::withToken ($ accessToken )
197+ ->withHeaders ($ headers )
198+ ->post ($ url , $ body );
199+ }
200+
201+ }
0 commit comments