· 6 years ago · Mar 15, 2019, 02:46 AM
1<?php
2$apikey = 'efffd49a-46fe-40f1-ac6b-ad85132f49de';
3$secretkey = '9705e364-3d14-407a-957e-d4a3804f5295';
4$oauthid = 'a89d924d-1bed-4b3b-b38b-2c211d87bf0c';
5$oauthsecretkey = '3656d8f9-8d53-468f-bd9e-fd347b2e94f8';
6$encode = base64_encode($oauthid.':'.$oauthsecretkey);
7$startdate = $_GET['date_awal'];
8$enddate = $_GET['date_akhir'];
9$amount = $_GET['amount'];
10
11$curl = curl_init();
12
13curl_setopt_array($curl, array(
14 CURLOPT_URL => "https://sandbox.bca.co.id/api/oauth/token",
15 CURLOPT_RETURNTRANSFER => true,
16 CURLOPT_ENCODING => "",
17 CURLOPT_MAXREDIRS => 10,
18 CURLOPT_TIMEOUT => 30,
19 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
20 CURLOPT_CUSTOMREQUEST => "POST",
21 CURLOPT_POSTFIELDS => "grant_type=client_credentials&undefined=",
22 CURLOPT_HTTPHEADER => array(
23 "Authorization: Basic ".$encode,
24 "Content-Type: application/x-www-form-urlencoded"
25 ),
26));
27
28$response = curl_exec($curl);
29$err = curl_error($curl);
30
31curl_close($curl);
32
33if ($err) {
34 echo "cURL Error #:" . $err;
35} else {
36 echo $response;
37 $decode=json_decode($response,1);
38 echo "<pre>";
39 print_r($decode);
40if (isset($decode['access_token'])) {
41 $token=$decode['access_token'];
42 date_default_timezone_set("Asia/Bangkok");
43 $waktu=date('Y-m-d\TH:i:s.000P');
44 $signature='GET:'."/banking/v3/corporates/BCAAPI2016/accounts/0201245680/statements?EndDate=".$enddate."&StartDate=".$startdate."&TransactionAmount=".$amount.":".$token.":".hash('sha256', '').":".$waktu;
45 $signfinal=hash_hmac('sha256', $signature, $secretkey);
46 $curl2 = curl_init();
47 curl_setopt_array($curl2, array(
48 CURLOPT_URL => "https://sandbox.bca.co.id/banking/v3/corporates/BCAAPI2016/accounts/0201245680/statements?StartDate=".$startdate."&EndDate=".$enddate."&TransactionAmount=".$amount,
49 CURLOPT_RETURNTRANSFER => true,
50 CURLOPT_ENCODING => "",
51 CURLOPT_MAXREDIRS => 10,
52 CURLOPT_TIMEOUT => 30,
53 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
54 CURLOPT_CUSTOMREQUEST => "GET",
55 CURLOPT_HTTPHEADER => array(
56 "Authorization: Bearer ".$token,
57 "Content-Type: application/json",
58 "Origin: dropshipaja.com",
59 "X-BCA-Key:".$apikey,
60 "X-BCA-Timestamp:".$waktu,
61 "X-BCA-Signature:".$signfinal
62 ),
63));
64$response2 = curl_exec($curl2);
65$err2 = curl_error($curl2);
66
67curl_close($curl2);
68$decode2=json_decode($response2,1);
69print_r($decode2);
70}
71
72}
73
74for($i=0;$i<count($bola);$i++){
75
76 if($bola[$i][1]=="bolasepak"){
77 $status="tidak ada";
78 for($j=0;$j<count($warna);$j++){
79 if($bola[$i][0]==$warna[$j]){
80 $status="ada";
81 break;
82 }
83 }
84 if ($status=="tidak ada"){
85 $warna[$indexwarna]=$bola[$i][0];
86 $indexwarna++;
87 }
88 }
89
90}