Hi Sinha,
It's very simple in the ccavenue_redirect_form add the following elements to auto populate the billing address on ccavenue payment page.
$form['billing_cust_name'] = array(
'#type' => 'hidden',
'#value' => $name,
);
$form['billing_cust_address'] = array(
'#type' => 'hidden',
'#value' => $address,
);
$form['billing_cust_country'] = array(
'#type' => 'hidden',
'#value' => $country, // it should be the full country name, no short codes
);
$form['billing_cust_tel'] = array(
'#type' => 'hidden',
'#value' => $tel,
);
$form['billing_cust_email'] = array(
'#type' => 'hidden',
'#value' => $email,
);
$form['billing_cust_state'] = array(
'#type' => 'hidden',
'#value' => $state,
);
$form['billing_cust_city'] = array(
'#type' => 'hidden',
'#value' => $city,
);
$form['billing_zip_code'] = array(
'#type' => 'hidden',
'#value' => $zip_code,
);
For shipping add the following form elements:
delivery_cust_name
delivery_cust_address
delivery_cust_country
delivery_cust_tel
delivery_cust_state
delivery_cust_city
delivery_zip_code
Thanks,
Vinoth
Comments
Hi Vinoth,could you please tell me the detail procedure for adding above code? I am pretty much new to PHP.
Thanks.
Which module do you use to integrate ccavenue?
I am using this module: https://drupal.org/project/commerce_ccavenue
In this module there is a function named ccavenue_redirect_form, in that function you should add the above code to make it work.
I have added those function into .module file.But it says undefined variable error, How can i define these variable. Please help me
Thanks Vinoth,it works for me :)
Hi Guys,
This is my code , This works for me well, But i don't recommend to use this
function ccavenue_redirect_form($form, &$form_state, $order, $payment_method) {
$countries = array(
'AF'=>'Afghanistan',
'AL'=>'Albania',
'DZ'=>'Algeria',
'AS'=>'American Samoa',
'AD'=>'Andorra',
'AO'=>'Angola',
'AI'=>'Anguilla',
'AG'=>'Antigua And Barbuda',
'AR'=>'Argentina',
'AM'=>'Armenia',
'AW'=>'Aruba',
'AU'=>'Australia',
'AT'=>'Austria',
'AZ'=>'Azerbaijan',
'BS'=>'Bahamas, The',
'BH'=>'Bahrain',
'BD'=>'Bangladesh',
'BB'=>'Barbados',
'BY'=>'Belarus',
'BE'=>'Belgium',
'BZ'=>'Belize',
'BJ'=>'Benin',
'BM'=>'Bermuda',
'BT'=>'Bhutan',
'BO'=>'Bolivia',
'BA'=>'Bosnia and Herzegovina',
'BW'=>'Botswana',
'BR'=>'Brazil',
'IO'=>'British Virgin Islands',
'BN'=>'Brunei',
'BG'=>'Bulgaria',
'BF'=>'Burkina Faso',
'BI'=>'Burundi',
'KH'=>'Cambodia',
'CM'=>'Cameroon',
'CA'=>'Canada',
'CV'=>'Cape Verde',
'KY'=>'Cayman Islands',
'CF'=>'Central African Republic',
'TD'=>'Chad',
'CL'=>'Chile',
'CN'=>'China',
'CX'=>'Christmas Island',
'CO'=>'Colombia',
'KM'=>'Comoros',
'CG'=>'Congo, Republic of the',
'CD'=>'Congo, Democratic Republic of the',
'CK'=>'Cook Islands',
'CR'=>'Costa Rica',
'CI'=>"Cote D'Ivoire",
'HR'=>'Croatia',
'CU'=>'Cuba',
'CY'=>'Cyprus',
'CZ'=>'Czech Republic',
'DK'=>'Denmark',
'DJ'=>'Djibouti',
'DM'=>'Dominica',
'DO'=>'Dominican Republic',
'TP'=>'East Timor',
'EC'=>'Ecuador',
'EG'=>'Egypt',
'SV'=>'El Salvador',
'GQ'=>'Equatorial Guinea',
'ER'=>'Eritrea',
'EE'=>'Estonia',
'ET'=>'Ethiopia',
'FK'=>'Falkland Islands',
'FO'=>'Faroe Islands',
'FJ'=>'Fiji',
'FI'=>'Finland',
'FR'=>'France',
'GF'=>'French Guiana',
'PF'=>'French Polynesia',
'GA'=>'Gabon',
'GM'=>'Gambia, The',
'GE'=>'Georgia',
'DE'=>'Germany',
'GH'=>'Ghana',
'GI'=>'Gibraltar',
'GR'=>'Greece',
'GL'=>'Greenland',
'GD'=>'Grenada',
'GP'=>'Guadeloupe',
'GU'=>'Guam',
'GT'=>'Guatemala',
'GN'=>'Guinea',
'GW'=>'Guinea-Bissau',
'GY'=>'Guyana',
'HT'=>'Haiti',
'HN'=>'Honduras',
'HU'=>'Hungary',
'IS'=>'Iceland',
'IN'=>'India',
'ID'=>'Indonesia',
'IR'=>'Iran',
'IQ'=>'Iraq',
'IE'=>'Ireland',
'IL'=>'Israel',
'IT'=>'Italy',
'JM'=>'Jamaica',
'JP'=>'Japan',
'JO'=>'Jordan',
'KZ'=>'Kazakhstan',
'KE'=>'Kenya',
'KI'=>'Kiribati',
'KP'=>'Korea, North',
'KR'=>'Korea, South',
'KW'=>'Kuwait',
'KG'=>'Kyrgyzstan',
'LA'=>'Laos',
'LV'=>'Latvia',
'LB'=>'Lebanon',
'LS'=>'Lesotho',
'LR'=>'Liberia',
'LI'=>'Liechtenstein',
'LT'=>'Lithuania',
'LU'=>'Luxembourg',
'MO'=>'Macau',
'MK'=>'Macedonia',
'MG'=>'Madagascar',
'MW'=>'Malawi',
'MY'=>'Malaysia',
'MV'=>'Maldives',
'ML'=>'Mali',
'MT'=>'Malta',
'MH'=>'Marshall Islands',
'MQ'=>'Martinique',
'MR'=>'Mauritania',
'MU'=>'Mauritius',
'YT'=>'Mayotte',
'MX'=>'Mexico',
'FM'=>'Micronesia, Federated States of',
'MD'=>'Moldova',
'MC'=>'Monaco',
'MN'=>'Mongolia',
'MS'=>'Montserrat',
'MA'=>'Morocco',
'MZ'=>'Mozambique',
'NA'=>'Namibia',
'NR'=>'Nauru',
'NP'=>'Nepal',
'NL'=>'Netherlands',
'AN'=>'Netherlands Antilles',
'NC'=>'New Caledonia',
'NZ'=>'New Zealand',
'NI'=>'Nicaragua',
'NE'=>'Niger',
'NG'=>'Nigeria',
'NU'=>'Niue',
'NF'=>'Norfolk Island',
'MP'=>'Northern Mariana Islands',
'NO'=>'Norway',
'OM'=>'Oman',
'PK'=>'Pakistan',
'PW'=>'Palau',
'PA'=>'Panama',
'PG'=>'Papua new Guinea',
'PY'=>'Paraguay',
'PE'=>'Peru',
'PH'=>'Philippines',
'PN'=>'Pitcairn Island',
'PL'=>'Poland',
'PT'=>'Portugal',
'PR'=>'Puerto Rico',
'QA'=>'Qatar',
'RE'=>'Reunion',
'RO'=>'Romania',
'RU'=>'Russia',
'RW'=>'Rwanda',
'SH'=>'Saint Helena',
'KN'=>'Saint Kitts and Nevis',
'LC'=>'Saint Lucia',
'VC'=>'Saint Vincent and the Grenadines',
'WS'=>'Samoa',
'SM'=>'San Marino',
'ST'=>'Sao Tome and Principe',
'SA'=>'Saudi Arabia',
'SN'=>'Senegal',
'SC'=>'Seychelles',
'SL'=>'Sierra Leone',
'SG'=>'Singapore',
'SK'=>'Slovakia',
'SI'=>'Slovenia',
'SB'=>'Solomon Islands',
'SO'=>'Somalia',
'ZA'=>'South Africa',
'ES'=>'Spain',
'LK'=>'Sri Lanka',
'SD'=>'Sudan',
'SR'=>'Suriname',
'SZ'=>'Swaziland',
'SE'=>'Sweden',
'CH'=>'Switzerland',
'SY'=>'Syria',
'TW'=>'Taiwan',
'TJ'=>'Tajikistan',
'TZ'=>'Tanzania',
'TH'=>'Thailand',
'TG'=>'Togo',
'TK'=>'Tokelau',
'TO'=>'Tonga',
'TT'=>'Trinidad And Tobago',
'TN'=>'Tunisia',
'TR'=>'Turkey',
'TM'=>'Turkmenistan',
'TC'=>'Turks and Caicos Islands',
'TV'=>'Tuvalu',
'UG'=>'Uganda',
'UA'=>'Ukraine',
'AE'=>'United Arab Emirates',
'GB'=>'United Kingdom',
'US'=>'United States',
'UY'=>'Uruguay',
'UZ'=>'Uzbekistan',
'VU'=>'Vanuatu',
'VE'=>'Venezuela',
'VN'=>'Vietnam',
'EH'=>'Western Sahara',
'YE'=>'Yemen',
'YU'=>'Yugoslavia, Federal Repubic Of',
'ZM'=>'Zambia',
'ZW'=>'Zimbabwe',
);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$billing = $order_wrapper->commerce_customer_billing->commerce_customer_address->value();
$shipping = $order_wrapper->commerce_customer_shipping->commerce_customer_address->value();
$name = $billing['name_line'];
$address = $billing['thoroughfare']." ".$billing['premise'];
$phone = $billing['mobile_number'];
$e_mail = $order->mail;
$state = $billing['administrative_area'];
$city = $billing['locality'];
$zip_code = $billing['postal_code'];
$chk_country = $billing['country'];
if(isset($countries[$chk_country])){
$my_country = $countries[$chk_country];
}
$dname = $shipping['name_line'];
$daddress = $shipping['thoroughfare']." ".$shipping['premise'];
$dphone = $shipping['mobile_number'];
$de_mail = $order->mail;
$dstate = $shipping['administrative_area'];
$dcity = $shipping['locality'];
$dzip_code = $shipping['postal_code'];
$dchk_country = $shipping['country'];
if(isset($countries[$dchk_country])){
$dmy_country = $countries[$dchk_country];
}
$wrapper = entity_metadata_wrapper('commerce_order', $order);
// Get financial info
$currency_code = $wrapper->commerce_order_total->currency_code->value();
$amount = $wrapper->commerce_order_total->amount->value()/100;
$return_url = url('checkout/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array('absolute' => TRUE));
$merchant_id = $payment_method['settings']['merchant_id'];
$working_key = $payment_method['settings']['working_key'];
$order_id = $order->order_id;
$checksum = _commerce_ccavenue_getchecksum($merchant_id, $amount, $order_id, $return_url, $working_key);
$form['Merchant_Id'] = array(
'#type' => 'hidden',
'#value' => $merchant_id,
);
$form['Amount'] = array(
'#type' => 'hidden',
'#value' => $amount ,
);
$form['Order_Id'] = array(
'#type' => 'hidden',
'#value' => $order_id,
);
$form['Redirect_Url'] = array(
'#type' => 'hidden',
'#value' => $return_url,
);
$form['Checksum'] = array(
'#type' => 'hidden',
'#value' => $checksum,
);
$form['billing_cust_name'] = array(
'#type' => 'hidden',
'#value' => $name,
);
$form['billing_cust_address'] = array(
'#type' => 'hidden',
'#value' => $address,
);
$form['billing_cust_tel'] = array(
'#type' => 'hidden',
'#value' => $phone,
);
$form['billing_cust_country'] = array(
'#type' => 'hidden',
'#value' => $my_country,
);
$form['billing_cust_email'] = array(
'#type' => 'hidden',
'#value' => $e_mail,
);
$form['billing_cust_state'] = array(
'#type' => 'hidden',
'#value' => $state,
);
$form['billing_cust_city'] = array(
'#type' => 'hidden',
'#value' => $city,
);
$form['billing_zip_code'] = array(
'#type' => 'hidden',
'#value' => $zip_code,
);
if($billing == $shipping) {
$form['delivery_cust_name'] = array(
'#type' => 'hidden',
'#value' => $name,
);
$form['delivery_cust_address'] = array(
'#type' => 'hidden',
'#value' => $address,
);
$form['delivery_cust_tel'] = array(
'#type' => 'hidden',
'#value' => $phone,
);
$form['delivery_cust_country'] = array(
'#type' => 'hidden',
'#value' => $my_country,
);
$form['billing_cust_email'] = array(
'#type' => 'hidden',
'#value' => $e_mail,
);
$form['delivery_cust_state'] = array(
'#type' => 'hidden',
'#value' => $state,
);
$form['delivery_cust_city'] = array(
'#type' => 'hidden',
'#value' => $city,
);
$form['delivery_zip_code'] = array(
'#type' => 'hidden',
'#value' => $zip_code,
);
}else{
$form['delivery_cust_name'] = array(
'#type' => 'hidden',
'#value' => $dname,
);
$form['delivery_cust_address'] = array(
'#type' => 'hidden',
'#value' => $daddress,
);
$form['delivery_cust_tel'] = array(
'#type' => 'hidden',
'#value' => $dphone,
);
$form['delivery_cust_country'] = array(
'#type' => 'hidden',
'#value' => $dmy_country,
);
$form['billing_cust_email'] = array(
'#type' => 'hidden',
'#value' => $de_mail,
);
$form['delivery_cust_state'] = array(
'#type' => 'hidden',
'#value' => $dstate,
);
$form['delivery_cust_city'] = array(
'#type' => 'hidden',
'#value' => $dcity,
);
$form['delivery_zip_code'] = array(
'#type' => 'hidden',
'#value' => $dzip_code,
);
}
$form['#action'] = 'https://www.ccavenue.com/shopzone/cc_details.jsp';
return $form;
}
Dear Vinod/Priyanka
Please suggest me to improve this code
Thanks
Sajeev
Thanks Sajeev.. actually it is your code that works..!!