mrsnax

Veritrans Going Live

Aug 14th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require_once("lib/veritrans/Veritrans.php");
  2.  
  3. // Veritrans Server Key
  4. Veritrans_Config::$serverKey = "<your-server-key>";
  5.  
  6.  
  7. // Uncomment for production environment
  8. Veritrans_Config::$isProduction = true;
  9.  
  10. // Uncomment to enable sanitization
  11. // Veritrans_Config::$isSanitized = true;
  12.  
  13. // Uncomment to enable 3D-Secure
  14. Veritrans_Config::$is3ds = true;
  15.  
  16. // Added Ongkir and Taxes if available
  17.  
  18. $Ongkir     = array(array(
  19.     "id"        => rand(),
  20.     "price"     => "15000",
  21.     "quantity"  => "1",
  22.     "name"      => "ONGKIR YES JKT"
  23. ));                    
  24.  
  25.  
  26.  
  27. $Taxes      = array(array(
  28.     "id"        => rand(),
  29.     "price"     => "15000",
  30.     "quantity"  => "1",
  31.     "name"      => "PAJAK 15%"
  32. ));    
  33.  
  34. //  TODO Insert database
  35.  
  36. foreach ($_SESSION["shoppingcart"] as $i => $value){        // If wanna use cookies, please use $_COOKIES["whatisyourcart"]
  37.  
  38.     $varCart [$i]   = array(
  39.         "id"        => $_SESSION["shoppingcart"][$i]["id"],
  40.         "price"     => $_SESSION["shoppingcart"][$i]["price"],
  41.         "quantity"  => $_SESSION["shoppingcart"][$i]["quantity"],
  42.         "name"      => $_SESSION["shoppingcart"][$i]["name"]
  43.     );
  44.  
  45.     $items = array_merge($varCart, $Ongkir, $Taxes);
  46.  
  47. }
  48.  
  49. // Setup Parameters
  50.  
  51.  
  52. $params = array(
  53. 'transaction_details' => array(
  54.     'order_id'      => rand(),
  55.     'gross_amount'      => "50000",
  56. ),
  57.  
  58. "item_details" => ($items),
  59.  
  60. "customer_details" => array (
  61.     "first_name"        => "Sterli",
  62.     "last_name"     => "Snax",
  63.     "email"         => "saya@sterli.net",
  64.     "phone"         => "08176460388",
  65.  
  66. "billing_address" => array (
  67.     "first_name"        => "Sterli",
  68.     "last_name"     => "Snax",
  69.     "address"       => "Jl. Kembang II No. 17",
  70.     "city"          => "Jakarta Pusat",
  71.     "postal_code"       => "10000",
  72.     "phone"         => "08176460388",
  73.     "country_code"      => "IDN"
  74. ),
  75.  
  76. "shipping_address" => array(
  77.     "first_name"        => "Sterli",
  78.     "last_name"     => "Snax",
  79.     "address"       => "Jl. Gunung Sahari Raya No. 2, Ruko Marina Tama, Blok B/11",
  80.     "city"          => "Jakarta Pusat",
  81.     "postal_code"       => "10000",
  82.     "phone"         => "02164002000",
  83.     "country_code"      => "IDN"
  84. )
  85.  
  86. ) // <---customer_details array;
  87.  
  88.  
  89. ); // <--- Params Array
  90.  
  91.  
  92. /* For debug only
  93.     echo "<pre>";
  94.         print_r($params);
  95.     echo "</pre>";
  96. */
  97.  
  98. /*♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫ After All This Time by Simon Webbe ♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫♫ */
  99.  
  100. try {
  101.     // Redirect to Veritrans VTWeb page
  102.     header('Location: ' . Veritrans_Vtweb::getRedirectionUrl($params));
  103. }
  104.     catch (Exception $e) {
  105.     echo $e->getMessage();
  106. }
Add Comment
Please, Sign In to add comment