Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

A payment gateway, How to devolope it?


Alexandero

Recommended Posts

Hi,

I have a merchant account with www.paydollar.com. But I don't know how to integrate their payment page into my oscommerce site.

 

I don't want to simple direct the customers to this gateway, because I have multilanguage Os so I want the payment page to be in these languages as Paydollars payment page is only in english.

 

Your suggestions and replies will be very appreciated.

 

Thank you

PM

Link to comment
Share on other sites

Please could anyone just convert this code into Oscommerce vriables? As I was looking for that module, I could only found Zen Cart forums.

 

Thanks a lot.

 

PN: This code will be helpful for everyone looking for Paydollar gateway module.

 

 

 

<?php
/**
* paydollar.php payment module class for Paypal IPN payment method
* created by: Emmanuel L. Bautista for Zen Cart
* email: [email protected]
* Copyright June 2006
*/


/**
* paydollar pyment method class
*
*/
class paydollar extends base {
 /**
  * string repesenting the payment method
  *
  * @var string
  */
 var $code;
 /**
  * $title is the displayed name for this payment method
  *
  * @var string
*/
 var $title;
 /**
  * $description is a soft name for this payment method
  *
  * @var string
*/
 var $description;
 /**
  * $enabled determines whether this module shows or not... in catalog.
  *
  * @var boolean
*/
 var $enabled;
 /**
* constructor
*
* @param int $paypal_ipn_id
* @return paypal
*/
 function paydollar() {
global $order;

$this->code = 'paydollar';
if ($_GET['main_page'] != '') {
  $this->title = MODULE_PAYMENT_PAYDOLLAR_TEXT_CATALOG_TITLE; // Payment module title in Catalog
} else {
  $this->title = MODULE_PAYMENT_PAYDOLLAR_TEXT_ADMIN_TITLE; // Payment module title in Admin
}
$this->description = MODULE_PAYMENT_PAYDOLLAR_TEXT_DESCRIPTION;
$this->enabled = ((MODULE_PAYMENT_PAYDOLLAR_STATUS == 'True') ? true : false);
$this->sort_order = MODULE_PAYMENT_PAYDOLLAR_SORT_ORDER;

if ((int)MODULE_PAYMENT_PAYDOLLAR_ORDER_STATUS_ID > 0) {
  $this->order_status = MODULE_PAYMENT_PAYDOLLAR_ORDER_STATUS_ID;
}

if (is_object($order)) $this->update_status();

$this->form_action_url = MODULE_PAYMENT_PAYDOLLAR_HANDLER;
 }
 /**
  * calculate zone matches and flag settings to determine whether this module should display to customers or not
*
*/
 function update_status() {
	 global $order, $db;

if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYDOLLAR_ZONE > 0) ) {
  $check_flag = false;
  $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYDOLAR_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
  while (!$check->EOF) {
	if ($check->fields['zone_id'] < 1) {
	  $check_flag = true;
	  break;
	} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
	  $check_flag = true;
	  break;
	}
	$check->MoveNext();
  }

  if ($check_flag == false) {
	$this->enabled = false;
  }
}
 }
 /**
  * JS validation which does error-checking of data-entry if this module is selected for use
  * (Number, Owner, and CVV Lengths)
  *
  * @return string
*/
 function javascript_validation() {

 }
 /**
  * Displays Credit Card Information Submission Fields on the Checkout Payment Page
  * In the case of paypal, this only displays the paypal title
  *
  * @return array
*/
 function selection() {
  return array('id' => $this->code,
			 'module' => $this->title);
 }
 /**
  * Normally evaluates the Credit Card Type for acceptance and the validity of the Credit Card Number & Expiration Date
  * Since paypal module is not collecting info, it simply skips this step.
  *
  * @return boolean
  */
 function pre_confirmation_check() {

 }
 /**
  * Display Credit Card Information on the Checkout Confirmation Page
  * Since none is collected for paypal before forwarding to paypal site, this is skipped
  *
  * @return boolean
*/
 function confirmation() {

 }
 /**
  * Build the data and actions to process when the "Submit" button is pressed on the order-confirmation screen.
  * This sends the data to the payment gateway for processing.
  * (These are hidden fields on the checkout confirmation page)
  *
  * @return string
*/
 function process_button() {
	global $_SERVER, $order;

	$this->totalsum = $order->info['total'];
	$this->orderRef = zen_get_Order_ID(zen_session_id());   // JTD:01/25/06

	/*$process_button_string = zen_draw_hidden_field('merchantId', MODULE_PAYMENT_PAYDOLLAR_ID) .
	zen_draw_hidden_field('amount', $this->totalsum) .
	zen_draw_hidden_field('orderRef', $this->orderRef) .
	zen_draw_hidden_field('currCode', $this->getCurrencyCode) .
	zen_draw_hidden_field('successUrl', zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) . //
	zen_draw_hidden_field('failUrl', zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')) . //
	zen_draw_hidden_field('cancelUrl', zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')) .//
	zen_draw_hidden_field('payType', 'N') .
	zen_draw_hidden_field('lang', $this->getLanguageCode); */

	$process_button_string = '<input type="hidden" name="merchantId" value="'.MODULE_PAYMENT_PAYDOLLAR_ID.'"/>
							  <input type="hidden" name="amount" value="'. $this->totalsum .'" />
							  <input type="hidden" name="orderRef" value="'. $this->orderRef .'"/>
							  <input type="hidden" name="currCode" value="'. $this->getCurrencyCode() .'" />
							  <input type="hidden" name="successUrl" value="'. zen_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL', false) .'"/>
							  <input type="hidden" name="failUrl" value="' . zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_status=failed', 'SSL') . '"/>
							  <input type="hidden" name="cancelUrl" value="'. zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_status=canceled', 'SSL') .'"/>
							  <input type="hidden" name="payType" value="N">
							  <input type="hidden" name="lang" value="'. $this->getLanguageCode() .'">';

 return $process_button_string;

 }
/*“344” - HKD
“840” – USD
“702” – SGD
“156” – CNY (RMB)
“392” – JPY
“901” – TWD
“036” – AUD
“978” – EUR
“826” – GBP
“124” – CAD
 */
 function getCurrencyCode(){

switch (MODULE_PAYMENT_PAYDOLLAR_CURRENCY) {
		case 'Only HKD':  $cur = '344';
				break;
		case 'Only USD':  $cur = '840';
			   break;
		case 'Only SGD':  $cur = '702';
				break;
		case 'Only CNY':  $cur = '156';
				break;
		case 'Only JPY':  $cur = '392';
				break;
		case 'Only TWD':  $cur = '901';
				break;
		case 'Only AUD':  $cur = '036';
				break;
		case 'Only EUR':  $cur = '978';
				break;
		case 'Only GBP':  $cur = '826';
				break;
		case 'Only CAD':  $cur = '124';
				break;
		default:  $cur = '344';

}

return $cur;
 }

 /*
The language of the payment page i.e.
“C” – Traditional Chinese
“E” – English
“X” – Simplified Chinese
“K” – Korean
“J” – Japanese
 */
 function getLanguageCode(){
   switch (MODULE_PAYMENT_PAYDOLLAR_LANGUAGE) {
		case 'Traditional Chinese':  $lang = 'C';
				break;
		case 'English':  $lang = 'E';
			   break;
		case 'Simplified Chinese':  $lang = 'XC';
				break;
		case 'Korean':  $lang = 'K';
				break;
		case 'Japanese':  $lang = 'J';
				break;
		default:  $lang = 'E';

}

return $lang;
 }
 /**
  * Store transaction info to the order and process any results that come back from the payment gateway
*
*/
 function before_process() {

 }
 /**
* Checks referrer
*
* @param string $zf_domain
* @return boolean
*/
 function check_referrer($zf_domain) {

 }
 /**
* Build admin-page components
*
* @param int $zf_order_id
* @return string
*/
 function admin_notification($zf_order_id) {

 }
 /**
  * Post-processing activities
  *
  * @return boolean
*/
 function after_process() {

 }
 /**
  * Used to display error message details
  *
  * @return boolean
*/
 function output_error() {

 }
 /**
  * Check to see whether module is installed
  *
  * @return boolean
*/
 function check() {
   global $db;
if (!isset($this->_check)) {
  $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYDOLLAR_STATUS'");
  $this->_check = $check_query->RecordCount();
}
return $this->_check;
 }
 /**
  * Install the payment module and its configuration settings
*
*/
 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 PayDollar Module', 'MODULE_PAYMENT_PAYDOLLAR_STATUS', 'True', 'Do you want to accept Paydollar payments?', '6', '0', '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 ('PayDollar ID', 'MODULE_PAYMENT_PAYDOLLAR_ID', '1', 'The merchant id used for the Paydollar service', '6', '0', 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 ('Transaction Currency', 'MODULE_PAYMENT_PAYDOLLAR_CURRENCY', 'Selected Currency', 'Choose the currency/currencies you want to accept', '6', '0', 'zen_cfg_select_option(array(\'Selected Currency\',\'Only HKD\',\'Only USD\',\'Only SGD\',\'Only CNY\',\'Only JPY\',\'Only TWD\',\'Only AUD\',\'Only EUR\',\'Only GBP\',\'Only CAD\'), ', 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 ('Transaction Currency', 'MODULE_PAYMENT_PAYDOLLAR_LANGUAGE', 'Selected Language', 'Choose the currency/currencies you want to accept', '6', '0', 'zen_cfg_select_option(array(\'Selected Language\',\'Trad Chinese\',\'English\',\'Simplified Chinese\',\'Korean\',\'Japanese\'), ', 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_PAYDOLLAR_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', '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, date_added) values ('Paydollar server', 'MODULE_PAYMENT_PAYDOLLAR_HANDLER', 'https://www.paydollar.com/b2c2/eng/payment/payForm.jsp', 'Type the server that will handle the transaction. The default is <code>https://www.paydollar.com/b2c2/eng/payment/payForm.jsp</code>', '6', '0', now())");
 }
 /**
  * Remove the module and all its settings
*
*/
 function remove() {
  global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

 }
 /**
  * Internal list of configuration keys used for configuration of the module
  *
  * @return array
*/
 function keys() {
	   return array('MODULE_PAYMENT_PAYDOLLAR_STATUS', 'MODULE_PAYMENT_PAYDOLLAR_ID', 'MODULE_PAYMENT_PAYDOLLAR_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYDOLLAR_CURRENCY','MODULE_PAYMENT_PAYDOLLAR_LANGUAGE', 'MODULE_PAYMENT_PAYDOLLAR_HANDLER');
 }
}
?>

Link to comment
Share on other sites

If there is not one available in the contributions you can;

1) Write one yourself.

2) Pay someone to write one for you.

3) Email the company, they might already have one done.

4) Switch payment processors, there is a module for 2000Charge.

Link to comment
Share on other sites

I tried to hire someone but their rates are too high especially that I have all the codes. Therefore, even if I am not a coder and never coded, I just modifed some codes of the code above then I arrived to install it, and I am almost done. I can see it on Admin and catalogue sides, but I receive an error on the payment gateway. There is a parameter missing. I don't know how to add it :(

 

Any help please?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...