<?php
/***************************************************************************
* lw_donate_paypal_functions.php
*
* begin : DEC/28/2006
* copyright : Loewen Exchange - Xiong Zou
* email : hide@address.com
*
* version : 1.0.3 - DEC/28/2006
*
***************************************************************************/
/***************************************************************************
## Terms of Use
##
## All of my MODifications are to use and edit/change for phpBB End Users
##
## Plese DO NOT remove any copyright/licence declaration when using the MODification
##
## I will remain as the sole developer for all my MODifications unless stated otherwise
##
##
## Distribution Terms
##
## All of my MODifications are prohibited to distribute to others without the permission from me.
##
## Plese DO NOT remove any copyright/licence declaration when using the MODification
##
## I will remain as the sole developer for all my MODifications unless stated otherwise
##
## Re-Distribution Terms
##
## If you are distributing WHOLE or PART of my MOD in your MOD Projects or Pre-modded Projects or any other means, you must:
##
## Get the formal authorization from me first.
##
## Plese DO NOT remove any copyright/licence declaration when using the MODification
##
## I will remain as the sole developer for all my MODification unless stated otherwise. Do NOT declare youself as my co-developer
##
## Re-Distribution Terms DOES NOT apply to MOD authors that developing Add-Ons to my MOD. You will be the Add-Ons' Developer/Author
##
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die('Hacking attempt');
exit;
}
function lw_DM_paypal_convert_currency_type_V3($input_currency)
{
$output_currency = $input_currency;
if(strcasecmp($input_currency, 'USD') == 0)
{
$output_currency = 'USD';
}
else if(strcasecmp($input_currency, 'AUD') == 0)
{
$output_currency = 'AUD';
}
else if(strcasecmp($input_currency, 'CAD') == 0)
{
$output_currency = 'CAD';
}
else if(strcasecmp($input_currency, 'CZK') == 0)
{
$output_currency = 'CZK';
}
else if(strcasecmp($input_currency, 'DKK') == 0)
{
$output_currency = 'DKK';
}
else if(strcasecmp($input_currency, 'EUR') == 0)
{
$output_currency = 'EUR';
}
else if(strcasecmp($input_currency, 'HKD') == 0)
{
$output_currency = 'HKD';
}
else if(strcasecmp($input_currency, 'HUF') == 0)
{
$output_currency = 'HUF';
}
else if(strcasecmp($input_currency, 'NZD') == 0)
{
$output_currency = 'NZD';
}
else if(strcasecmp($input_currency, 'NOK') == 0)
{
$output_currency = 'NOK';
}
else if(strcasecmp($input_currency, 'PLN') == 0)
{
$output_currency = 'PLN';
}
else if(strcasecmp($input_currency, 'GBP') == 0)
{
$output_currency = 'GBP';
}
else if(strcasecmp($input_currency, 'SGD') == 0)
{
$output_currency = 'SGD';
}
else if(strcasecmp($input_currency, 'SEK') == 0)
{
$output_currency = 'SEK';
}
else if(strcasecmp($input_currency, 'CHF') == 0)
{
$output_currency = 'CHF';
}
else if(strcasecmp($input_currency, 'JPY') == 0)
{
$output_currency = 'JPY';
}
return $output_currency;
}
function lw_construct_paypal_donation(&$the_template, &$Input_Array)
{
/* Input is passed as array so that later it can be easily extended.
* Example of inut array
* Input_Array = array(
* 'ITEM_NAME' => item_name,
* 'ITEM_NUMBER' => item_number,
* 'AMOUNT_TO_PAY' => amount_to_pay,
* 'CURRENCY_CODE' => currency_code,
* 'RECEIVER_ACCT' => 'admin_account_to_receive_payment',
* 'NOTIFY_URL' => $notifyurl,
* 'RETURN_URL' => 'return_to_url_from_payment_gateway',
* 'CANCEL_RETURN_URL' => 'calcel_return_to_url_from_payment_gateway',
* 'ENABLE_THIS_GATEWAY' => enable_this_gateway,
* 'ENABLE_TEST_MODE' => enable_test_mode,
* 'GATEWAY_FORM_ACTION_URL' => 'gateway_form_url',
* 'PAYMENT_METHOD' => payment_method,
* );
*/
global $user, $config;
$formaction = '';
$lw_submit_hidden_fields = '';
$lw_submit = '';
$user_in_grp_flag = 0;
$j = 0;
if(intval($Input_Array['ENABLE_THIS_GATEWAY']) > 0)
{
$support_currencies = array();
$support_currencies = split("[;,]", $config['paypal_support_currency']);
if( !(in_array($Input_Array['CURRENCY_CODE'], $support_currencies)))
{
return -1;
}
$formaction = 'https://www.paypal.com/cgi-bin/webscr';
$lw_submit = "<input type=\"image\" src=\"./images/paypal_donate.gif\" name=\"submit\" alt=\"\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"currency_code\" value=\"" . $Input_Array['CURRENCY_CODE'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"business\" value=\"" . $Input_Array['RECEIVER_ACCT'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"item_name\" value=\"" . $Input_Array['ITEM_NAME'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"item_number\" value=\"" . $Input_Array['ITEM_NUMBER'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"no_shipping\" value=\"1\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"notify_url\" value=\"" . $Input_Array['NOTIFY_URL'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"return\" value=\"" . $Input_Array['RETURN_URL'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"cancel_return\" value=\"" . $Input_Array['CANCEL_RETURN_URL'] . "\">";
switch($Input_Array['PAYMENT_METHOD'])
{
case PAYMENT_RECURRING_W:
case PAYMENT_RECURRING_M:
case PAYMENT_RECURRING_Q:
case PAYMENT_RECURRING_H:
case PAYMENT_RECURRING_Y:
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"cmd\" value=\"_xclick-subscriptions\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"a3\" value=\"" . $Input_Array['AMOUNT_TO_PAY'] . "\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"no_note\" value=\"1\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"src\" value=\"1\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"sra\" value=\"1\">";
break;
default: //PAYMENT_MANUAL
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"amount\" value=\"" . $Input_Array['AMOUNT_TO_PAY'] . "\">";
break;
}
switch($Input_Array['PAYMENT_METHOD'])
{
case PAYMENT_RECURRING_W:
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"p3\" value=\"1\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"t3\" value=\"W\">";
break;
case PAYMENT_RECURRING_M:
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"p3\" value=\"1\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"t3\" value=\"M\">";
break;
case PAYMENT_RECURRING_Q:
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"p3\" value=\"3\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"t3\" value=\"M\">";
break;
case PAYMENT_RECURRING_H:
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"p3\" value=\"6\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"t3\" value=\"M\">";
break;
case PAYMENT_RECURRING_Y:
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"p3\" value=\"1\">";
$lw_submit_hidden_fields .= "<input type=\"hidden\" name=\"t3\" value=\"Y\">";
break;
default: //PAYMENT_MANUAL
break;
}
$the_template->assign_vars(array(
'LW_PAYPAL_ACTION' => $formaction,
'LW_SUBMIT_HIDDEN_FIELDS' => $lw_submit_hidden_fields,
'LW_SUBMIT_ACTION' => $lw_submit,
'S_LW_PAYPAL_DONATION' => true,
)
);
return 0;
}
return -1;
}
?>