コード例 #1
0
 public function testCancelPermataVa()
 {
     $charge_params = VtChargeFixture::build('bank_transfer', array("bank" => "permata"));
     $charge_response = Veritrans_VtDirect::charge($charge_params);
     $cancel_status_code = Veritrans_Transaction::cancel($charge_response->transaction_id);
     $this->assertEquals($cancel_status_code, '200');
 }
コード例 #2
0
 public function status()
 {
     Veritrans_Config::$serverKey = "VT-server-tHdPoLZ5B9msOwJBt-tN7jOE";
     Veritrans_Config::$isProduction = false;
     $order_id = "1462714217";
     $result = Veritrans_Transaction::status($order_id);
     pr($result);
 }
コード例 #3
0
 public function testExpirePermataVa()
 {
     $charge_params = VtChargeFixture::build('bank_transfer', array("bank" => "permata"));
     $charge_response = Veritrans_VtDirect::charge($charge_params);
     $expire = Veritrans_Transaction::expire($charge_response->transaction_id);
     $this->assertEquals($expire->status_code, '407');
     // Verify transaction via API
     $txn_status = Veritrans_Transaction::status($charge_response->transaction_id);
     $this->assertEquals($txn_status->status_code, "407");
     $this->assertEquals($txn_status->transaction_status, "expire");
 }
コード例 #4
0
 public function status()
 {
     // Includes Veritrans
     include app_path() . '/packages/veritrans/Veritrans.php';
     // Veritans configuration
     Veritrans_Config::$serverKey = 'VT-server-YN3xDgcjXol4o0mgbOs-A72D';
     // init
     $data = array();
     // get input
     $param = Input::all();
     try {
         // Check status transaksi ke server Veritrans
         $check = Veritrans_Transaction::status($param['order_id']);
         var_dump($check);
         // Order id
         $cipher = 'm4t4h4r1899';
         $iv = sprintf("%016d", Auth::user()->id);
         // Mempola Initialization Vector dengan User id
         // -- Decrypt order_id dengan algoritma AES-256
         $order_id = openssl_decrypt($param['order_id'], 'AES-256-CBC', $cipher, 0, $iv);
         $order_id = explode("_", $order_id, 2);
         $donation_id = (int) $order_id[1];
         $donation = Donation::where('id', '=', $donation_id)->where('status', '!=', 3)->first();
         // Check
         $code = DB::table('payment_code')->where('order_id', $param['order_id']);
         if ($code->count() > 0) {
             $vtweb_url = 'https://vtweb.sandbox.veritrans.co.id/v2/vtweb/' . $code->pluck('code');
         } else {
             $transaction = array('transaction_details' => array('order_id' => $param['order_id'], 'gross_amount' => (int) $donation->total), "vtweb" => array("credit_card_3d_secure" => true), 'customer_details' => array('first_name' => Auth::user()->firstname, 'last_name' => Auth::user()->lastname));
             // Mendapatkan checkout url
             $vtweb_url = Veritrans_Vtweb::getRedirectionUrl($transaction);
             $insert_code = DB::table('payment_code')->insert(array('order_id' => $param['order_id'], 'user_id' => Auth::user()->id, 'donation_id' => $donation->id, 'code' => basename($vtweb_url)));
         }
         $data = array('status_code' => $check->status_code, 'donation' => $donation);
     } catch (Exception $ex) {
         $data['status_code'] = '404';
     }
     return View::make('bagikasih.donation.status', $data);
 }
コード例 #5
0
 public function testExpire()
 {
     VT_Tests::$stubHttp = true;
     VT_Tests::$stubHttpResponse = '{
     "status_code": "407",
     "status_message": "Success, transaction has expired",
     "transaction_id": "2af158d4-b82e-46ac-808b-be19aaa96ce3",
     "order_id": "Order-111",
     "payment_type": "echannel",
     "transaction_time": "2014-11-27 10:05:10",
     "transaction_status": "expire",
     "gross_amount": "10000.00"
   }';
     $expire = Veritrans_Transaction::expire("Order-111");
     $this->assertEquals($expire->status_code, "407");
     $this->assertEquals($expire->status_message, "Success, transaction has expired");
     $this->assertEquals(VT_Tests::$lastHttpRequest["url"], "https://api.sandbox.veritrans.co.id/v2/Order-111/expire");
     $fields = VT_Tests::lastReqOptions();
     $this->assertEquals($fields["POST"], 1);
     $this->assertEquals($fields["POSTFIELDS"], null);
 }
 /**
  * Check for Veritrans Web Response
  * Method ini akan dipanggil untuk merespon notifikasi yang
  * diberikan oleh server Veritrans serta melakukan verifikasi
  * apakah notifikasi tersebut berasal dari Veritrans dan melakukan
  * konfirmasi transaksi pembayaran yang dilakukan customer
  *
  * update: sekaligus untuk menjadi finish/failed URL handler.
  * @access public
  * @return void
  */
 function veritrans_vtweb_response()
 {
     global $woocommerce;
     @ob_clean();
     global $woocommerce;
     $order = new WC_Order($order_id);
     Veritrans_Config::$isProduction = $this->environment == 'production' ? true : false;
     if ($this->environment == 'production') {
         Veritrans_Config::$serverKey = $this->server_key_v2_production;
     } else {
         Veritrans_Config::$serverKey = $this->server_key_v2_sandbox;
     }
     // check whether the request is GET or POST,
     // if request == GET, request is for finish OR failed URL, then redirect to WooCommerce's order complete/failed
     // else if request == POST, request is for payment notification, then update the payment status
     if (!isset($_GET['order_id'])) {
         // Check if POST, then create new notification
         $veritrans_notification = new Veritrans_Notification();
         if (in_array($veritrans_notification->status_code, array(200, 201, 202))) {
             header('HTTP/1.1 200 OK');
             if ($order->get_order($veritrans_notification->order_id) == true) {
                 $veritrans_confirmation = Veritrans_Transaction::status($veritrans_notification->order_id);
                 do_action("valid-veritrans-web-request", $veritrans_notification);
             }
         }
     } else {
         // else if GET, redirect to order complete/failed
         // error_log('status_code '. $_GET['status_code']); //debug
         // error_log('status_code '. $_GET['transaction_status']); //debug
         if (isset($_GET['order_id']) && isset($_GET['transaction_status']) && ($_GET['transaction_status'] == 'capture' || $_GET['transaction_status'] == 'pending' || $_GET['transaction_status'] == 'settlement')) {
             $order_id = $_GET['order_id'];
             // error_log($this->get_return_url( $order )); //debug
             $order = new WC_Order($order_id);
             wp_redirect($order->get_checkout_order_received_url());
         } else {
             if (isset($_GET['order_id']) && isset($_GET['transaction_status']) && $_GET['transaction_status'] == 'deny') {
                 $order_id = $_GET['order_id'];
                 $order = new WC_Order($order_id);
                 wp_redirect($order->get_checkout_payment_url(false));
             } else {
                 if (isset($_GET['order_id']) && !isset($_GET['transaction_status'])) {
                     // if customer click "back" button, redirect to checkout page again
                     $order_id = $_GET['order_id'];
                     $order = new WC_Order($order_id);
                     wp_redirect($order->get_checkout_payment_url(false));
                 }
             }
         }
     }
 }
コード例 #7
0
<?php

require_once dirname(__FILE__) . '/../../Veritrans.php';
Veritrans_Config::$serverKey = '<your server key>';
if (Veritrans_Config::$serverKey == '<your server key>') {
    echo "<code>";
    echo "<h4>Please set real server key from sandbox</h4>";
    echo "In file: " . __FILE__;
    echo "<br>";
    echo "<br>";
    echo htmlspecialchars('Veritrans_Config::$serverKey = \'<your server key>\';');
    die;
}
$orderId = '1404189699';
try {
    $status = Veritrans_Transaction::status($orderId);
} catch (Exception $e) {
    echo $e->getMessage();
    die;
}
var_dump($status);
// $approve = Veritrans_Transaction::approve($orderId);
// var_dump($approve);
// $cancel = Veritrans_Transaction::cancel($orderId);
// var_dump($cancel);
コード例 #8
0
 public function __construct($input_source = "php://input")
 {
     $raw_notification = json_decode(file_get_contents($input_source), true);
     $status_response = Veritrans_Transaction::status($raw_notification['transaction_id']);
     $this->response = $status_response;
 }
コード例 #9
0
 public function setUp()
 {
     $charge_params = VtChargeFixture::build('bri_epay');
     $charge_response = Veritrans_VtDirect::charge($charge_params);
     $this->status_response = Veritrans_Transaction::status($charge_response->transaction_id);
 }
コード例 #10
0
 public function testCancel()
 {
     VT_Tests::$stubHttp = true;
     VT_Tests::$stubHttpResponse = '{
     "status_code": "200",
     "status_message": "Success, transaction is canceled",
     "transaction_id": "2af158d4-b82e-46ac-808b-be19aaa96ce3",
     "masked_card": "451111-1117",
     "order_id": "Order-111",
     "payment_type": "credit_card",
     "transaction_time": "2014-11-27 10:05:10",
     "transaction_status": "cancel",
     "fraud_status": "accept",
     "approval_code": "1416550071152",
     "bank": "bni",
     "gross_amount": "10000.00"
   }';
     $cancel = Veritrans_Transaction::cancel("Order-111");
     $this->assertEquals($cancel, "200");
     $this->assertEquals(VT_Tests::$lastHttpRequest["url"], "https://api.sandbox.veritrans.co.id/v2/Order-111/cancel");
     $fields = VT_Tests::lastReqOptions();
     $this->assertEquals($fields["POST"], 1);
     $this->assertEquals($fields["POSTFIELDS"], null);
 }