11
catalin12345
Re: how to sell virtual products?!or services online?

i`ve founded xassets is not the latest 0.93 or latest release 0.86 is but i think is good!
it haves paypent gateway via paypal!
who can do it for moneybookers?!


12
catalin12345
Re: how to sell virtual products?!or services online?

the file that is in:
html\modules\xasset\class\gateways
Can somebody tell me how to do it for moneybookers?
i`ve heared that normally is not so hard this is the code:
<?php

/* Some of this code is adapted from the OSCommerce paypal payment module */

require_once('baseGateway.php');

class paypal extends baseGateway {
//cons
var $_IPN;
//
function paypal() {
//call code first
$this->code = 'paypal';
//inherited
parent::baseGateway();
//
$this->shortDesc = 'Paypal Gateway';
if (defined('PAYPAL_GATEWAY_DESCRIPTION')) {
$this->description = PAYPAL_GATEWAY_DESCRIPTION;
}
if (defined('PAYPAL_SANDBOX') && PAYPAL_SANDBOX) {
$this->postURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
} else {
$this->postURL = 'https://www.paypal.com/cgi-bin/webscr';
}
$this->_validates = true;
//
$this->_IPN = XOOPS_URL.'/modules/xasset/verify.php';
}
/////////////////////////////////////////////////////
function keys(){
$ary = array( 'PAYPAL_SANDBOX','PAYPAL_ENABLED','PAYPAL_EMAIL_ID','PAYPAL_CURRENCY', 'PAYPAL_GATEWAY_DESCRIPTION', 'PAYPAL_STORE_NAME');
return $ary;
}
/////////////////////////////////////////////////////
function install(){
parent::install();
//
$this->saveField('PAYPAL_SANDBOX',false,1,'Paypal Sandbox Test Mode','b');
$this->saveField('PAYPAL_ENABLED',true,2,'Enable Paypal Module?','b');
$this->saveField('PAYPAL_GATEWAY_DESCRIPTION','Pay with Paypal',3,'Payment Description','s');
$this->saveField('PAYPAL_STORE_NAME','Your Store',4,'Your online store name','s');
$this->saveField('PAYPAL_EMAIL_ID','your@email.com',5,'Paypal identifying email','s');
$this->saveField('PAYPAL_CURRENCY','USD',6,'Default to if unsupported','a','USD,CAD,EUR,GBP,JPY,AUD');
}
/////////////////////////////////////////
function isThisGateway($post) {
//called by verify to determine the gateway type from $_POST... returns order id
$result = false;
//
if (isset($post['item_number'])) {
//could be paypal...confirm
if (isset($post['custom'])) {
//oh yes...
if ($post['custom'] == 'paypal') {
$result = true;
}
}
}
//
if ($result) {
return $post['item_number'];
} else {
return false;
}
}
/////////////////////////////////////////////////////
function processForm() {
global $xoopsUser;
//
$hCurrency =& xoops_getmodulehandler('currency','xasset');
$hOrder =& xoops_getmodulehandler('order','xasset');
$hClient =& xoops_getmodulehandler('userDetails','xasset');
$hCountry =& xoops_getmodulehandler('country','xasset');
//get values
if (isset($_SESSION['orderID'])) {
$order =& $hOrder->get($_SESSION['orderID']);
$client =& $hClient->get($order->getVar('user_detail_id'));
$currency =& $hCurrency->get($order->getVar('currency_id'));
$country =& $hCountry->get($client->getVar('country_id'));
//check if the user selected
$curCode = $currency->getVar('code');
if (!in_array($curCode, array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD'))) {
$curCode = PAYPAL_CURRENCY;
$currency =& $hCurrency->getByCode($curCode);
}
//
$tax = $order->getOrdertaxTotalSum();
$tax = $tax['amount'];
//
$form = $this->drawHidden('cmd', '_xclick') .
$this->drawHidden('business', PAYPAL_EMAIL_ID) .
$this->drawHidden('custom', 'paypal') . //used by isThisGateway to tag this as coming from paypal
$this->drawHidden('item_number',$order->getVar('id')) .
$this->drawHidden('item_name', PAYPAL_STORE_NAME) .
$this->drawHidden('amount', $currency->valueOnlyFormat($order->getOrderNet())) .
$this->drawHidden('quantity', '1') .
$this->drawHidden('tax', $currency->valueOnlyFormat($tax)) .
$this->drawHidden('shipping', '0') .
$this->drawHidden('no_shipping',1) . //this disables the shipping address fields.. comment if not req
$this->drawHidden('first_name', $client->getVar('first_name')) .
$this->drawHidden('last_name', $client->getVar('last_name')) .
$this->drawHidden('address1', $client->getVar('street_address1')) .
$this->drawHidden('address2', $client->getVar('street_address2')) .
$this->drawHidden('city', $client->getVar('town')) .
$this->drawHidden('state', $client->getVar('state')) .
$this->drawHidden('zip', $client->getVar('zip')) .
$this->drawHidden('lc', $country->getVar('iso2')) .
$this->drawHidden('email', $xoopsUser->email()) .
$this->drawHidden('currency_code', $curCode) .
$this->drawHidden('return', $this->_returnURL) .
$this->drawHidden('notify_url', $this->_IPN) .
$this->drawHidden('rm', '2') .
$this->drawHidden('no_note', '1') .
$this->drawHidden('cancel_return', $this->_cancelURL);
//
return $form;
} else {
redirect_header(XOOPS_ROOT_PATH.'/index.php',2,'Error. Cannot find cart.');
}
}
/////////////////////////////////////////
function validateTransaction($orderID, $post) {
parent::validateTransaction($orderID, $post);
//before processing IPN params check a few things like if order value matches
$hOrder =& xoops_getmodulehandler('order','xasset');
$hLog =& xoops_getmodulehandler('gatewayLog','xasset');
$order =& $hOrder->get($orderID);
//if ($order->getOrderTotal('s') == $post['amount']) {
//process return parameters
$fields = $post;
$url = $this->postURL;
$web = parse_url($url);
//
$req = 'cmd=_notify-validate';
foreach ($post as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$postdata = $req;
//
if ($web['scheme'] == "https") {
$web['port']="443";
$ssl="ssl://"; }
else { $web['port']="80"; }
//
$fp = @fsockopen($ssl . $web['host'],$web['port'],$errnum,$errstr,30);
if (!$fp) {
echo "$errnum: $errstr"; }
else {
fputs($fp, "POST $web[path] HTTP/1.1\r\n");
fputs($fp, "Host: $web[host]\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($postdata)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $postdata . "\r\n\r\n");
//
while(!feof($fp)) {
$info[]=@fgets($fp, 1024);
}
//close fp - we are done with it
fclose($fp);
//break up results into a string
$info=implode(",",$info);
$hLog->addLog( $orderID, 1, 3 , $info );
}
return eregi("VERIFIED",$info);
//}
}
////////////////////////////////////////////////
function processReturn(&$oOrder, $post, &$error) {
parent::processReturn(&$oOrder, $post);
//
$hOrder =& xoops_getmodulehandler('order','xasset');
$hCurr =& xoops_getmodulehandler('currency','xasset');
//
//$order =& $hOrder->get($orderID);
$curr =& $hCurr->get($oOrder->getVar('currency_id'));
//
$paypalTrans = $post['txn_id'];
$error = '';
//check for duplicate trans id
if ($hOrder->transactionExists($paypalTrans)) {
$error .= 'Duplicate Transaction\n';
}
//check order amounts
if ($post['payment_status'] != 'Completed') {
$error .= 'Paypal indicated order is Incomplete\n';
}
//check order amount
if ($post['business'] != PAYPAL_EMAIL_ID) {
$error .= 'Receiver Email Incorrect\n';
}
//check order amount
if ( (abs($post['mc_gross'] - $oOrder->getOrderTotal('s')) > 1 )) {
$error .= 'Order total mismatch\n';
}
//check for correct currenc
if ($post['mc_currency'] != $curr->getVar('code')) {
$error .= 'Currency Code Mismatch. Order Aborted.\n';
}
//continue if no error
if (strlen($error) == 0) {
$oOrder->setVar('trans_id',$paypalTrans);
$oOrder->setVar('value',$post['mc_gross']);
$oOrder->setVar('fee',$post['mc_fee']);
//
//if (!$hOrder->insert($oOrder,true)) {
// $err = print_f($hOrder->_db,true);
// $hLog->addLog( $orderID, $order->getVar('gateway_id'),
// $order->orderStatusValidate(), "error : $error with post data : $err" );
//}
//return $hOrder->insert($order,true);
return true;
} else {
//log
$post = print_r($post,true);
//
$hLog =& xoops_getmodulehandler('gatewayLog','xasset');
$hLog->addLog( $orderID, $order->getVar('gateway_id'),
$order->orderStatusValidate(), "error : $error with post data : $post" );
//
return false;
}
}
}

?>
thanks anticipately...


13
catalin12345
Re: how to sell virtual products?!or services online?

does anybody know to do this or help me out?!


14
catalin12345
Re: how to sell virtual products?!or services online?

in that paypal code is writed for xassets:
"Some of this code is adapted from the OSCommerce paypal payment module"
Can somebody tell who knows exactly from what module of osccommerce because they are more for paypal is adapted and an download to see more exactly how it was adapted to check maybe i can make it availble for moneybookers and why not for 2checkout?!


15
catalin12345
Re: how to sell virtual products?!or services online?

does anybody knows from :
http://www.oscommerce.com/community?contributions=&search=paypal&category=1
wich of those paypal module for oscoomerce was adapted the paypal plugin for xasset?!


Login

Who's Online

184 user(s) are online (125 user(s) are browsing Support Forums)


Members: 0


Guests: 184


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits