function dibspayment_paywin_order_params($cart) { global $wpdb; $order_data = array(); $purchase_log = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $cart->sessionid . " LIMIT 1", ARRAY_A); $currency_code = $wpdb->get_results("SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A); // Set status on new order $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . get_option('dibspw_statusp') . "' WHERE `sessionid` = '" . $cart->sessionid . "' LIMIT 1;"); // collect data for request $order_data['orderid'] = $purchase_log[0]['id']; $order_data['merchant'] = get_option('dibspw_mid'); $order_data['amount'] = dibspayment_paywin_round($cart->total_price); $order_data['currency'] = $currency_code[0]['code']; $order_data['language'] = get_option('dibspw_lang'); $order_data['oitypes'] = 'QUANTITY;UNITCODE;DESCRIPTION;AMOUNT;ITEMID;VATAMOUNT'; $order_data['oinames'] = 'Qty;UnitCode;Description;Amount;ItemId;VatAmount'; $order_data['oinames'] = 'Qty;UnitCode;Description;Amount;ItemId;VatAmount'; $wpec_taxes_c = new wpec_taxes_controller(); //$tax_total = $wpec_taxes_c->wpec_taxes_calculate_total(); //get the rate for the country and region if set $tax_total = $wpec_taxes_c->wpec_taxes->wpec_taxes_get_rate($wpec_taxes_c->wpec_taxes_retrieve_selected_country(), $wpec_taxes_c->wpec_taxes_retrieve_region()); // cart items $i = 1; foreach ($cart->cart_items as $oitem) { $tmp_price = dibspayment_paywin_round($oitem->unit_price); if (!empty($tmp_price)) { $unit_price = $oitem->unit_price; $tax['tax'] = 0; if ($wpec_taxes_c->wpec_taxes->wpec_taxes_get_enabled() && $tax_total['rate']) { if ($wpec_taxes_c->wpec_taxes_isincluded()) { $tax = $wpec_taxes_c->wpec_taxes_calculate_included_tax($oitem); $tax['tax'] = $tax['tax'] / $oitem->quantity; $unit_price = $oitem->unit_price - $tax['tax']; } else { $tax['tax'] = $unit_price * ($tax_total['rate'] / 100); } } $tmp_name = !empty($oitem->product_name) ? $oitem->product_name : $oitem->sku; if (empty($tmp_name)) { $tmp_name = $oitem->product_id; } $order_data['oiRow' . $i++] = dibspayment_paywin_oirow_str($oitem->quantity, dibspayment_paywin_utf8Fix(str_replace(";", "\\;", $tmp_name)), dibspayment_paywin_round($unit_price), dibspayment_paywin_utf8Fix(str_replace(";", "\\;", $oitem->product_id)), dibspayment_paywin_round($tax['tax'])); } unset($tmp_price, $tmp_name); } // Shipping calculation if ($cart->calculate_total_shipping()) { $shipping_tax = 0; $fRate = $cart->calculate_total_shipping(); if ($tax_total['shipping'] && $wpec_taxes_c->wpec_taxes->wpec_taxes_get_enabled()) { if ($wpec_taxes_c->wpec_taxes_isincluded()) { $shipping_tax = $wpec_taxes_c->wpec_taxes_calculate_tax($cart->calculate_total_shipping(), $tax_total['rate'], false); $fRate = $fRate - $shipping_tax; } else { $shipping_tax = $wpec_taxes_c->wpec_taxes_calculate_tax($cart->calculate_total_shipping(), $tax_total['rate']); } } $order_data['oiRow' . $i++] = dibspayment_paywin_oirow_str(1, "Shipping", dibspayment_paywin_round($fRate), "shipping_0", dibspayment_paywin_round($shipping_tax)); } // Cupone if it is avaliable if ($cart->coupons_amount > 0) { $order_data['oiRow' . $i++] = dibspayment_paywin_oirow_str(1, "Coupon", -dibspayment_paywin_round($cart->coupons_amount), "coupon_0", 0); } // Address fields here.. $aAddr = $_POST['collected_data']; $order_data['shippingfirstname'] = $aAddr[get_option('dibspw_form_first_name_d')]; $order_data['shippinglastname'] = $aAddr[get_option('dibspw_form_last_name_d')]; $order_data['shippingpostalcode'] = $aAddr[get_option('dibspw_form_post_code_d')]; $order_data['shippingpostalplace'] = $aAddr[get_option('dibspw_form_city_d')]; //$order_data['shippingaddress2'] = $aAddr[get_option('dibspw_form_address_d')]; $order_data['shippingaddress'] = $aAddr[get_option('dibspw_form_country_d')] . " " . $aAddr[get_option('dibspw_form_state_d')]; $order_data['billingfirstname'] = $aAddr[get_option('dibspw_form_first_name_b')]; $order_data['billinglastname'] = $aAddr[get_option('dibspw_form_last_name_b')]; $order_data['billingpostalcode'] = $aAddr[get_option('dibspw_form_post_code_b')]; $order_data['billingpostalplace'] = $aAddr[get_option('dibspw_form_city_b')]; $order_data['billingaddress'] = $aAddr[get_option('dibspw_form_address_b')]; //$order_data['billingaddress'] = $aAddr[get_option('dibspw_form_country_b')]. " " . // $aAddr[get_option('dibspw_form_state_b')]; $order_data['billingmobile'] = $aAddr[get_option('dibspw_form_phone_b')]; $order_data['billingemail'] = $aAddr[get_option('dibspw_form_email_b')]; $order_data['acceptreturnurl'] = get_option('siteurl') . "/?dibspw_result=success"; $order_data['cancelreturnurl'] = site_url() . "/?dibspw_result=cancel"; $order_data['callbackurl'] = get_option('siteurl') . "/?dibspw_result=callback"; $order_data['s_callbackfix'] = get_option('siteurl') . "/?dibspw_result=callback"; $order_data['s_sysmod'] = DIBS_SYSMOD; if (get_option('dibspw_testmode')) { $order_data['test'] = 1; } if (get_option('dibspw_capturenow')) { $order_data['capturenow'] = 1; } if (get_option('dibspw_fee')) { $order_data['addfee'] = 1; } $order_data['s_pid'] = $cart->sessionid; if (get_option('dibspw_account')) { $order_data['account'] = get_option('dibspw_account'); } if (get_option('dibspw_paytype')) { $order_data['paytype'] = get_option('dibspw_paytype'); } if (get_option('dibspw_pid')) { $order_data['s_partnerid'] = get_option('dibspw_pid'); } if ($hmac = get_option('dibspw_hmac')) { $order_data['MAC'] = dibspayment_paywin_calc_mac($order_data, $hmac, $bUrlDecode = FALSE); } return $order_data; }