コード例 #1
0
 public function testRealConnect()
 {
     $params = array('transaction_details' => array('order_id' => rand(), 'gross_amount' => 10000));
     try {
         $paymentUrl = Veritrans_Vtweb::getRedirectionUrl($params);
     } catch (Exception $error) {
         $errorHappen = true;
         $this->assertEquals($error->getMessage(), "Veritrans Error (401): Access denied due to unauthorized transaction, please check client or server key");
     }
     $this->assertTrue($errorHappen);
 }
コード例 #2
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);
 }
コード例 #3
0
 public function pay(Request $request)
 {
     \Veritrans_Config::$serverKey = '597bed2a-b11c-4976-ba85-743f54fadaec';
     \Veritrans_Config::$isProduction = false;
     \Veritrans_Config::$isSanitized = false;
     // Populate customer's billing address
     $billing_address = array('first_name' => $request->input('billingFirstName'), 'last_name' => $request->input('billingLastName'), 'address' => $request->input('billingAddress'), 'city' => $request->input('billingCity'), 'postal_code' => $request->input('billingPostalCode'), 'phone' => $request->input('billingPhone'), 'country_code' => 'IDN');
     // Populate customer's shipping address
     $shipping_address = array('first_name' => $request->input('shipmentFirstName'), 'last_name' => $request->input('shipmentLastName'), 'address' => $request->input('shipmentAddress'), 'city' => $request->input('shipmentCity'), 'postal_code' => $request->input('shipmentPostalCode'), 'phone' => $request->input('shipmentPhone'), 'country_code' => 'IDN');
     // Populate customer's info
     $customer_details = array('first_name' => $request->input('customerFirstName'), 'last_name' => $request->input('customerLastName'), 'email' => $request->input('customerEmail'), 'phone' => $request->input('customerPhone'), 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
     //Detail Items
     $detailItems = [];
     foreach (Cart::content() as $item) {
         $detailItems[] = ['id' => $item->id, 'price' => $item->price, 'quantity' => $item->qty, 'name' => $item->name];
     }
     $params = array('customer_details' => $customer_details, 'item_details' => $detailItems, 'transaction_details' => array('order_id' => rand(), 'gross_amount' => Cart::total()), 'vtweb' => array('enabled_payments' => array($request->input('payment')), 'credit_card_3d_secure' => true, 'finish_redirect_url' => route('frontend.payment.finish'), 'unfinish_redirect_url' => route('frontend.payment.unFinish'), 'error_redirect_url' => route('frontend.payment.error')));
     try {
         // Redirect to Veritrans VTWeb page
         return redirect(\Veritrans_Vtweb::getRedirectionUrl($params));
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
コード例 #4
0
 public function execValidation($cart)
 {
     global $cookie;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'veritranspay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $usd = Configuration::get('VT_KURS');
     $cf = Configuration::get('VT_CONVENIENCE_FEE') * 0.01;
     $list_enable_payments = array();
     if (Configuration::get('ENABLED_CREDIT_CARD')) {
         $list_enable_payments[] = "credit_card";
     }
     if (Configuration::get('ENABLED_CIMB')) {
         $list_enable_payments[] = "cimb_clicks";
     }
     if (Configuration::get('ENABLED_MANDIRI')) {
         $list_enable_payments[] = "mandiri_clickpay";
     }
     if (Configuration::get('ENABLED_PERMATAVA')) {
         $list_enable_payments[] = "bank_transfer";
     }
     if (Configuration::get('ENABLED_BRIEPAY')) {
         $list_enable_payments[] = "bri_epay";
     }
     if (Configuration::get('ENABLED_TELKOMSEL_CASH')) {
         $list_enable_payments[] = "telkomsel_cash";
     }
     if (Configuration::get('ENABLED_XL_TUNAI')) {
         $list_enable_payments[] = "xl_tunai";
     }
     if (Configuration::get('ENABLED_MANDIRI_BILL')) {
         $list_enable_payments[] = "echannel";
     }
     if (Configuration::get('ENABLED_BBM_MONEY')) {
         $list_enable_payments[] = "bbm_money";
     }
     if (Configuration::get('ENABLED_INDOMARET')) {
         $list_enable_payments[] = "cstore";
     }
     if (Configuration::get('ENABLED_INDOSAT_DOMPETKU')) {
         $list_enable_payments[] = "indosat_dompetku";
     }
     if (Configuration::get('ENABLED_MANDIRI_ECASH')) {
         $list_enable_payments[] = "mandiri_ecash";
     }
     //error_log(print_r($list_enable_payments,TRUE));
     $veritrans = new Veritrans_Config();
     //SETUP
     Veritrans_Config::$serverKey = Configuration::get('VT_SERVER_KEY');
     Veritrans_Config::$isProduction = Configuration::get('VT_ENVIRONMENT') == 'production' ? true : false;
     $url = Veritrans_Config::getBaseUrl();
     if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
         $shipping_cost = $cart->getOrderShippingCost();
     } else {
         $shipping_cost = $cart->getTotalShippingCost();
     }
     $currency = new Currency($cookie->id_currency);
     $total = $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array();
     $billing_address = new Address($cart->id_address_invoice);
     $delivery_address = new Address($cart->id_address_delivery);
     if (Configuration::get('VT_3D_SECURE') == 'on' || Configuration::get('VT_3D_SECURE') == 1) {
         Veritrans_Config::$is3ds = true;
     }
     if (Configuration::get('VT_SANITIZED') == 'on' || Configuration::get('VT_SANITIZED') == 1) {
         Veritrans_Config::$isSanitized = true;
     }
     //error_log('sanitized '.Configuration::get('VT_SANITIZED'));
     // Billing Address
     $params_billing_address = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'address' => $billing_address->address1, 'city' => $billing_address->city, 'postal_code' => $billing_address->postcode, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'country_code' => 'IDN');
     if ($cart->isVirtualCart()) {
     } else {
         if ($cart->id_address_delivery != $cart->id_address_invoice) {
             $params_shipping_address = array('first_name' => $delivery_address->firstname, 'last_name' => $delivery_address->lastname, 'address' => $delivery_address->address1, 'city' => $delivery_address->city, 'postal_code' => $delivery_address->postcode, 'phone' => $this->determineValidPhone($delivery_address->phone, $delivery_address->phone_mobile), 'country_code' => 'IDN');
         } else {
             $params_shipping_address = $params_billing_address;
         }
     }
     $params_customer_details = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'email' => $customer->email, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'billing_address' => $params_billing_address, 'shipping_address' => $params_shipping_address);
     $items = $this->addCommodities($cart, $shipping_cost, $usd);
     // convert the currency
     $cart_currency = new Currency($cart->id_currency);
     if ($cart_currency->iso_code != 'IDR') {
         // check whether if the IDR is installed or not
         if (Currency::exists('IDR', null)) {
             // use default rate
             if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
                 $conversion_func = function ($input) use($cart_currency) {
                     return Tools::convertPrice($input, new Currency(Currency::getIdByIsoCode('IDR')), true);
                 };
             } else {
                 $conversion_func = function ($input) use($cart_currency) {
                     return Tools::convertPriceFull($input, $cart_currency, new Currency(Currency::getIdByIsoCode('IDR')));
                 };
             }
         } else {
             // use rate
             $conversion_func = function ($input) {
                 return $input * intval(Configuration::get('VT_KURS'));
             };
         }
         foreach ($items as &$item) {
             $item['price'] = intval(round(call_user_func($conversion_func, $item['price'])));
         }
     } else {
         if ($cart_currency->iso_code == 'IDR') {
             foreach ($items as &$item) {
                 $item['price'] = intval(round($item['price']));
             }
         }
     }
     $this->validateOrder($cart->id, Configuration::get('VT_ORDER_STATE_ID'), $cart->getOrderTotal(true, Cart::BOTH), $this->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     $gross_amount = 0;
     unset($item);
     foreach ($items as $item) {
         $gross_amount += $item['price'] * $item['quantity'];
     }
     $isBniInstallment = Configuration::get('ENABLED_BNI_INSTALLMENT') == 1;
     $isMandiriInstallment = Configuration::get('ENABLED_MANDIRI_INSTALLMENT') == 1;
     $warning_redirect = false;
     $fullPayment = true;
     $installment_type_val = Configuration::get('VT_ENABLE_INSTALLMENT');
     $param_required;
     switch ($installment_type_val) {
         case 'all_product':
             if ($isBniInstallment) {
                 //$bni_term2 = $this->getTermInstallment('BNI');
                 $a = Configuration::get('VT_INSTALLMENTS_BNI');
                 $term = explode(',', $a);
                 $bni_term = $term;
                 //error_log(print_r($bni_term,true));
                 //error_log($bni_term,true);
             }
             if ($isMandiriInstallment) {
                 $mandiri_term = $this->getTermInstallment('MANDIRI');
                 $a = Configuration::get('VT_INSTALLMENTS_MANDIRI');
                 $term = explode(',', $a);
                 $mandiri_term = $term;
                 //error_log($mandiri_term,true);
                 //error_log(print_r($mandiri_term,true));
             }
             $param_installment = array();
             if ($isBniInstallment) {
                 $param_installment['bni'] = $bni_term;
             }
             if ($isMandiriInstallment) {
                 $param_installment['mandiri'] = $mandiri_term;
             }
             $param_required = "false";
             $fullPayment = false;
             break;
         case 'certain_product':
             $param_installment = null;
             $products_cart = $cart->getProducts();
             $num_product = count($products_cart);
             if ($num_product == 1) {
                 $attr_product = explode(',', $products_cart[0]['attributes_small']);
                 foreach ($attr_product as $att) {
                     $att_trim = ltrim($att);
                     $att_arr = explode(' ', $att_trim);
                     //error_log(print_r($att_arr,true));
                     if (strtolower($att_arr[0]) == 'installment') {
                         $fullPayment = false;
                         $param_installment = array();
                         $param_installment[strtolower($att_arr[1])] = array($att_arr[2]);
                     }
                 }
             } else {
                 $warning_redirect = true;
                 $keys['message'] = 1;
             }
             $param_required = "true";
             break;
         case 'off':
             $param_installment = null;
             break;
     }
     //error_log($param_installment,true);
     // $param_payment_option = array(
     // 	'installment' => array(
     // 						'required' => $param_required,
     // 						'installment_terms' => $param_installment
     // 					)
     // 	);
     $params_all = array('payment_type' => Configuration::get('VT_PAYMENT_TYPE'), 'vtweb' => array('enabled_payments' => $list_enable_payments), 'transaction_details' => array('order_id' => $this->currentOrder, 'gross_amount' => $gross_amount), 'item_details' => $items, 'customer_details' => $params_customer_details);
     if ($gross_amount < 500000) {
         $warning_redirect = true;
         $keys['message'] = 2;
     }
     if (!$warning_redirect && ($isBniInstallment || $isMandiriInstallment) && !$fullPayment) {
         $params_all['vtweb']['payment_options'] = $param_payment_option;
     }
     if (Configuration::get('VT_API_VERSION') == 2 && Configuration::get('VT_PAYMENT_TYPE') != 'vtdirect') {
         try {
             // Redirect to Veritrans VTWeb page
             if ($this->isInstallmentCart($cart->getProducts()) || $installment_type_val == 'all_product') {
                 $keys['isWarning'] = $warning_redirect;
             } else {
                 $keys['isWarning'] = false;
             }
             $keys['redirect_url'] = Veritrans_Vtweb::getRedirectionUrl($params_all);
         } catch (Exception $e) {
             $keys['errors'] = $e->getMessage();
             echo $e->getMessage();
         }
         return $keys;
     } else {
         if (Configuration::get('VT_API_VERSION') == 2 && Configuration::get('VT_PAYMENT_TYPE') == 'vtdirect') {
             echo 'not yet implementation.';
             exit;
         } else {
             echo 'The Veritrans API versions and the payment type is not valid.';
             exit;
         }
     }
 }
コード例 #5
0
      if($data_item->promo_start_datetime <= date('Y-m-d') and $data_item->promo_end_datetime >= date('Y-m-d')){
	     if($data_item->promo_id == '1'){
	     
		    $data_item->type_price = $data_item->type_price - (($data_item->promo_value / 100) * $data_item->type_price);
		 
		 }else if($data_item->promo_id == '2'){
	        $data_item->type_price = $data_item->type_price - $data_item->promo_value;
		 }
		 
	  }else{
	     $data_item->type_price;
	  }
	  
   }else{
      $data_item->type_price = $data_item->type_price;
   }
   
   
   $params['items']['id'][$key] = 'order-'.($key+1);
   $params['items']['price'][$key] = $data_item->type_price;
   $params['items']['quantity'][$key] = $data_item->item_quantity;
   $params['items']['name'][$key] = $data_item->product_name.' - '.$data_item->type_name;
}
*/
$params = array("vtweb" => array("credit_card_3d_secure" => false, 'finish_redirect_url' => BASE_URL . 'finish-veritrans', 'unfinish_redirect_url' => BASE_URL . 'bag-veritrans', 'error_redirect_url' => BASE_URL . 'finish-veritrans'), 'transaction_details' => array('order_id' => $data_order->order_number, 'gross_amount' => $data_order->order_total_amount));
try {
    $veritrans_url = strrchr(Veritrans_Vtweb::getRedirectionUrl($params), 'https://');
    safe_redirect($veritrans_url);
} catch (Exception $e) {
    echo $e->getMessage();
}
コード例 #6
0
<?php

$order_id = filter_var($_REQUEST['order_number'], FILTER_SANITIZE_STRING);
$order_total = filter_var($_REQUEST['total'], FILTER_SANITIZE_NUMBER_INT);
require_once dirname(__FILE__) . '/../../Veritrans.php';
/* --- SANDBOX --- */
Veritrans_Config::$serverKey = '2d7b85ab-f67a-43fd-9a85-95ffc9ef7f22';
/* --- PRODUCTION --- */
//Veritrans_Config::$serverKey = '88dd5ab2-218e-4b2f-8f0d-09e2e5275068';
// Uncomment for production environment
Veritrans_Config::$isProduction = false;
// Uncomment to enable sanitization
// Veritrans_Config::$isSanitized = true;
// Uncomment to enable 3D-Secure
//Veritrans_Config::$is3ds = true;
$params = array('transaction_details' => array('order_id' => $order_id, 'gross_amount' => $order_total));
try {
    // Redirect to Veritrans VTWeb page
    header('Location: ' . Veritrans_Vtweb::getRedirectionUrl($params));
} catch (Exception $e) {
    echo $e->getMessage();
}
コード例 #7
0
ファイル: detail.blade.php プロジェクト: marthem/bagikasih
    // Veritans configuration
    Veritrans_Config::$serverKey = 'VT-server-YN3xDgcjXol4o0mgbOs-A72D';
    // Order id
    $cipher = 'm4t4h4r1899';
    $iv = sprintf("%016d", Auth::user()->id);
    // Mempola Initialization Vector dengan User id
    // -- Encrypt order_id dengan algoritma AES-256
    $order_id = openssl_encrypt(Auth::user()->id . '_' . $donation->id, 'AES-256-CBC', $cipher, 0, $iv);
    // Check
    $code = DB::table('payment_code')->where('order_id', $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' => $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' => $order_id, 'user_id' => Auth::user()->id, 'donation_id' => $donation->id, 'code' => basename($vtweb_url)));
    }
}
// about donation object
if (isset($donation->type->social_action_category_id)) {
    $type_name = 'Aksi Sosial';
    $type_url = URL::route('temukan-aksi-sosial');
} else {
    $type_name = 'Target Sosial';
    $type_url = URL::route('temukan-target-sosial');
}
// about donation status
if ($donation->status == 0 and $donation->payment_id == null) {
    $status = '<a href="' . URL::route('riwayat-donasi') . '">Menunggu konfirmasi dari Anda</a>';
} else {
コード例 #8
0
 function plgVmConfirmedOrder($cart, $order)
 {
     // error_log('plgVmConfirmedOrder'); // debug purpose
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $interface = $this->_loadVeritransInterface($this);
     // DONE function
     $interface->setOrder($order);
     $interface->setCart($cart);
     $this->getPaymentCurrency($this->_currentMethod);
     $interface->setTotal($order['details']['BT']->order_total);
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     $subscribe_id = NULL;
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $email_currency = $this->getEmailCurrency($this->_currentMethod);
     // TODO save to DB!
     // Prepare data that should be stored in the database
     // $dbValues['order_number'] = $order['details']['BT']->order_number;
     // $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     // $dbValues['payment_name'] = $this->renderPluginName($this->_currentMethod);
     // $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     // $dbValues['klikandpay_custom'] = $this->getContext();
     // $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     // $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     // $dbValues['payment_currency'] = $this->_currentMethod->payment_currency;
     // $dbValues['email_currency'] = $email_currency;
     // $dbValues['payment_order_total'] = $post_variables["MONTANT"];
     // $dbValues['tax_id'] = $this->_currentMethod->tax_id;
     // $this->storePSPluginInternalData($dbValues);
     // Set our server key
     Veritrans_Config::$serverKey = $this->_currentMethod->serverkey;
     Veritrans_Config::$isProduction = $this->_currentMethod->shop_mode == 'test' ? FALSE : TRUE;
     Veritrans_Config::$is3ds = $this->_currentMethod->is3ds ? TRUE : FALSE;
     if ($this->_currentMethod->credit_card) {
         $payements_type[] = 'credit_card';
     }
     if ($this->_currentMethod->mandiri_clickpay) {
         $payements_type[] = 'mandiri_clickpay';
     }
     if ($this->_currentMethod->cimb_clicks) {
         $payements_type[] = 'cimb_clicks';
     }
     if ($this->_currentMethod->bank_transfer) {
         $payements_type[] = 'bank_transfer';
     }
     if ($this->_currentMethod->bri_epay) {
         $payements_type[] = 'bri_epay';
     }
     if ($this->_currentMethod->telkomsel_cash) {
         $payements_type[] = 'telkomsel_cash';
     }
     if ($this->_currentMethod->xl_tunai) {
         $payements_type[] = 'xl_tunai';
     }
     if ($this->_currentMethod->echannel) {
         $payements_type[] = 'echannel';
     }
     if ($this->_currentMethod->bbm_money) {
         $payements_type[] = 'bbm_money';
     }
     if ($this->_currentMethod->cstore) {
         $payements_type[] = 'cstore';
     }
     if ($this->_currentMethod->credit_card) {
         $payements_type[] = 'indosat_dompetku';
     }
     $conversion_rate = floatval($this->_currentMethod->conversion_rate);
     if (!isset($conversion_rate) or $conversion_rate = '' or $conversion_rate = '1') {
         $conversion_rate = 1;
     }
     $gross_amount = 0;
     $items_details = array();
     //push item to item details array
     foreach ($order['items'] as $line_item_wrapper) {
         $item = array();
         $line_item_price = $line_item_wrapper->product_final_price;
         $item['id'] = $line_item_wrapper->virtuemart_order_item_id;
         $item['quantity'] = $line_item_wrapper->product_quantity;
         $item['price'] = ceil($line_item_price * $conversion_rate);
         $item['name'] = $line_item_wrapper->order_item_name;
         $items_details[] = $item;
         $gross_amount += $item['price'] * $item['quantity'];
     }
     //push shipment & shipment tax to item details
     $item = array();
     $item['id'] = 'sp';
     $item['quantity'] = 1;
     $item['price'] = ceil(($order['details']['BT']->order_shipment + $order['details']['BT']->order_shipment_tax) * $conversion_rate);
     $item['name'] = "Shipment & Shipment tax";
     $items_details[] = $item;
     $gross_amount += $item['price'] * $item['quantity'];
     //push discount to item details
     $item = array();
     $item['id'] = 'dc';
     $item['quantity'] = 1;
     $item['price'] = -(ceil($order['details']['BT']->coupon_discount) * $conversion_rate);
     $item['name'] = "Coupon Discount";
     $items_details[] = $item;
     $gross_amount += $item['price'] * $item['quantity'];
     // Billing name
     $fname = $order['details']['BT']->first_name;
     if (isset($order['details']['BT']->middle_name) and $order['details']['BT']->middle_name) {
         $fname .= $order['details']['BT']->middle_name;
     }
     $lname = $order['details']['BT']->last_name;
     $address = $order['details']['BT']->address_1;
     if (isset($order['details']['BT']->address_2) and $order['details']['BT']->address_2) {
         $address .= $order['details']['BT']->address_2;
     }
     // check if both phone field filled, append both
     $appender = '';
     if (isset($order['details']['BT']->phone_1) && isset($order['details']['BT']->phone_2)) {
         $appender = ', ';
     }
     // Fill transaction data
     // /index.php?option=com_virtuemart&view=vmplg&task=pluginUserPaymentCancel
     $finish_url = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=pluginresponsereceived&';
     $back_url = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=pluginUserPaymentCancel&';
     // error_log($back_url);  // debug purpose
     $transaction = array("vtweb" => array('finish_redirect_url' => $finish_url, 'unfinish_redirect_url' => $back_url, 'error_redirect_url' => $back_url, 'enabled_payments' => $payements_type), 'transaction_details' => array('order_id' => $order['details']['BT']->virtuemart_order_id, 'gross_amount' => $gross_amount), 'item_details' => $items_details, 'customer_details' => array('first_name' => $fname, 'last_name' => $lname, 'email' => $order['details']['BT']->email, 'phone' => $order['details']['BT']->phone_1, 'billing_address' => array('first_name' => $fname, 'last_name' => $lname, 'address' => $address, 'city' => $order['details']['BT']->city, 'postal_code' => $order['details']['BT']->zip, 'phone' => $order['details']['BT']->phone_1 . $appender . $order['details']['BT']->phone_2)));
     // Add shipment details if exists
     if (array_key_exists('ST', $order['details'])) {
         // check if both phone field filled, append both
         $appender = '';
         if (isset($order['details']['ST']->phone_1) && isset($order['details']['ST']->phone_2)) {
             $appender = ', ';
         }
         // Shipping name
         $sfname = $order['details']['ST']->first_name;
         if (isset($order['details']['ST']->middle_name) and $order['details']['ST']->middle_name) {
             $sfname .= $order['details']['ST']->middle_name;
         }
         $slname = $order['details']['ST']->last_name;
         $saddress = $order['details']['ST']->address_1;
         if (isset($order['details']['ST']->address_2) and $order['details']['ST']->address_2) {
             $saddress .= $order['details']['ST']->address_2;
         }
         $shipping_address = array('first_name' => $sfname, 'last_name' => $slname, 'address' => $saddress, 'city' => $order['details']['ST']->city, 'postal_code' => $order['details']['ST']->zip, 'phone' => $order['details']['ST']->phone_1 . $appender . $order['details']['ST']->phone_2);
         $transaction['customer_details']['shipping_address'] = $shipping_address;
     }
     // error_log('$transaction = '.print_r($transaction,true)); // debug purpose
     $vtweb_url = Veritrans_Vtweb::getRedirectionUrl($transaction);
     $html = $this->getConfirmedHtml($vtweb_url, $interface, $subscribe_id);
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     vRequest::setVar('display_title', false);
     vRequest::setVar('html', $html);
     // $this->emptyCart();
     header("Location: " . $vtweb_url);
     return;
 }
コード例 #9
0
function edd_veritrans_payment($purchase_data)
{
    global $edd_options;
    require_once plugin_dir_path(__FILE__) . '/lib/Veritrans.php';
    /**********************************
     * set transaction mode
     **********************************/
    if (edd_is_test_mode()) {
        // set test credentials here
        Veritrans_Config::$isProduction = false;
        Veritrans_Config::$serverKey = $edd_options['vt_sandbox_api_key'];
    } else {
        // set live credentials here
        Veritrans_Config::$isProduction = true;
        Veritrans_Config::$serverKey = $edd_options['vt_production_api_key'];
    }
    // check for any stored errors
    $errors = edd_get_errors();
    if (!$errors) {
        $purchase_summary = edd_get_purchase_summary($purchase_data);
        // error_log('purchase data: '.print_r($purchase_data,true)); //debugan
        // error_log('purchase summary: '.print_r($purchase_summary,true)); //debugan
        // error_log('plugin_dir_path : '.plugin_dir_path(__FILE__)); //debugan
        /**********************************
         * setup the payment details
         **********************************/
        // error_log(json_encode($purchase_data, true));
        $payment = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['currency'], 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
        // record the pending payment
        $payment = edd_insert_payment($payment);
        // create item
        $transaction_details = array();
        foreach ($purchase_data['cart_details'] as $item) {
            $vt_item = array('id' => $item['id'], 'price' => $item['price'], 'quantity' => $item['quantity'], 'name' => $item['name']);
            array_push($transaction_details, $vt_item);
        }
        $vt_params = array('transaction_details' => array('order_id' => $payment, 'gross_amount' => $purchase_data['price']), 'customer_details' => array('first_name' => $purchase_data['user_info']['first_name'], 'last_name' => $purchase_data['user_info']['last_name'], 'email' => $purchase_data['user_info']['email'], 'billing_address' => array('first_name' => $purchase_data['user_info']['first_name'], 'last_name' => $purchase_data['user_info']['last_name'])), 'item_details' => $transaction_details);
        //get enabled payment opts from backend
        $enabled_payments = edd_get_vtpayment_ops();
        if (!empty($enabled_payments)) {
            $vt_params['vtweb']['enabled_payments'] = $enabled_payments;
        }
        // error_log('vt_3ds '.$edd_options['vt_3ds']); //debugan
        // get rid of cart contents
        edd_empty_cart();
        // Redirect to veritrans
        // error_log('vt_params: '.print_r($vt_params,true)); //debugan
        wp_redirect(Veritrans_Vtweb::getRedirectionUrl($vt_params));
        exit;
    } else {
        $fail = true;
        // errors were detected
    }
    if ($fail !== false) {
        // if errors are present, send the user back to the purchase page so they can be corrected
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    }
}
コード例 #10
0
ファイル: Vp.php プロジェクト: CapsuleCorpIndonesia/apel-enak
 function testpay()
 {
     echo 1;
     // Set our server key
     Veritrans_Config::$serverKey = VeritransPay::$serverKeyReal;
     echo 2;
     // Uncomment for production environment
     //        Veritrans_Config::$isProduction = true;
     // Uncomment to enable sanitization
     //        Veritrans_Config::$isSanitized = true;
     // Uncomment to enable 3D-Secure
     //        Veritrans_Config::$is3ds = true;
     echo 3;
     // Fill transaction data
     $transaction = array('transaction_details' => array('order_id' => rand(), 'gross_amount' => 10000));
     echo 4;
     $vtweb_url = Veritrans_Vtweb::getRedirectionUrl($transaction);
     pr($vtweb_url);
     //        echo $vtweb_url.5;
     // Redirect
     header('Location: ' . $vtweb_url);
     die;
 }
コード例 #11
0
 /**
  * function to post summary of balin checkout
  * 
  * 1. Get Session Cart & transaction
  * 2. Parsing variable
  * 3. Store checkout
  * 4. Check result, send mail
  * 5. Redirect url
  * @return redirect url
  */
 public function vtprocessing($order_id = null)
 {
     //1. Ambil data order detail dari API
     $APIUser = new APIUser();
     $me_order_detail = $APIUser->getMeOrderDetail(['user_id' => Session::get('whoami')['id'], 'order_id' => $order_id]);
     if ($me_order_detail['status'] != 'success') {
         \App::abort(404);
     }
     // Set our server key
     Veritrans_Config::$serverKey = env('VERITRANS_KEY', 'VT_KEY');
     // Uncomment for production environment
     Veritrans_Config::$isProduction = env('VERITRANS_PRODUCTION', false);
     // Comment to disable sanitization
     Veritrans_Config::$isSanitized = true;
     // Comment to disable 3D-Secure
     Veritrans_Config::$is3ds = true;
     // Fill transaction data
     $transaction = ['transaction_details' => ['order_id' => $me_order_detail['data']['ref_number'], 'gross_amount' => $me_order_detail['data']['bills']]];
     $vtweb_url = Veritrans_Vtweb::getRedirectionUrl($transaction);
     Session::forget('veritrans_payment');
     // Redirect
     dd(header('Location: ' . $vtweb_url));
 }