PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : ساخت درگاه ملت برای یک اسکریپت



hannah
October 28th, 2012, 16:12
سلام
میخوام برای یک اسکریپت درگاه آنلاین بانک ملت بسازم
نمونه کل ساخته شده برای پای پال رو گذاشتم
بگید هزینه چقدره

<?php
/*
================================================== ===
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2011 VLD Interactive
================================================== ===
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
================================================== ===
*/


$data = array(
'name' => 'PayPal',
'label' => 'paypal',
'settings' => array(
array(
'name' => 'Email address',
'label' => 'paypal_email',
'type' => 'email',
'items' => array(),
'value' => '',
'help' => 'Type in your PayPal email address.',
),
array(
'name' => 'Currency',
'label' => 'paypal_currency',
'type' => 'select',
'items' => array(
'AUD' => '(AUD) Australian Dollar',
'BRL' => '(BRL) Brazilian Real',
'CAD' => '(CAD) Canadian Dollar',
'CZK' => '(CZK) Czech Koruna',
'DKK' => '(DKK) Danish Krone',
'EUR' => '(EUR) Euro',
'HKD' => '(HKD) Hong Kong Dollar',
'HUF' => '(HUF) Hungarian Forint',
'ILS' => '(ILS) Israeli New Sheqel',
'JPY' => '(JPY) Japanese Yen',
'MYR' => '(MYR) Malaysian Ringgit',
'MXN' => '(MXN) Mexican Peso',
'NOK' => '(NOK) Norwegian Krone',
'NZD' => '(NZD) New Zealand Dollar',
'PHP' => '(PHP) Philippine Peso',
'PLN' => '(PLN) Polish Zloty',
'GBP' => '(GBP) Pound Sterling',
'SGD' => '(SGD) Singapore Dollar',
'SEK' => '(SEK) Swedish Krona',
'CHF' => '(CHF) Swiss Franc',
'TWD' => '(TWD) Taiwan New Dollar',
'THB' => '(THB) Thai Baht',
'USD' => '(USD) U.S. Dollar',
),
'value' => '',
'help' => 'Select preferred currency.',
),
array(
'name' => 'Test mode',
'label' => 'paypal_test',
'type' => 'boolean',
'items' => array(),
'value' => '0',
'help' => 'Enable if you want to run test transactions.',
),
),
);


//------------------------------------------------
// Payment form
//------------------------------------------------
function paypal_payment_form($package_id, $package_name, $package_amount, $package_group_id, $package_credits, $package_term_length, $package_term_type, $package_recurring, $member_gift_id = 0)
{
global $DB, $PREFS, $SESSION, $LANG, $TEMPLATE;


paypal_fetch_settings();


$post_url = $PREFS->conf['gateways']['paypal']['paypal_test'] ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
$notify_url = $PREFS->conf['fancy_urls'] ? 'account/upgrade/ipn/paypal/' : 'index.php?m=account_upgrade&p=ipn&id=paypal';
$return_url = $PREFS->conf['fancy_urls'] ? 'account/upgrade/success/' : 'index.php?m=account_upgrade&p=success';
$cancel_url = $PREFS->conf['fancy_urls'] ? 'account/upgrade/' : 'index.php?m=account_upgrade';


if ( $package_term_type == 1 ) {
$package_term_type = "D";
}
elseif ( $package_term_type == 2 ) {
$package_term_type = "M";
}
elseif ( $package_term_type == 3 ) {
$package_term_type = "Y";
}


if ( $package_recurring ) {
$html = '
<form name="paypal_payment_form" method="post" action="'.$post_url.'">
<input type="image" src="'.VIR_PATH.'media/paypal_button.gif" name="submit" />
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="charset" value="utf8" />
<input type="hidden" name="p3" value="'.$package_term_length.'" />
<input type="hidden" name="t3" value="'.$package_term_type.'" />
<input type="hidden" name="business" value="'.$PREFS->conf['gateways']['paypal']['paypal_email'].'" />
<input type="hidden" name="item_name" value="'.htmlentities2utf8($package_name).'" />
<input type="hidden" name="item_number" value="'.$SESSION->conf['member_id'].'" />
<input type="hidden" name="custom" value="'.$package_id.'" />
<input type="hidden" name="a3" value="'.$package_amount.'" />
<input type="hidden" name="currency_code" value="'.$PREFS->conf['gateways']['paypal']['paypal_currency'].'" />
<input type="hidden" name="cancel_return" value="'.VIR_PATH.$cancel_url.'" />
<input type="hidden" name="return" value="'.VIR_PATH.$return_url.'" />
<input type="hidden" name="notify_url" value="'.VIR_PATH.$notify_url.'" />
</form>';
}
else {
$html = '
<form name="paypal_payment_form" method="post" action="'.$post_url.'">
<input type="image" src="'.VIR_PATH.'media/paypal_button.gif" name="submit" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="charset" value="utf8" />
<input type="hidden" name="business" value="'.$PREFS->conf['gateways']['paypal']['paypal_email'].'" />
<input type="hidden" name="item_name" value="'.htmlentities2utf8($package_name).'" />
<input type="hidden" name="item_number" value="'.$SESSION->conf['member_id'].'" />
<input type="hidden" name="custom" value="'.$package_id.($member_gift_id ? 'x'.$member_gift_id : '').'" />
<input type="hidden" name="amount" value="'.$package_amount.'" />
<input type="hidden" name="currency_code" value="'.$PREFS->conf['gateways']['paypal']['paypal_currency'].'" />
<input type="hidden" name="cancel_return" value="'.VIR_PATH.$cancel_url.'" />
<input type="hidden" name="return" value="'.VIR_PATH.$return_url.'" />
<input type="hidden" name="notify_url" value="'.VIR_PATH.$notify_url.'" />
</form>';
}

return $html;
}


//------------------------------------------------
// Process payment
//------------------------------------------------
function paypal_ipn()
{
global $DB, $PREFS, $SESSION, $LANG, $TEMPLATE;


if ( !count($_POST) ) return;
paypal_fetch_settings();


$success = 0;
$postipn = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$postipn .= "&$key=$value";
}


$socket = @fsockopen(($PREFS->conf['gateways']['paypal']['paypal_test'] ? "www.sandbox.paypal.com" : "www.paypal.com"), 80, $errno, $errstr, 30);
if ( !$socket ) return;


$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header.= "Host: " . ($PREFS->conf['gateways']['paypal']['paypal_test'] ? "www.sandbox.paypal.com" : "www.paypal.com") . "\r\n";
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Content-Length: ".strlen($postipn)."\r\n\r\n";


@fputs($socket, $header.$postipn);
while(!feof($socket))
{
$reply = @fgets($socket, 1024);
$reply = @trim($reply);
}

@fclose ($socket);
if ( strtolower($reply) != "verified" ) return;


$member_id = isset($_POST['item_number']) ? intval($_POST['item_number']) : '';
$txn_id = isset($_POST['txn_id']) ? mysql_real_escape_string($_POST['txn_id']) : '';
$payment_amount = isset($_POST['mc_gross']) ? $_POST['mc_gross'] : '';
$payment_currency = isset($_POST['mc_currency']) ? $_POST['mc_currency'] : '';

$custom = isset($_POST['custom']) ? explode('x', $_POST['custom']) : '';
$package_id = isset($custom[0]) ? intval($custom[0]) : 0;
$member_gift_id = isset($custom[1]) ? mysql_real_escape_string($custom[1]) : 0;


if ( strtolower($_POST['payment_status']) != "completed" || ( strtolower($_POST['txn_type']) != "subscr_payment" && strtolower($_POST['txn_type']) != "web_accept") ) return;
if ( strtolower($_POST['receiver_email']) != strtolower($PREFS->conf['gateways']['paypal']['paypal_email']) && strtolower($_POST['business']) != strtolower($PREFS->conf['gateways']['paypal']['paypal_email']) ) return;


$result = $DB->query("SELECT * FROM " . DB_PREFIX . "packages WHERE package_id='$package_id' LIMIT 1");
if ( !$DB->num_rows($result) ) return;
$obj = $DB->fetch_object($result);

$package_price = $obj->price;
$package_term = $obj->term;
$package_type = $obj->termtype;
$package_credits = $obj->credits;
$new_group_id = $obj->group_id;


$result = $DB->query("SELECT order_id FROM " . DB_PREFIX . "orders WHERE txn_id='paypal".$txn_id."' LIMIT 1");
if ( $DB->num_rows($result) ) return;


if ( $payment_amount != $package_price || strtolower($payment_currency) != strtolower($PREFS->conf['gateways']['paypal']['paypal_currency']) ) return;


$DB->query("INSERT INTO " . DB_PREFIX . "orders (member_id, member_gift_id, package_id, txn_id, paymentdate, amount, credits, term, termtype)
VALUES('$member_id', '$member_gift_id', '$package_id', 'paypal".$txn_id."', '" . time() . "', '$package_price', '$package_credits', '$package_term', '$package_type')");

set_membership_term($member_id, $member_gift_id, $new_group_id, $package_type, $package_term, $package_credits);
}


//------------------------------------------------
// Fetch settings
//------------------------------------------------
function paypal_fetch_settings()
{
global $DB, $PREFS;

$result = $DB->query("SELECT * FROM " . DB_PREFIX . "payment_gateways WHERE label='paypal' LIMIT 1");

if ($DB->num_rows($result))
{
$obj = $DB->fetch_object($result);
$PREFS->conf['gateways']['paypal'] = @unserialize($obj->settings);
}
}


?>

hannah
October 29th, 2012, 12:54
کسی انجام نمیده ؟