function uc_2checkout_form in Ubercart 5
Same name and namespace in other branches
- 6.2 payment/uc_2checkout/uc_2checkout.module \uc_2checkout_form()
- 7.3 payment/uc_2checkout/uc_2checkout.module \uc_2checkout_form()
1 string reference to 'uc_2checkout_form'
- uc_2checkout_form_alter in payment/
uc_2checkout/ uc_2checkout.module - Implementation of hook_form_alter().
File
- payment/
uc_2checkout/ uc_2checkout.module, line 179 - Integrates 2Checkout.com's redirected payment service.
Code
function uc_2checkout_form($order) {
$country = uc_get_country_data(array(
'country_id' => $order->billing_country,
));
if ($country === FALSE) {
$country = array(
0 => array(
'country_iso_code_3' => 'USA',
),
);
}
$data = array(
'sid' => variable_get('uc_2checkout_sid', ''),
'total' => uc_currency_format($order->order_total, FALSE, FALSE, '.'),
'cart_order_id' => $order->order_id,
'demo' => variable_get('uc_2checkout_demo', TRUE) ? 'Y' : 'N',
'fixed' => 'Y',
'lang' => variable_get('uc_2checkout_language', 'en'),
'x_receipt_link_url' => url('cart/2checkout/complete/' . uc_cart_get_id(), NULL, NULL, TRUE),
'merchant_order_id' => $order->order_id,
'pay_method' => isset($_SESSION['pay_method']) ? $_SESSION['pay_method'] : 'CC',
'card_holder_name' => substr($order->billing_first_name . ' ' . $order->billing_last_name, 0, 128),
'street_address' => substr($order->billing_street1, 0, 64),
'street_address2' => substr($order->billing_street2, 0, 64),
'city' => substr($order->billing_city, 0, 64),
'state' => uc_get_zone_code($order->billing_zone),
'zip' => substr($order->billing_postal_code, 0, 16),
'country' => $country[0]['country_iso_code_3'],
'email' => substr($order->primary_email, 0, 64),
'phone' => substr($order->billing_phone, 0, 16),
'id_type' => 1,
);
$i = 0;
foreach ($order->products as $product) {
$i++;
$data['c_prod_' . $i] = $product->model . ',' . $product->qty;
$data['c_name_' . $i] = $product->title;
$data['c_description_' . $i] = $desc;
$data['c_price_' . $i] = uc_currency_format($product->price, FALSE, FALSE, '.');
}
$form['#action'] = _2checkout_post_url(variable_get('uc_2checkout_checkout_type', 'multi'));
foreach ($data as $name => $value) {
$form[$name] = array(
'#type' => 'hidden',
'#value' => $value,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_2checkout_checkout_button', t('Submit Order')),
);
return $form;
}