JezK
Edit File: tripay.php
<?php global $wpdb; $tb_booking = $wpdb->prefix . 'bookingan'; $tb_konfirmasi = $wpdb->prefix . 'konfirmasi'; //--- Tripay Callback/Notifikasi if ($redirect == 'notification') { date_default_timezone_set('Asia/Jakarta'); $dataJSON = file_get_contents('php://input'); $notif = json_decode($dataJSON, TRUE); $trx_time = date('Y-m-d H:i:s',$notif['paid_at']); $trx_id = $notif['reference']; $invoice = $notif['merchant_ref']; $paystatus = $notif['status']; $channel = $notif['payment_method']; $channel_code = $notif['payment_method_code']; $ammount = number_format($notif['total_amount'],0,',','.'); $is_ammount = 'Rp '.$ammount; $fee_merchant = $notif['fee_merchant']; $fee_customer = $notif['fee_customer']; $fee = $notif['total_fee']; $received = $notif['amount_received']; $gateway_notice = 'Pembayaran diverifikasi otomatis oleh sistem (Tripay)'; $timestamp = current_time('mysql'); $etime = current_time('d M Y h:i a'); $tanggal = current_time('d M Y'); $x = $wpdb->get_row( "SELECT * FROM $tb_booking WHERE invoice = '$invoice'" ); $nama = $x->nama1_cust.' '.$x->nama2_cust; $email_cust = $x->email_cust; $nohp = $x->hp_cust; $dp = $x->dp; $status = $x->status; // Status PAID if ($paystatus == 'PAID') { // ubah status booking (dp paid) if ($dp != '100' && $status == 'unpaid') { $sql = $wpdb->query(" UPDATE $tb_booking SET status = 'dp', payment = 'tripay', paystatus = 'dp-paid', dp_paydata = '$trx_time|$trx_id|$channel|DP $dp%' WHERE invoice = '$invoice' "); $pesan_cust = 'Down Payment '.$dp.'%<br>'.$gateway_notice; $is_dp = 'DP '.$dp.'%'; } else { // ubah status booking (full paid) $sql = $wpdb->query(" UPDATE $tb_booking SET dp = '100', status = 'paid', payment = 'tripay', paystatus = 'paid', paydata = '$trx_time|$trx_id|$channel|$gateway_notice' WHERE invoice = '$invoice' "); $pesan_cust = 'Full Payment<br>'.$gateway_notice; $is_dp = false; } if($sql) { // insert data konfirmasi (verified) $wpdb->insert( $tb_konfirmasi, array( 'time' => $timestamp, 'etime' => $etime, 'nama_cust' => $nama, 'email_cust' => $email_cust, 'hp_cust' => $nohp, 'pesan_cust' => $pesan_cust, 'invoice' => $invoice, 'txn_id' => $trx_id, 'tgl_transfer' => $tanggal, 'jmlh_transfer' => $ammount, 'rek_tujuan' => $channel, 'imgcode' => 'tripay', 'status' => 'verified', ) ); // kirim notifikasi pembayaran valid include(get_template_directory().'/functions/notifikasi/pay-paid.php'); } exit(json_encode(['success' => true])); } // How to pay Tripay } else if ($redirect == 'howtopay' && $invoice) { $x = $wpdb->get_row( "SELECT * FROM $tb_booking WHERE invoice = '$invoice'" ); if ($oketheme['tripay_act'] == 'live') { $apiKey = $oketheme['tripay_pro_apikey']; $endpoint = 'https://tripay.co.id/api/transaction/detail'; } else { $apiKey = $oketheme['tripay_sand_apikey']; $endpoint = 'https://tripay.co.id/api-sandbox/transaction/detail'; } @$z = explode("|",$x->payment); // If ID transaction available if (@$z[1]) { $payload = ['reference' => $z[1]]; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_FRESH_CONNECT => true, CURLOPT_URL => $endpoint.'?'.http_build_query($payload), CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HEADER => false, CURLOPT_HTTPHEADER => ['Authorization: Bearer '.$apiKey], CURLOPT_FAILONERROR => false, CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4 ]); $response = curl_exec($curl); $error = curl_error($curl); $result = json_decode($response, true); // If success get data if ($result['success']) { $data = $result['data']['instructions']; ?> <div id="headback"> <div class="titleheader"> <h1><?=$result['data']['payment_name'];?></h1> <p> Invoice ID: <?=$invoice;?><br> <b>Rp <?=number_format($result['data']['amount'],0,',','.');?></b> </p> </div> </div> <div id="conwrap"> <div class="wrap-post"> <?php if (@$result['data']['qr_url']) { echo '<img src="'.$result['data']['qr_url'].'">'; } else if (@$result['data']['pay_code']){ echo 'Kode Bayar <code>'.$result['data']['pay_code'].'</code>'; } else { echo 'Link Pembayaran: <b><a href="'.$result['data']['checkout_url'].'" target="blank">'.$result['data']['checkout_url'].'</a></b>'; } if($data) { echo '<p>Berikut ini adalah cara pembayaran melalui <b>'.$result['data']['payment_name'].'</b>:</p>'; foreach ($data as $y) { echo '<h4>'.$y['title'].'</h4><ul>'; foreach ($y['steps'] as $z) { echo '<li>'.$z.'</li>'; } echo '</ul>'; } }?> </div> <p align="center" style="margin-top:40px"> <?php if($t=='id') {?> Bila ada pertanyaan, silahkan hubungi <a href="#kontak" data-fancybox="kontak" class="pop">layanan pelanggan</a> kami. <?php } else { ?> If you need help, please <a href="#kontak" data-fancybox="kontak" class="pop">contact</a> us. <?php } ?> </p> </div> <?php } else { // false get data $sql = $wpdb->query(" UPDATE $tb_booking SET payment = NULL WHERE invoice = '$x->invoice' "); echo '<meta http-equiv="Refresh" content="3;url='.home_url().'/invoice?id='.$x->invoice.'&email='.$x->email_cust.'">';?> <div id="headback"> <div class="titleheader"> <?php if ($t == 'id') { echo '<h1>Opsss... Maaf!</h1><p>Seharusnya Anda tidak berada di halaman ini...</p>'; } else { echo '<h1>Opsss... Sorry!</h1><p>You should not be on this page...</p>'; } ?> </div> </div> <?php } // If ID Transaction empty } else { echo '<meta http-equiv="Refresh" content="5;url='.home_url().'">';?> <div id="headback"> <div class="titleheader"> <h1>INVOICE ID: <?=$invoice;?></h1> <p>The data you're looking for wasn't found...!</p> </div> </div> <div id="conwrap"> <?php if ($t == 'id') { ?> <div class="wrap-post" style="text-align:center"> <h2>Anda akan diarahkan ke halaman beranda dalam beberapa detik...</h2> <img src="<?php echo get_template_directory_uri(); ?>/images/loading.gif"><br/> Apabila tidak berhasil diarahkan, silahkan <a href="<?php echo home_url(); ?>">klik disini</a> </div> <p align="center" style="margin-top:40px"> Bila ada pertanyaan, silahkan hubungi <a href="#kontak" data-fancybox="kontak" class="pop">layanan pelanggan</a> kami. </p> <?php } else { ?> <div class="wrap-post" style="text-align:center"> <h2>You'll be redirected to the home page in a few seconds...</h2> <img src="<?php echo get_template_directory_uri(); ?>/images/loading.gif"><br/> If it is not successfully directed, please <a href="<?php echo home_url(); ?>">click here</a> </div> <p align="center" style="margin-top:40px"> If you have any questions, please <a href="#kontak" data-fancybox="kontak" class="pop">contact</a> our customer service. </p> <?php } ?> </div> <?php } // Else direct to homepage } else { ?> <meta http-equiv="Refresh" content="5;url=<?php echo home_url(); ?>"> <div id="headback"> <div class="titleheader"> <?php if ($t == 'id') { echo '<h1>Opsss... Maaf!</h1><p>Seharusnya Anda tidak berada di halaman ini...</p>'; } else { echo '<h1>Opsss... Sorry!</h1><p>You should not be on this page...</p>'; } ?> </div> </div> <div id="conwrap"> <?php if ($t == 'id') { ?> <div class="wrap-post" style="text-align:center"> <h2>Anda akan diarahkan ke halaman beranda dalam beberapa detik...</h2> <img src="<?php echo get_template_directory_uri(); ?>/images/loading.gif"><br/> Apabila tidak berhasil diarahkan, silahkan <a href="<?php echo home_url(); ?>">klik disini</a> </div> <p align="center" style="margin-top:40px"> Bila ada pertanyaan, silahkan hubungi <a href="#kontak" data-fancybox="kontak" class="pop">layanan pelanggan</a> kami. </p> <?php } else { ?> <div class="wrap-post" style="text-align:center"> <h2>You'll be redirected to the home page in a few seconds...</h2> <img src="<?php echo get_template_directory_uri(); ?>/images/loading.gif"><br/> If it is not successfully directed, please <a href="<?php echo home_url(); ?>">click here</a> </div> <p align="center" style="margin-top:40px"> If you have any questions, please <a href="#kontak" data-fancybox="kontak" class="pop">contact</a> our customer service. </p> <?php } ?> </div> <?php } ?>