예제 #1
0
// $veritrans->enable_3d_secure	= 1;
// $veritrans->bank 				= "bni";
// $veritrans->installment_banks 	= array("bni");
// $veritrans->promo_bins			= array("411111", "444444");
// $veritrans->point_banks			= array("bni", "cimb");
$veritrans->payment_methods = array("credit_card", "mandiri_clickpay");
// $veritrans->installment_terms   = array(
// 	'bni' => array(3)
// 	);
// Set commodity items. This is just sample items.
// TODO: Change with your actual items.
$items = array(array("item_id" => 'itemsatu', "price" => 250000, "quantity" => 1, "item_name1" => 'sepatu', "item_name2" => 'Shoes'), array("item_id" => 'itemdua', "price" => 500000, "quantity" => 2, "item_name1" => 'Tas', "item_name2" => 'Bag'));
$veritrans->items = $items;
$veritrans->force_sanitization = TRUE;
if ($_POST['payment_type'] == 'vtdirect') {
    $keys = $veritrans->charge();
} else {
    //Call Veritrans VT-Web API Get Token
    try {
        $keys = $veritrans->getTokens();
        if (!$keys) {
            print_r($veritrans->errors);
            exit;
        } else {
            //Save this token_merchant on your database to be used for checking veritrans notification response.
            $token_merchant = $keys['token_merchant'];
            //Use this token_browser for redirecting customer to Veritrans payment page.
            $token_browser = $keys['token_browser'];
        }
    } catch (Exception $e) {
        var_dump($e);
예제 #2
0
// //	Accept: application/json
// // 	Basic Auth using server_key
// $request = curl_init($endpoint);
// curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
// curl_setopt($request, CURLOPT_POSTFIELDS, $json_transaction_data);
// curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
// $auth = sprintf('Authorization: Basic %s', base64_encode($server_key.':'));
// curl_setopt($request, CURLOPT_HTTPHEADER, array(
//     'Content-Type: application/json',
// 	'Accept: application/json',
// 	$auth
// 	)
// );
// // Excute request and parse the response
// $response = json_decode(curl_exec($request));
$response = $veritrans->charge();
if (in_array($response['status_code'], array(200, 201, 202))) {
    if ($response['transaction_status'] == "capture") {
        //success
        echo "Transaksi berhasil. <br />";
        echo "Status transaksi untuk order id " . $response['order_id'] . ": " . $response['transaction_status'];
        echo "<h3>Detail transaksi:</h3>";
        var_dump($response);
    } else {
        if ($response['transaction_status'] == "deny") {
            //deny
            echo "Transaksi ditolak. <br />";
            echo "Status transaksi untuk order id " . $response['order_id'] . ": " . $response['transaction_status'];
            echo "<h3>Detail transaksi:</h3>";
            var_dump($response);
        } else {