Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Virtual_account extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- $this->client_id = 'client_id';
- $this->secret_key = 'secret_key';
- $this->url = 'URL';
- $this->va = $this->load->database('va', true);
- $this->load->library('BniEnc');
- $this->load->helper('get_content');
- if( ! $this->ion_auth->logged_in() )
- {
- redirect('auth/login');
- }
- }
- private function transmit($data_asli)
- {
- $hashed_string = BniEnc::encrypt(
- $data_asli,
- $this->client_id,
- $this->secret_key
- );
- $data = array(
- 'client_id' => $this->client_id,
- 'data' => $hashed_string,
- );
- $response = get_content($this->url, json_encode($data));
- $response_json = json_decode($response, true);
- if ($response_json['status'] !== '000') {
- // handling jika gagal
- var_dump($response_json);
- exit;
- // return FALSE;
- }
- else {
- // $data_response = BniEnc::decrypt($response_json['data'], $this->client_id, $this->secret_key);
- // return array( 'status' => $response_json['status'], 'data_response' => $data_response );
- return TRUE;
- }
- }
- public function get_va( $id_invoice = null )
- {
- if( $id_invoice )
- {
- $this->load->helper('get_content');
- include_once __DIR__ . "/../../../../libraries/BniEnc.php";
- $data_asli = array(
- 'type' => 'inquirybilling',
- 'client_id' => $this->client_id,
- 'trx_id' => $this->db->get_where('invoice', array('id_invoice' => $id_invoice))->row()->trx_id,
- );
- $this->transmit( $data_asli );
- }
- else
- {
- show_404();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement