PHP Code:
<?php
class payzippy extends base
{
var $code, $title, $description, $enabled;
// class constructor
function payzippy()
{
$this->code = 'payzippy';
$this->title = MODULE_PAYMENT_PAYZIPPY_TEXT_TITLE;
$this->description = MODULE_PAYMENT_PAYZIPPY_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_PAYZIPPY_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_PAYZIPPY_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
$this->form_action_url = 'https://www.payzippy.com/payment/api/charging/v1';
}
// class methods
function update_status()
{
global $order, $db;
if (($this->enabled == true) && ((int)MODULE_PAYMENT_PAYZIPPY_ZONE > 0)) {
$check_flag = false;
$check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYZIPPY_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while ($check = mysql_fetch_array($check_query)) {
if ($check['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
}
if ($check_flag == false) {
$this->enabled = false;
}
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type == 'virtual') {
$this->enabled = false;
}
}
}
function javascript_validation()
{
return false;
}
function selection()
{
return array('id' => $this->code , 'module' => $this->title);
}
function pre_confirmation_check()
{
return false;
}
function confirmation()
{
return false;
}
function process_button()
{
global $order, $currencies;
if (MODULE_PAYMENT_PAYZIPPY_CONVERSION == 'Enabled'){
if (DEFAULT_CURRENCY <> 'INR'){
$cOrderTotal = $currencies->get_value("INR") * $order->info['total'];
}
} else {
$cOrderTotal = $order->info['total'];
}
$MerchantId=MODULE_PAYMENT_PAYZIPPY_LOGIN;
$Merchantkeyid=MODULE_PAYMENT_PAYZIPPY_KEY_ID;
$Amount = $cOrderTotal;
$currencyType = "INR";
$OrderId = $_SESSION['customer_id'] . '-' . date('Ymdhis');
$Url = zen_href_link(FILENAME_CHECKOUT_PROCESS,'','SSL',true,false);
$billing_address=$order->customer['street_address'];
$billing_city=$order->customer['city'];
$billing_country=$order->customer['country']['title'];
$billing_name=$order->customer['firstname'].' '.$order->customer['lastname'];
$billing_state=$order->customer['state'];
$billing_zip=$order->customer['postcode'];
$buyer_email_address=$order->customer['email_address'];
$buyer_phone_no=$order->customer['telephone'];
$callback_url=$Url;
$currency=$currencyType;
$hash_method="MD5";
$merchant_id=$MerchantId;
$merchant_key_id=MODULE_PAYMENT_PAYZIPPY_KEY_ID;
$merchant_transaction_id=$OrderId;
$payment_method="CREDIT";
$transaction_amount=$Amount*100;
$transaction_type="SALE";
$securityToken=$_SESSION['securityToken'];
$ui_mode="REDIRECT";
$hash=MODULE_PAYMENT_PAYZIPPY_KEY;
$WorkingKey="$billing_address|$billing_city|$billing_country|$billing_name|$billing_state|$billing_zip|$buyer_email_address|$buyer_phone_no|$callback_url|$currency|$hash_method|$merchant_id|$merchant_key_id|$merchant_transaction_id|$payment_method|$securityToken|$transaction_amount|$transaction_type|$ui_mode|$hash";
$hashed=md5($WorkingKey);
//Variables to be passed to Payzippy as a POST
$process_button_string =zen_draw_hidden_field('billing_address',$billing_address) .
zen_draw_hidden_field('billing_city',$billing_city) .
zen_draw_hidden_field('billing_country',$billing_country) .
zen_draw_hidden_field('billing_name',$billing_name) .
zen_draw_hidden_field('billing_state',$billing_state) .
zen_draw_hidden_field('billing_zip',$billing_zip) .
zen_draw_hidden_field('buyer_email_address', $buyer_email_address) . // Email Address
zen_draw_hidden_field('buyer_phone_no',$buyer_phone_no) .
zen_draw_hidden_field('callback_url',$callback_url) .
zen_draw_hidden_field('currency', $currency) . //INR is default.
zen_draw_hidden_field('hash_method', $hash_method) . //MD5, SHA256
zen_draw_hidden_field('merchant_id',$merchant_id) . //Your MID issued by PayZippy.
zen_draw_hidden_field('merchant_key_id', $merchant_key_id) . //This is the default value.
zen_draw_hidden_field('merchant_transaction_id', $merchant_transaction_id) . //Your Transaction Id
zen_draw_hidden_field('payment_method', $payment_method) . // CREDIT,DEBIT,EMI,NET
zen_draw_hidden_field('transaction_amount', $transaction_amount) . //Amount must be in paise. So, 1 Rupee= 100.
zen_draw_hidden_field('transaction_type', $transaction_type) . //This is the default Value.
zen_draw_hidden_field('ui_mode', $ui_mode) . //REDIRECT/IFRAME.
zen_draw_hidden_field('hash',$hashed);
//echo $process_button_string;
return $process_button_string;
}
function before_process()
{
global $messageStack, $HTTP_POST_VARS;
$bank_name = $_REQUEST['bank_name'];
$fraud_action = $_REQUEST['fraud_action'];
$fraud_details = $_REQUEST['fraud_details'];
$hash_method = $_REQUEST['hash_method'];
$is_international = $_REQUEST['is_international'];
$merchant_id = $_REQUEST['merchant_id'];
$merchant_key_id = $_REQUEST['merchant_key_id'];
$merchant_transaction_id = $_REQUEST['merchant_transaction_id'];
$payment_method = $_REQUEST['payment_method'];
$payzippy_transaction_id = $_REQUEST['payzippy_transaction_id'];
$transaction_amount = $_REQUEST['transaction_amount'];
$transaction_currency = $_REQUEST['transaction_currency'];
$transaction_response_code = $_REQUEST['transaction_response_code'];
$transaction_response_message = $_REQUEST['transaction_response_message'];
$transaction_status = $_REQUEST['transaction_status'];
$transaction_time = $_REQUEST['transaction_time'];
$transaction_type = $_REQUEST['transaction_type'];
$udf1 = $_REQUEST['udf1'];
$udf2 = $_REQUEST['udf2'];
$udf3 = $_REQUEST['udf3'];
$udf4 = $_REQUEST ['udf4'];
$udf5 = $_REQUEST['udf5'];
$version = $_REQUEST['version'];
$hash = MODULE_PAYMENT_PAYZIPPY_KEY;
$AuthDesc=$_REQUEST['transaction_status'];
$recievedhash=$_REQUEST['hash'];
$Workingstring="$bank_name|$fraud_action|$fraud_details|$hash_method|$is_international|$merchant_id|$merchant_key_id|$merchant_transaction_id|$payment_method|$payzippy_transaction_id|$transaction_amount|$transaction_currency|$transaction_response_code|$transaction_response_message|$transaction_status|$transaction_time|$transaction_type|$udf1|$udf2|$udf3|$udf4|$udf5|$version|$hash";
$Checksum=md5($Workingstring);
/*if ($recievedhash == $Checksum)
$Checksum = 'true';
else
$Checksum = 'false';*/
if ($Checksum != $recievedhash) {
$messageStack->add_session('checkout_payment', MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE, 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
}
if ($Checksum == $recievedhash && $AuthDesc == 'FAILED') {
$messageStack->add_session('checkout_payment', MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE, 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
}
if ($Checksum == $recievedhash && $AuthDesc == 'PENDING') {
$messageStack->add_session('checkout_payment', MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE, 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
}
}
function after_process()
{
return false;
}
function output_error()
{
$output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n" . ' <tr>' . "\n" . ' <td class="main"> <font color="#FF0000"><b>' . MODULE_PAYMENT_PAYZIPPY_TEXT_ERROR . '</b></font><br> ' . MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE . ' </td>' . "\n" . ' </tr>' . "\n" . '</table>' . "\n";
return $output_error_string;
}
function check()
{
global $db;
if (! isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYZIPPY_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
function install() {
global $db;
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable payzippy Module', 'MODULE_PAYMENT_PAYZIPPY_STATUS', 'True', 'Do you want to accept payzippy payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant_Id', 'MODULE_PAYMENT_PAYZIPPY_LOGIN', 'Your_PAYZIPPY_ID', 'Merchant ID used for the payzippy service', '6', '2', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYZIPPY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '5', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYZIPPY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '6', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '7', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Currency Converter', 'MODULE_PAYMENT_PAYZIPPY_CONVERSION', 'Enabled', 'Currency Conversion', '6', '10', 'zen_cfg_select_option(array(\'Enabled\', \'Disable\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Working_Key', 'MODULE_PAYMENT_PAYZIPPY_KEY', 'Working_Key', 'put in the alphanumeric key from Payzippy', '6', '3', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant_Key_Id', 'MODULE_PAYMENT_PAYZIPPY_KEY_ID', 'Merchant_Key_Id', 'Given Merchant Key Id', '6', '3', now())");
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_PAYZIPPY_STATUS', 'MODULE_PAYMENT_PAYZIPPY_LOGIN','MODULE_PAYMENT_PAYZIPPY_KEY', 'MODULE_PAYMENT_PAYZIPPY_ZONE', 'MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYZIPPY_SORT_ORDER', 'MODULE_PAYMENT_PAYZIPPY_CONVERSION','MODULE_PAYMENT_PAYZIPPY_KEY_ID');
}
}
?>
Bookmarks