<?php if (empty($_POST)) { echo "Empty data."; exit; } require '../../../veritrans.php'; $veritrans = new Veritrans(); $veritrans->server_key = 'eebadfec-fa3a-496a-8ea0-bb5795179ce6'; // change with your development/production server key $veritrans->version = 2; // since 2014's stack is currently not the default one, we need to set it explicitly //TODO: Change with your actual order_id. $veritrans->order_id = 'order' . rand(); $veritrans->billing_different_with_shipping = 1; $veritrans->required_shipping_address = 1; // Billing info. [Optional] $veritrans->first_name = $_POST['billing_first_name']; $veritrans->last_name = $_POST['billing_last_name']; $veritrans->address1 = $_POST['billing_address1']; $veritrans->address2 = $_POST['billing_address2']; $veritrans->city = $_POST['billing_city']; $veritrans->country_code = "IDN"; $veritrans->postal_code = $_POST['billing_postal_code']; $veritrans->phone = $_POST['billing_phone']; // Shipping info. [Required if required_shipping_address = '1'] $veritrans->shipping_first_name = $_POST['shipping_first_name']; $veritrans->shipping_last_name = $_POST['shipping_last_name']; $veritrans->shipping_address1 = $_POST['shipping_address1']; $veritrans->shipping_address2 = $_POST['shipping_address2']; $veritrans->shipping_city = $_POST['shipping_city'];
<?php require '../../../veritrans.php'; if (empty($_POST['token_id'])) { echo "Empty token_id."; exit; } $veritrans = new Veritrans(); // TODO: change with your actual server_key that can be found on Merchant Administration Portal (MAP) $veritrans->server_key = "eebadfec-fa3a-496a-8ea0-bb5795179ce6"; // TODO : change to production URL for your production Environment // $endpoint = "https://api.veritrans.co.id/v2/charge"; // token_id merepresentasikan credit card yang akan di-carge. // token_id didaptkan dari request yang dilakukan melalui veritrans.js $veritrans->payment_type = Veritrans::VT_DIRECT; $veritrans->token_id = $_POST['token_id']; $veritrans->bank = 'bni'; if (isset($_POST['save_cc'])) { $veritrans->save_token_id = true; } // $transaction_details = array( // 'order_id' => time(), // 'gross_amount' => 200000 // ); $veritrans->order_id = time(); $veritrans->gross_amount = 20000; // Populate items $items = [array('item_id' => 'item1', 'price' => 100000, 'quantity' => 1, 'item_name1' => 'Adidas f50'), array('item_id' => 'item2', 'price' => 50000, 'quantity' => 2, 'item_name1' => 'Nike N90')]; $veritrans->items = $items; // Populate customer's billing address // $billing_address = array(
<?php if (empty($_POST)) { echo "Empty data."; exit; } require '../../veritrans.php'; //TODO: Change with your actual merchant id and merchant hash key $MERCHANT_ID = 'T100000000000001002793'; $MERCHANT_HASH_KEY = '38576e0919d02d342cab80b968be50c6c1467be63a5e30453efea0739fc09b16'; $veritrans = new Veritrans(); if ($_POST['payment_type'] == 'vtdirect') { $veritrans->token_id = $_POST['token_id']; $veritrans->server_key = '0ff9946b-f16e-4236-947a-b90867c5a276'; } else { $veritrans->merchant_id = $MERCHANT_ID; $veritrans->merchant_hash_key = $MERCHANT_HASH_KEY; } //TODO: Change with your actual order_id. $veritrans->order_id = 'order' . rand(); $veritrans->billing_different_with_shipping = 1; $veritrans->required_shipping_address = 1; // Billing info. [Optional] $veritrans->first_name = $_POST['billing_first_name']; $veritrans->last_name = $_POST['billing_last_name']; $veritrans->address1 = $_POST['billing_address1']; $veritrans->address2 = $_POST['billing_address2']; $veritrans->city = $_POST['billing_city']; $veritrans->country_code = "IDN"; $veritrans->postal_code = $_POST['billing_postal_code']; $veritrans->phone = $_POST['billing_phone'];
/** * Expire transaction before it's setteled * @param string $id Order ID or transaction ID * @return mixed[] */ public static function expire($id) { return Veritrans::post(Veritrans::getBaseUrl() . '/' . $id . '/expire', Veritrans::$serverKey, false); }