Skip to content

Commit 842ea2e

Browse files
mahesa814mahesa nugraha
andauthored
feat(snap bca): add function in has transaction (#7)
* feat(snap bca): add function in has transaction transfer-rtgs,sknbi,bi-fast,internal account inquiry,externnal account inquiry, transaction status inquiry * docs(doc block): function --------- Co-authored-by: mahesa nugraha <mahesa.nugraha@rakhasa.com>
1 parent 25e09a0 commit 842ea2e

File tree

1 file changed

+308
-0
lines changed

1 file changed

+308
-0
lines changed

src/Services/BCA/Traits/HasTransaction.php

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,312 @@ public static function directDebitPaymentStatus(): HttpResponseInterface
116116
->withHeaders($headers)
117117
->post($url, $body);
118118
}
119+
120+
/**
121+
* this is function transfer rtgs
122+
* @return HttpResponseInterface
123+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
124+
* @throws \Otnansirk\SnapBI\Exception\HttpException
125+
*/
126+
public static function transferRTGS(): HttpResponseInterface
127+
{
128+
// Required access token
129+
self::authenticated();
130+
$path = "/openapi/v1.0/transfer-rtgs";
131+
132+
$timestamp = currentTimestamp()->toIso8601String();
133+
$accessToken = self::$token;
134+
135+
$body = array_merge([
136+
"partnerReferenceNo" => Uuid::uuid4(),
137+
], self::$body);
138+
139+
$headers = array_merge([
140+
'X-TIMESTAMP' => $timestamp,
141+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
142+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
143+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
144+
'X-EXTERNAL-ID' => int_rand(16),
145+
], self::$headers);
146+
147+
$url = BcaConfig::get('base_url') . $path;
148+
return Http::withToken($accessToken)
149+
->withHeaders($headers)
150+
->post($url, $body);
151+
}
152+
153+
/**
154+
* This service is used to transfer SKNBI.
155+
* @return HttpResponseInterface
156+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
157+
* @throws \Otnansirk\SnapBI\Exception\HttpException
158+
*/
159+
public static function transferSKNBI(): HttpResponseInterface
160+
{
161+
// Required access token
162+
self::authenticated();
163+
$path = "/openapi/v1.0/transfer-skn";
164+
165+
$timestamp = currentTimestamp()->toIso8601String();
166+
$accessToken = self::$token;
167+
168+
$body = array_merge([
169+
"partnerReferenceNo" => Uuid::uuid4(),
170+
"sourceAccountNo" => BcaConfig::get('source_account_no')
171+
], self::$body);
172+
173+
$headers = array_merge([
174+
'X-TIMESTAMP' => $timestamp,
175+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
176+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
177+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
178+
'X-EXTERNAL-ID' => int_rand(16),
179+
], self::$headers);
180+
181+
$url = BcaConfig::get('base_url') . $path;
182+
return Http::withToken($accessToken)
183+
->withHeaders($headers)
184+
->post($url, $body);
185+
}
186+
187+
/**
188+
* This service is used to transfer intrabank.
189+
* means that the transfer is made within the same bank network
190+
* @return HttpResponseInterface
191+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
192+
* @throws \Otnansirk\SnapBI\Exception\HttpException
193+
*/
194+
public static function transferIntraBank(): HttpResponseInterface
195+
{
196+
// Required access token
197+
self::authenticated();
198+
$path = "/openapi/v1.0/transfer-intrabank";
199+
200+
$timestamp = currentTimestamp()->toIso8601String();
201+
$accessToken = self::$token;
202+
203+
$body = array_merge([
204+
"partnerReferenceNo" => Uuid::uuid4(),
205+
"sourceAccountNo" => BcaConfig::get('source_account_no'),
206+
], self::$body);
207+
208+
$headers = array_merge([
209+
'X-TIMESTAMP' => $timestamp,
210+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
211+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
212+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
213+
'X-EXTERNAL-ID' => int_rand(16),
214+
], self::$headers);
215+
216+
$url = BcaConfig::get('base_url') . $path;
217+
return Http::withToken($accessToken)
218+
->withHeaders($headers)
219+
->post($url, $body);
220+
}
221+
222+
223+
/**
224+
* This service is used to transfer interbank online.
225+
* meaning that the sender uses a different Bank network to transfer to the receiver
226+
* @return HttpResponseInterface
227+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
228+
* @throws \Otnansirk\SnapBI\Exception\HttpException
229+
*/
230+
public static function transferInterBankONL(): HttpResponseInterface
231+
{
232+
// Required access token
233+
self::authenticated();
234+
$path = "/openapi/v2.0/transfer-interbank";
235+
236+
$timestamp = currentTimestamp()->toIso8601String();
237+
$accessToken = self::$token;
238+
239+
$body = array_merge([
240+
"partnerReferenceNo" => Uuid::uuid4(),
241+
"sourceAccountNo" => BcaConfig::get("source_account_no"),
242+
], self::$body);
243+
244+
$headers = array_merge([
245+
'X-TIMESTAMP' => $timestamp,
246+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
247+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
248+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
249+
'X-EXTERNAL-ID' => int_rand(16),
250+
], self::$headers);
251+
252+
$url = BcaConfig::get('base_url') . $path;
253+
return Http::withToken($accessToken)
254+
->withHeaders($headers)
255+
->post($url, $body);
256+
}
257+
258+
/**
259+
* This service is used to internal account inquiry.
260+
* @return HttpResponseInterface
261+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
262+
* @throws \Otnansirk\SnapBI\Exception\HttpException
263+
*/
264+
public static function internalAccountInquiry(): HttpResponseInterface
265+
{
266+
// Required access token
267+
self::authenticated();
268+
$path = "/openapi/v1.0/account-inquiry-internal";
269+
270+
$timestamp = currentTimestamp()->toIso8601String();
271+
$accessToken = self::$token;
272+
273+
$body = array_merge([
274+
"partnerReferenceNo" => Uuid::uuid4(),
275+
], self::$body);
276+
277+
$headers = array_merge([
278+
'X-TIMESTAMP' => $timestamp,
279+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
280+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
281+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
282+
'X-EXTERNAL-ID' => int_rand(16),
283+
], self::$headers);
284+
285+
$url = BcaConfig::get('base_url') . $path;
286+
return Http::withToken($accessToken)
287+
->withHeaders($headers)
288+
->post($url, $body);
289+
}
290+
291+
/**
292+
* This service is used to internal account inquiry.
293+
* @return HttpResponseInterface
294+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
295+
* @throws \Otnansirk\SnapBI\Exception\HttpException
296+
*/
297+
public static function accountInquiryExternal(): HttpResponseInterface
298+
{
299+
// Required access token
300+
self::authenticated();
301+
$path = "/openapi/v1.0/account-inquiry-external";
302+
303+
$timestamp = currentTimestamp()->toIso8601String();
304+
$accessToken = self::$token;
305+
306+
$body = array_merge([
307+
"partnerReferenceNo" => Uuid::uuid4()
308+
], self::$body);
309+
310+
$headers = array_merge([
311+
'X-TIMESTAMP' => $timestamp,
312+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
313+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
314+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
315+
'X-EXTERNAL-ID' => int_rand(16),
316+
], self::$headers);
317+
318+
$url = BcaConfig::get('base_url') . $path;
319+
return Http::withToken($accessToken)
320+
->withHeaders($headers)
321+
->post($url, $body);
322+
}
323+
324+
/**
325+
* This service is used to inquiry status transaction.
326+
* @return HttpResponseInterface
327+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
328+
* @throws \Otnansirk\SnapBI\Exception\HttpException
329+
*/
330+
public static function inquiryStatusTransaction(): HttpResponseInterface
331+
{
332+
// Required access token
333+
self::authenticated();
334+
$path = "/openapi/v1.0/balance-inquiry";
335+
336+
$timestamp = currentTimestamp()->toIso8601String();
337+
$accessToken = self::$token;
338+
339+
$body = array_merge([
340+
"originalPartnerReferenceNo" => Uuid::uuid4()
341+
], self::$body);
342+
343+
$headers = array_merge([
344+
'X-TIMESTAMP' => $timestamp,
345+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
346+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
347+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
348+
'X-EXTERNAL-ID' => int_rand(16),
349+
], self::$headers);
350+
351+
$url = BcaConfig::get('base_url') . $path;
352+
return Http::withToken($accessToken)
353+
->withHeaders($headers)
354+
->post($url, $body);
355+
}
356+
357+
/**
358+
* This service is used to balance inquiry.
359+
* @return HttpResponseInterface
360+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
361+
* @throws \Otnansirk\SnapBI\Exception\HttpException
362+
*/
363+
public static function balanceInquiry(): HttpResponseInterface
364+
{
365+
// Required access token
366+
self::authenticated();
367+
$path = "/openapi/v1.0/balance-inquiry";
368+
369+
$timestamp = currentTimestamp()->toIso8601String();
370+
$accessToken = self::$token;
371+
372+
$body = array_merge([
373+
"partnerReferenceNo" => Uuid::uuid4(),
374+
"accountNo" => BcaConfig::get('account_id'),
375+
"bankCardToken" => BcaConfig::get('bank_card_token'),
376+
],
377+
self::$body);
378+
379+
$headers = array_merge([
380+
'X-TIMESTAMP' => $timestamp,
381+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
382+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
383+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
384+
'X-EXTERNAL-ID' => int_rand(16),
385+
], self::$headers);
386+
387+
$url = BcaConfig::get('base_url') . $path;
388+
return Http::withToken($accessToken)
389+
->withHeaders($headers)
390+
->post($url, $body);
391+
}
392+
393+
/**
394+
* This service is used to transfer Bi fast.
395+
* @return HttpResponseInterface
396+
* @throws \Otnansirk\SnapBI\Exception\AuthenticateException
397+
* @throws \Otnansirk\SnapBI\Exception\HttpException
398+
*/
399+
public static function transferBIFAST(): HttpResponseInterface
400+
{
401+
// Required access token
402+
self::authenticated();
403+
$path = "/openapi/v2.0/transfer-interbank";
404+
405+
$timestamp = currentTimestamp()->toIso8601String();
406+
$accessToken = self::$token;
407+
408+
$body = array_merge([
409+
"partnerReferenceNo" => Uuid::uuid4(),
410+
"sourceAccountNo" => BcaConfig::get('source_account_no'),
411+
],
412+
self::$body);
413+
414+
$headers = array_merge([
415+
'X-TIMESTAMP' => $timestamp,
416+
'X-SIGNATURE' => Signature::symmetric(BcaConfig::class, 'POST', $path, $body, $timestamp, $accessToken),
417+
'CHANNEL-ID' => BcaConfig::get('channel_id'),
418+
'X-PARTNER-ID' => BcaConfig::get('partner_id'),
419+
'X-EXTERNAL-ID' => int_rand(16),
420+
], self::$headers);
421+
422+
$url = BcaConfig::get('base_url') . $path;
423+
return Http::withToken($accessToken)
424+
->withHeaders($headers)
425+
->post($url, $body);
426+
}
119427
}

0 commit comments

Comments
 (0)