Initial commit
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| CubeCart 4
|
||||
| ========================================
|
||||
| CubeCart is a registered trade mark of Devellion Limited
|
||||
| Copyright Devellion Limited 2006. All rights reserved.
|
||||
| Devellion Limited,
|
||||
| 5 Bridge Street,
|
||||
| Bishops Stortford,
|
||||
| HERTFORDSHIRE.
|
||||
| CM23 2JU
|
||||
| UNITED KINGDOM
|
||||
| http://www.devellion.com
|
||||
| UK Private Limited Company No. 5323904
|
||||
| ========================================
|
||||
| Web: http://www.cubecart.com
|
||||
| Email: info (at) cubecart (dot) com
|
||||
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
||||
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
||||
+--------------------------------------------------------------------------
|
||||
| index.inc.php
|
||||
| ========================================
|
||||
| Configure Google Checkout
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if(!defined('CC_INI_SET')){ die("Access Denied"); }
|
||||
|
||||
permission("settings","read",$halt=TRUE);
|
||||
|
||||
require($glob['adminFolder'].CC_DS."includes".CC_DS."header.inc.php");
|
||||
|
||||
if(isset($_POST['module'])){
|
||||
require CC_ROOT_DIR.CC_DS.'modules'.CC_DS.'status.inc.php';
|
||||
$cache = new cache("config.".$moduleName);
|
||||
$cache->clearCache();
|
||||
//$module = fetchDbConfig($moduleName); // Uncomment this is you wish to merge old config with new
|
||||
$module = array(); // Comment this out if you don't want the old config to merge with new
|
||||
$msg = writeDbConf($_POST['module'], $moduleName, $module);
|
||||
|
||||
}
|
||||
$module = fetchDbConfig($moduleName);
|
||||
?>
|
||||
<p><a href="http://checkout.google.com/"><img src="modules/<?php echo $moduleType; ?>/<?php echo $moduleName; ?>/admin/logo.gif" alt="" border="0" title="" /></a></p>
|
||||
<?php
|
||||
if(isset($msg))
|
||||
{
|
||||
echo msg($msg);
|
||||
}
|
||||
|
||||
?>
|
||||
<p class="tdText"><strong>IMPORTANT:</strong> Google Checkouts is not compatible with real time shipping quotes or the shipping methods built into the CubeCart. This because no customer information is captured prior to transferring them to Google. For this reason you must configure custom shipping methods for them and a table of this data is sent to Google. Tax settings will be inherited from your CubeCart stores tax settings.</p>
|
||||
<p class="tdText"><a href='<?php echo $glob['adminFile']."?_g=settings/altShipping";?>' class="txtLink">Configure Google Shipping Methods</a></p>
|
||||
<p>Google Checkout will ONLY function with a valid SSL certificate in operation. The URLS will show below once this has been enabled.</p>
|
||||
<form action="<?php echo $glob['adminFile']; ?>?_g=<?php echo $_GET['_g']; ?>&module=<?php echo $_GET['module']; ?>" method="post" enctype="multipart/form-data">
|
||||
<table border="0" cellspacing="1" cellpadding="3" class="mainTable">
|
||||
<tr>
|
||||
<td colspan="2" class="tdTitle">Configuration Settings </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Status:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[status]">
|
||||
<option value="1" <?php if($module['status']==1) echo "selected='selected'"; ?>>Enabled</option>
|
||||
<option value="0" <?php if($module['status']==0) echo "selected='selected'"; ?>>Disabled</option>
|
||||
</select> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Google merchant ID:</strong></td>
|
||||
<td class="tdText"><input type="text" name="module[merchId]" value="<?php echo $module['merchId']; ?>" class="textbox" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Google merchant key:</strong></td>
|
||||
<td class="tdText"><input type="text" name="module[merchKey]" value="<?php echo $module['merchKey']; ?>" class="textbox" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Mode:</strong></td>
|
||||
<td class="tdText"><select name="module[mode]">
|
||||
<option value="sandbox" <?php if($module['mode'] == "sandbox") echo "selected='selected'"; ?>>SandBox (Testing Environment)</option>
|
||||
<option value="live" <?php if($module['mode'] == "live") echo "selected='selected'"; ?>>Live</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" valign="top" class="tdText"><strong>Send Welcome Email:</strong><br />
|
||||
(Contains user/password for future access)</td>
|
||||
<td class="tdText"><select name="module[welcomeEmail]">
|
||||
<option value="0" <?php if($module['welcomeEmail'] == 0) echo "selected='selected'"; ?>>No</option>
|
||||
<option value="1" <?php if($module['welcomeEmail'] == 1) echo "selected='selected'"; ?>>Yes</option>
|
||||
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Button size:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[size]">
|
||||
<option value="large" <?php if($module['size'] == "large") echo "selected='selected'"; ?>>Large</option>
|
||||
<option value="medium" <?php if($module['size'] == "medium") echo "selected='selected'"; ?>>Medium</option>
|
||||
<option value="small" <?php if($module['size'] == "small") echo "selected='selected'"; ?>>Small</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Debug:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[debug]">
|
||||
<option value="1" <?php if($module['debug'] == 1) echo "selected='selected'"; ?>>Yes</option>
|
||||
<option value="0" <?php if($module['debug'] == 0) echo "selected='selected'"; ?>>No</option>
|
||||
</select> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>API Callback URL: </strong></td>
|
||||
<td class="tdText"><input type="text" value="<?php if($config['ssl']==true) { echo $config['storeURL_SSL']."/index.php?_g=rm&type=altCheckout&cmd=call&module=Google_Checkout"; } else { echo "VALID SSL CONFIGURATION REQUIRED"; } ?>" style="width: 95%;" /><br />
|
||||
Please set callback method to XML. <br />
|
||||
<strong>IMPORTANT:</strong> Google Checkout will ONLY work in Live mode if the API Callback URL is under the HTTPS protocol. You may need to purchase an SSL certificate if your hosting doesn't have this functionality allready.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="tdText"><strong>Public business website:</strong></td>
|
||||
<td class="tdText"><input type="text" value="<?php if($config['ssl']==true) { echo $config['storeURL_SSL']."/index.php?_g=co&_a=confirmed&s=3"; } else { echo "VALID SSL CONFIGURATION REQUIRED"; } ?>" style="width: 95%;" /><br />
|
||||
Customers will be returned here after payment. (Set under the "Settings" tab in the Google Checkout control panel)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right" class="tdText"> </td>
|
||||
<td class="tdText"><input type="submit" class="submit" value="Edit Config" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
BIN
production/modules/altCheckout/Google_Checkout/admin/logo.gif
Normal file
BIN
production/modules/altCheckout/Google_Checkout/admin/logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
183
production/modules/altCheckout/Google_Checkout/button.php
Normal file
183
production/modules/altCheckout/Google_Checkout/button.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//Point to the correct directory
|
||||
//chdir("..");
|
||||
//Include all the required files
|
||||
require_once('library/googlecart.php');
|
||||
require_once('library/googleitem.php');
|
||||
require_once('library/googleshipping.php');
|
||||
require_once('library/googletaxrule.php');
|
||||
require_once('library/googletaxtable.php');
|
||||
|
||||
// Invoke any of the provided use cases
|
||||
class Google_Checkout {
|
||||
|
||||
function buildIt($moduleName="") {
|
||||
|
||||
global $altCheckoutInv, $altShippingPrices, $config, $config_tax_mod, $db, $glob;
|
||||
|
||||
$module = fetchDbConfig($moduleName);
|
||||
|
||||
// Create a new shopping cart object
|
||||
$merchant_id = $module['merchId']; //Your Merchant ID
|
||||
$merchant_key = $module['merchKey']; //Your Merchant Key
|
||||
$server_type = $module['mode'];
|
||||
|
||||
require("classes".CC_DS."cart".CC_DS."order.php");
|
||||
$order = new order();
|
||||
|
||||
$merchant_private_data = array("sessionid" => $GLOBALS[CC_SESSION_NAME],"cart_order_id" => $order->mkOrderNo());
|
||||
$cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $merchant_private_data);
|
||||
|
||||
// Add items to the cart
|
||||
if(is_array($altCheckoutInv)){
|
||||
|
||||
/*
|
||||
$altCheckoutInv[$i]['taxType']; // to work out tax tables
|
||||
$altCheckoutInv[$i]['name'];
|
||||
$altCheckoutInv[$i]['options'];
|
||||
$altCheckoutInv[$i]['quantity'];
|
||||
$altCheckoutInv[$i]['price'];
|
||||
$altCheckoutInv[$i]['private_data']
|
||||
*/
|
||||
|
||||
$taxTypes = array();
|
||||
|
||||
for($i=1;$i<=count($altCheckoutInv);$i++)
|
||||
{
|
||||
|
||||
$item = new GoogleItem($altCheckoutInv[$i]['name'],
|
||||
$altCheckoutInv[$i]['options'],
|
||||
$altCheckoutInv[$i]['quantity'],
|
||||
$altCheckoutInv[$i]['price'],
|
||||
$money = $config['defaultCurrency'],
|
||||
$private_data = $altCheckoutInv[$i]['private_data'],
|
||||
$tax_selector = "rule_".$altCheckoutInv[$i]['taxType']
|
||||
);
|
||||
|
||||
$cart->AddItem($item);
|
||||
|
||||
$taxTypes[$altCheckoutInv[$i]['taxType']] = TRUE;
|
||||
|
||||
}
|
||||
|
||||
// build tax rules and let fun fun commence
|
||||
if(is_array($taxTypes))
|
||||
{
|
||||
|
||||
foreach($taxTypes as $key => $value) {
|
||||
|
||||
if($config_tax_mod['status']==1) {
|
||||
// Google checkout only supports US sellers right now
|
||||
$query = "SELECT t.tax_percent, c.iso, county_id, shipping FROM ".$glob['dbprefix']."CubeCart_tax_rates t LEFT JOIN ".$glob['dbprefix']."CubeCart_iso_countries c ON t.country_id = c.id WHERE `type_id` = 1 AND `active` = 1 AND c.iso = 'US' ORDER BY tax_percent DESC";
|
||||
|
||||
$taxRates = $db->select($query);
|
||||
|
||||
if($taxRates==TRUE) {
|
||||
|
||||
|
||||
for($i=0;$i<count($taxRates);$i++) {
|
||||
|
||||
if($taxRates[$i-1]['tax_percent']!==$taxRates[$i]['tax_percent'] || $i==0) {
|
||||
|
||||
$n=0;
|
||||
|
||||
if($taxRates[$i]['shippping']==1) { $shipping_taxed = "true"; } else { $shipping_taxed = "false"; }
|
||||
|
||||
$tax_rule = new GoogleTaxRule("alternate", ($taxRates[$i]['tax_percent']*0.01), $country_area="", $shipping_taxed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$states[$n] = countyAbbrev($taxRates[$i]['county_id']);
|
||||
$n++;
|
||||
|
||||
if($taxRates[$i]['tax_percent']!==$taxRates[$i+1]['tax_percent']){
|
||||
$tax_rule->SetStateAreas($states);
|
||||
unset($states);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$tax_table = new GoogleTaxTable("alternate","rule_".$key, $standalone = "true");
|
||||
$tax_table->AddTaxRules($tax_rule);
|
||||
$cart->AddTaxTables($tax_table);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$taxRate = $db->select("SELECT percent FROM ".$glob['dbprefix']."CubeCart_taxes WHERE `id` = ".$db->mySQLsafe($key));
|
||||
|
||||
$countryIso = getCountryFormat($config['taxCountry'],"id","iso");
|
||||
|
||||
if($config['taxCounty']==0 && $countryIso == "US"){
|
||||
$country_area = "ALL";
|
||||
} else {
|
||||
$country_area = "";
|
||||
}
|
||||
|
||||
$tax_rule = new GoogleTaxRule("alternate", ($taxRate[0]['percent']*0.01), $country_area, $shipping_taxed="false");
|
||||
|
||||
if($config['taxCounty']>0){
|
||||
$stateCode = countyAbbrev($config['taxCounty']);
|
||||
$tax_rule->SetStateAreas($stateCode);
|
||||
} else {
|
||||
// state required to set country?!!? No sense AT all.
|
||||
$tax_rule->SetStateAreas("FALSE");
|
||||
}
|
||||
|
||||
$tax_table = new GoogleTaxTable("alternate","rule_".$key, $standalone = "true");
|
||||
$tax_table->AddTaxRules($tax_rule);
|
||||
$cart->AddTaxTables($tax_table);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(is_array($altShippingPrices)) {
|
||||
|
||||
for($i=0;$i<count($altShippingPrices);$i++) {
|
||||
$ship = new GoogleShipping($altShippingPrices[$i]['name'], "flat-rate", $altShippingPrices[$i]['price']);
|
||||
$ship->SetAllowedCountryArea("ALL");
|
||||
$cart->AddShipping($ship);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($module['debug']==1) {
|
||||
// echo XML out
|
||||
echo "<pre style='background-color: white; font-family: Courier New, Courier, mono;'><h3>XML -> Google Checkout</h3>".htmlspecialchars($cart->GetXML())."</pre>";
|
||||
}
|
||||
|
||||
// Display Google Checkout button
|
||||
return $cart->CheckoutButtonCode($module['size']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
626
production/modules/altCheckout/Google_Checkout/call.inc.php
Normal file
626
production/modules/altCheckout/Google_Checkout/call.inc.php
Normal file
@@ -0,0 +1,626 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This is the response handler code that will be invoked every time
|
||||
* a notification or request is sent by the Google Server
|
||||
*
|
||||
* To allow this code to receive responses, the url for this file
|
||||
* must be set on the seller page under Settings->Integration as the
|
||||
* "API Callback URL'
|
||||
* Order processing commands can be sent automatically by placing these
|
||||
* commands appropriately
|
||||
*
|
||||
* To use this code for merchant-calculated feedback, this url must be
|
||||
* set also as the merchant-calculations-url when the cart is posted
|
||||
* Depending on your calculations for shipping, taxes, coupons and gift
|
||||
* certificates update parts of the code as required
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CC_INI_SET')){ die("Access Denied"); }
|
||||
|
||||
require_once('library/googleresponse.php');
|
||||
require_once('library/googlemerchantcalculations.php');
|
||||
require_once('library/googleresult.php');
|
||||
|
||||
// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
|
||||
$xml_response = $HTTP_RAW_POST_DATA;
|
||||
if (get_magic_quotes_gpc()){
|
||||
$xml_response = stripslashes($xml_response);
|
||||
}
|
||||
$headers = getallheaders();
|
||||
|
||||
require_once(CC_ROOT_DIR.CC_DS."classes".CC_DS."htmlMimeMail".CC_DS."htmlMimeMail.php");
|
||||
|
||||
// Create new response object
|
||||
$merchant_id = $module['merchId'];
|
||||
$merchant_key = $module['merchKey'];
|
||||
$server_type = $module['mode'];
|
||||
|
||||
$response = new GoogleResponse($merchant_id, $merchant_key, $xml_response, $server_type);
|
||||
$root = $response->root;
|
||||
$data = $response->data;
|
||||
|
||||
function doDebug($extra = ""){
|
||||
|
||||
global $config,$module,$xml_response,$response;
|
||||
|
||||
if($module['debug']==1){
|
||||
// email to storekeeper
|
||||
$mail = new htmlMimeMail();
|
||||
|
||||
$text = print_r($response,true)."\n\n\n".$extra;
|
||||
|
||||
$mail->setText($text);
|
||||
$mail->setReturnPath($config['masterEmail']);
|
||||
$mail->setFrom($config['masterEmail']);
|
||||
$mail->setSubject("Google Checkout Debug XML");
|
||||
$mail->setHeader('X-Mailer', 'CubeCart Mailer');
|
||||
$mail->send(array($config['masterEmail']), $config['mailMethod']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Check status and take appropriate action
|
||||
$status = $response->HttpAuthentication($headers);
|
||||
|
||||
switch ($root){
|
||||
|
||||
case "request-received":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "error":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "diagnosis":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "checkout-redirect":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "merchant-calculation-callback":
|
||||
{
|
||||
// Create the results and send it
|
||||
$merchant_calc = new GoogleMerchantCalculations();
|
||||
|
||||
// Loop through the list of address ids from the callback
|
||||
$addresses = get_arr_result($data[$root]['calculate']['addresses']['anonymous-address']);
|
||||
|
||||
foreach($addresses as $curr_address)
|
||||
{
|
||||
$curr_id = $curr_address['id'];
|
||||
$country = $curr_address['country-code']['VALUE'];
|
||||
$city = $curr_address['city']['VALUE'];
|
||||
$region = $curr_address['region']['VALUE'];
|
||||
$postal_code = $curr_address['region']['VALUE'];
|
||||
|
||||
// Loop through each shipping method if merchant-calculated shipping
|
||||
// support is to be provided
|
||||
if(isset($data[$root]['calculate']['shipping']))
|
||||
{
|
||||
$shipping = get_arr_result($data[$root]['calculate']['shipping']['method']);
|
||||
|
||||
foreach($shipping as $curr_ship)
|
||||
{
|
||||
$name = $curr_ship['name'];
|
||||
//Compute the price for this shipping method and address id
|
||||
$price = 10; // Modify this to get the actual price
|
||||
$shippable = "true"; // Modify this as required
|
||||
$merchant_result = new GoogleResult($curr_id);
|
||||
$merchant_result->SetShippingDetails($name, $price, $config['defaultCurrency'],
|
||||
$shippable);
|
||||
|
||||
if($data[$root]['calculate']['tax']['VALUE'] == "true")
|
||||
{
|
||||
//Compute tax for this address id and shipping type
|
||||
$amount = 15; // Modify this to the actual tax value
|
||||
$merchant_result->SetTaxDetails($amount, $config['defaultCurrency']);
|
||||
}
|
||||
|
||||
$codes = get_arr_result($data[$root]['calculate']['merchant-code-strings']
|
||||
['merchant-code-string']);
|
||||
foreach($codes as $curr_code)
|
||||
{
|
||||
//Update this data as required to set whether the coupon is valid, the code and the amount
|
||||
$coupons = new GoogleCoupons("true", $curr_code['code'], 5, $config['defaultCurrency'], "test2");
|
||||
$merchant_result->AddCoupons($coupons);
|
||||
}
|
||||
$merchant_calc->AddResult($merchant_result);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$merchant_result = new GoogleResult($curr_id);
|
||||
if($data[$root]['calculate']['tax']['VALUE'] == "true")
|
||||
{
|
||||
//Compute tax for this address id and shipping type
|
||||
$amount = 15; // Modify this to the actual tax value
|
||||
$merchant_result->SetTaxDetails($amount, $config['defaultCurrency']);
|
||||
}
|
||||
$codes = get_arr_result($data[$root]['calculate']['merchant-code-strings']
|
||||
['merchant-code-string']);
|
||||
foreach($codes as $curr_code)
|
||||
{
|
||||
//Update this data as required to set whether the coupon is valid, the code and the amount
|
||||
$coupons = new GoogleCoupons("true", $curr_code['code'], 5, $config['defaultCurrency'], "test2");
|
||||
$merchant_result->AddCoupons($coupons);
|
||||
}
|
||||
$merchant_calc->AddResult($merchant_result);
|
||||
}
|
||||
}
|
||||
|
||||
$response->ProcessMerchantCalculations($merchant_calc);
|
||||
break;
|
||||
}
|
||||
case "new-order-notification":
|
||||
{
|
||||
|
||||
////////////////////////////
|
||||
// INSERT ORDER TO DATABASE AND ADD CUSTOMERS
|
||||
/////////
|
||||
|
||||
// multiple items
|
||||
if(isset($data['new-order-notification']['shopping-cart']['items']['item'][0])) {
|
||||
|
||||
$amountofkeys = "multiple";
|
||||
|
||||
$subTotal = 0;
|
||||
// orderInv nees to be a key higher :-/ blame Al for being a dikhed
|
||||
$invKey=1;
|
||||
|
||||
for($i=0;$i<count($data['new-order-notification']['shopping-cart']['items']['item']);$i++) {
|
||||
|
||||
$orderInv[$invKey]['name'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['item-name']['VALUE'];
|
||||
$orderInv[$invKey]['price'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['unit-price']['VALUE'];
|
||||
$orderInv[$invKey]['quantity'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['quantity']['VALUE'];
|
||||
$orderInv[$invKey]['product_options'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['item-description']['VALUE'];
|
||||
// custom data
|
||||
$orderInv[$invKey]['productId'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['merchant-private-item-data']['productid']['VALUE'];
|
||||
$orderInv[$invKey]['productCode'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['merchant-private-item-data']['productcode']['VALUE'];
|
||||
$orderInv[$invKey]['digital'] = $data['new-order-notification']['shopping-cart']['items']['item'][$i]['merchant-private-item-data']['digital']['VALUE'];
|
||||
$orderInv[$invKey]['custom'] = 0;
|
||||
|
||||
$subTotal = $subTotal + $data['new-order-notification']['shopping-cart']['items']['item'][$i]['unit-price']['VALUE'];
|
||||
|
||||
$invKey++;
|
||||
|
||||
}
|
||||
|
||||
// single item
|
||||
} else {
|
||||
|
||||
$amountofkeys = "single";
|
||||
|
||||
$subTotal = 0;
|
||||
// orderInv nees to be a key higher :-/ blame Al
|
||||
$orderInv[1]['name'] = $data['new-order-notification']['shopping-cart']['items']['item']['item-name']['VALUE'];
|
||||
$orderInv[1]['price'] = $data['new-order-notification']['shopping-cart']['items']['item']['unit-price']['VALUE'];
|
||||
$orderInv[1]['quantity'] = $data['new-order-notification']['shopping-cart']['items']['item']['quantity']['VALUE'];
|
||||
$orderInv[1]['product_options'] = $data['new-order-notification']['shopping-cart']['items']['item']['item-description']['VALUE'];
|
||||
// custom data
|
||||
$orderInv[1]['productId'] = $data['new-order-notification']['shopping-cart']['items']['item']['merchant-private-item-data']['productid']['VALUE'];
|
||||
$orderInv[1]['productCode'] = $data['new-order-notification']['shopping-cart']['items']['item']['merchant-private-item-data']['productcode']['VALUE'];
|
||||
$orderInv[1]['digital'] = $data['new-order-notification']['shopping-cart']['items']['item']['merchant-private-item-data']['digital']['VALUE'];
|
||||
$orderInv[1]['custom'] = 0;
|
||||
|
||||
$subTotal = $subTotal + $data['new-order-notification']['shopping-cart']['items']['item']['unit-price']['VALUE'];
|
||||
}
|
||||
|
||||
|
||||
// insert/update customer
|
||||
|
||||
$email = $data['new-order-notification']['buyer-billing-address']['email']['VALUE'];
|
||||
|
||||
$customer = $db->select("SELECT `customer_id` FROM ".$glob['dbprefix']."CubeCart_customer WHERE `email` = ".$db->MySQLSafe($email));
|
||||
|
||||
// update data
|
||||
$billingCountryId = getCountryFormat($data['new-order-notification']['buyer-billing-address']['country-code']['VALUE'],"iso","id");
|
||||
|
||||
function name($fullName,$key)
|
||||
{
|
||||
|
||||
$fullNameArray = explode(" ",$fullName);
|
||||
$maxKey = count($fullNameArray)-1;
|
||||
|
||||
switch ($key)
|
||||
{
|
||||
case 0:
|
||||
return $fullNameArray[$key];
|
||||
break;
|
||||
case 1:
|
||||
|
||||
$first = "";
|
||||
for($i=0;$i<count($fullNameArray);$i++)
|
||||
{
|
||||
if($i!==0 && $i!==$maxKey)
|
||||
{
|
||||
$first .=$fullNameArray[$i]." ";
|
||||
}
|
||||
}
|
||||
|
||||
return trim($first);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return $fullNameArray[$maxKey];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$customerData['title'] = $db->MySQLSafe(name($data['new-order-notification']['buyer-billing-address']['contact-name']['VALUE'],0));
|
||||
$customerData['firstName'] = $db->MySQLSafe(name($data['new-order-notification']['buyer-billing-address']['contact-name']['VALUE'],1));
|
||||
$customerData['lastName'] = $db->MySQLSafe(name($data['new-order-notification']['buyer-billing-address']['contact-name']['VALUE'],2));
|
||||
$customerData['add_1'] = $db->MySQLSafe($data['new-order-notification']['buyer-billing-address']['address1']['VALUE']);
|
||||
$customerData['add_2'] = $db->MySQLSafe($data['new-order-notification']['buyer-billing-address']['address2']['VALUE']);
|
||||
$customerData['town'] = $db->MySQLSafe($data['new-order-notification']['buyer-billing-address']['city']['VALUE']);
|
||||
$customerData['county'] = $db->MySQLSafe($data['new-order-notification']['buyer-billing-address']['region']['VALUE']);
|
||||
$customerData['postcode'] = $db->MySQLSafe($data['new-order-notification']['buyer-billing-address']['postal-code']['VALUE']);
|
||||
$customerData['country'] = $db->MySQLSafe($billingCountryId);
|
||||
$customerData['phone'] = $db->MySQLSafe($data['new-order-notification']['buyer-billing-address']['phone']['VALUE']);
|
||||
|
||||
if($data['new-order-notification']['buyer-marketing-preferences']['email-allowed']['VALUE'] == "true")
|
||||
{
|
||||
$customerData['optIn1st'] = 1;
|
||||
}
|
||||
|
||||
if($customer==TRUE)
|
||||
{
|
||||
$db->update($glob['dbprefix']."CubeCart_customer",$customerData,"`email` = ".$db->MySQLSafe($email));
|
||||
$customer_id = $customer[0]['customer_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// added insert data
|
||||
$password = randomPass(6);
|
||||
$customerData['password'] = $db->MySQLSafe(md5($password));
|
||||
$customerData['email'] = $db->MySQLSafe($email);
|
||||
$customerData['regTime'] = $db->MySQLSafe(time());
|
||||
$customerData['ipAddress'] = $db->MySQLSafe(get_ip_address()); // this will be googles IP :-/
|
||||
// ghost membership
|
||||
$customerData['type'] = $db->MySQLSafe(2);
|
||||
|
||||
// send welcome email
|
||||
if($module['welcomeEmail']==true) {
|
||||
|
||||
$emailLang = getLang("email.inc.php");
|
||||
|
||||
$mail = new htmlMimeMail();
|
||||
|
||||
$macroArray = array(
|
||||
|
||||
"CUSTOMER_NAME" => $data['new-order-notification']['buyer-billing-address']['contact-name']['VALUE'],
|
||||
"EMAIL" => $email,
|
||||
"PASSWORD" => $password,
|
||||
"STORE_URL" => $glob['storeURL'],
|
||||
"SENDER_IP" => get_ip_address()
|
||||
|
||||
);
|
||||
|
||||
$text = macroSub($lang['email']['new_reg_body'],$macroArray);
|
||||
unset($macroArray);
|
||||
|
||||
$mail->setText($text);
|
||||
$mail->setReturnPath($email);
|
||||
$mail->setFrom($config['masterName'].' <'.$config['masterEmail'].'>');
|
||||
$mail->setSubject($emailLang['email']['new_reg_subject']);
|
||||
$mail->setHeader('X-Mailer', 'CubeCart Mailer');
|
||||
$mail->send(array($email), $config['mailMethod']);
|
||||
// full membership
|
||||
$customerData['type'] = $db->MySQLSafe(1);
|
||||
} else {
|
||||
// ghost membership
|
||||
$customerData['type'] = $db->MySQLSafe(2);
|
||||
}
|
||||
|
||||
$db->insert($glob['dbprefix']."CubeCart_customer",$customerData);
|
||||
$customer_id = $db->insertid();
|
||||
|
||||
}
|
||||
|
||||
// empty basket and login
|
||||
|
||||
$sessionData['customer_id'] = $db->MySQLSafe($customer_id);
|
||||
$sessionData['basket'] = "''";
|
||||
$sessionData['timeLast'] = $db->MySQLSafe(time());
|
||||
|
||||
$db->update($glob['dbprefix']."CubeCart_sessions",$sessionData,"`sessId` = ".$db->MySQLSafe($data['new-order-notification']['shopping-cart']['merchant-private-data']['sessionid']['VALUE']));
|
||||
|
||||
$orderSum['cart_order_id'] = $data['new-order-notification']['shopping-cart']['merchant-private-data']['cart_order_id']['VALUE'];
|
||||
$orderSum['sec_order_id'] = $data['new-order-notification']['google-order-number']['VALUE'];
|
||||
$orderSum['customer_id'] = $customer_id;
|
||||
$orderSum['email'] = $email;
|
||||
$orderSum['name'] = $data['new-order-notification']['buyer-billing-address']['contact-name']['VALUE'];
|
||||
$orderSum['add_1'] = $data['new-order-notification']['buyer-billing-address']['address1']['VALUE'];
|
||||
$orderSum['add_2'] = $data['new-order-notification']['buyer-billing-address']['address2']['VALUE'];
|
||||
$orderSum['town'] = $data['new-order-notification']['buyer-billing-address']['city']['VALUE'];
|
||||
$orderSum['county'] = $data['new-order-notification']['buyer-billing-address']['region']['VALUE'];
|
||||
$orderSum['postcode'] = $data['new-order-notification']['buyer-billing-address']['postal-code']['VALUE'];
|
||||
$orderSum['country'] = getCountryFormat($billingCountryId, 'iso', 'printable_name');
|
||||
$orderSum['phone'] = $data['new-order-notification']['buyer-billing-address']['phone']['VALUE'];
|
||||
$orderSum['mobile'] = ""; // unsupported
|
||||
$orderSum['currency'] = $config['defaultCurrency'];
|
||||
|
||||
$orderSum['name_d'] = $data['new-order-notification']['buyer-shipping-address']['contact-name']['VALUE'];
|
||||
$orderSum['add_1_d'] = $data['new-order-notification']['buyer-shipping-address']['address1']['VALUE'];
|
||||
$orderSum['add_2_d'] = $data['new-order-notification']['buyer-shipping-address']['address2']['VALUE'];
|
||||
$orderSum['town_d'] = $data['new-order-notification']['buyer-shipping-address']['city']['VALUE'];
|
||||
$orderSum['county_d'] = $data['new-order-notification']['buyer-shipping-address']['region']['VALUE'];
|
||||
$orderSum['postcode_d'] = $data['new-order-notification']['buyer-shipping-address']['postal-code']['VALUE'];
|
||||
$orderSum['country_d'] = getCountryFormat($data['new-order-notification']['buyer-shipping-address']['country-code']['VALUE'], 'iso', 'printable_name');
|
||||
|
||||
$orderSum['subtotal'] = $subTotal;
|
||||
$orderSum['discount'] = $data['new-order-notification']['order-adjustment']['merchant-codes']['coupon-adjustment']['applied-amount']['VALUE'];
|
||||
$orderSum['total_ship'] = $data['new-order-notification']['order-adjustment']['shipping']['flat-rate-shipping-adjustment']['shipping-cost']['VALUE'];
|
||||
$orderSum['total_tax'] = $data['new-order-notification']['order-adjustment']['total-tax']['VALUE'];
|
||||
$orderSum['prod_total'] = $data['new-order-notification']['order-total']['VALUE'];
|
||||
$orderSum['shipMethod'] = $data['new-order-notification']['order-adjustment']['shipping']['flat-rate-shipping-adjustment']['shipping-name']['VALUE'];
|
||||
|
||||
// notification of coupon used
|
||||
$orderSum['comments'] = $data['new-order-notification']['order-adjustment']['merchant-codes']['coupon-adjustment']['message']['VALUE'];
|
||||
|
||||
//$orderSum['tax'.$i.'_disp'] = $taxes[$i]['display'];
|
||||
//$orderSum['tax'.$i.'_amt'] = $taxes[$i]['amount'];
|
||||
|
||||
$orderSum['gateway'] = "Google Checkout";
|
||||
|
||||
|
||||
doDebug(count($data['new-order-notification']['shopping-cart']['items']['item'])." - \n".$amountofkeys);
|
||||
|
||||
// add order
|
||||
$order->createOrder($orderInv, $orderSum);
|
||||
|
||||
unset($orderInv,$orderSum);
|
||||
|
||||
$transData['status'] = "NEW ORDER";
|
||||
$transData['notes'] = "A new order has been placed using Google Checkout";
|
||||
$transData['order_id'] = $data['new-order-notification']['shopping-cart']['merchant-private-data']['cart_order_id']['VALUE'];
|
||||
$transData['amount'] = $data['new-order-notification']['order-total']['VALUE'];
|
||||
$transData['trans_id'] = $data['new-order-notification']['google-order-number']['VALUE'];
|
||||
$transData['customer_id'] = $customer_id;
|
||||
$transData['gateway'] = "Google Checkout";
|
||||
$order->storeTrans($transData,FALSE);
|
||||
$response->SendAck();
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case "order-state-change-notification":
|
||||
{
|
||||
|
||||
doDebug();
|
||||
|
||||
$response->SendAck();
|
||||
$new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
|
||||
$new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];
|
||||
|
||||
|
||||
$assocData = $db->select("SELECT `customer_id`, `trans_id`, `order_id`, `amount` FROM ".$glob['dbprefix']."CubeCart_transactions WHERE `trans_id` = ".$db->MySQLSafe($data['order-state-change-notification']['google-order-number']['VALUE']));
|
||||
|
||||
$transData = $assocData[0];
|
||||
unset($assocData);
|
||||
$transData['status'] = $new_financial_state;
|
||||
$transData['gateway'] = "Google Checkout";
|
||||
$cart_order_id = $transData['order_id'];
|
||||
|
||||
switch($new_financial_state)
|
||||
{
|
||||
|
||||
case 'REVIEWING':
|
||||
{
|
||||
$order->orderStatus(2,$cart_order_id);
|
||||
|
||||
$transData['notes'] = "REVIEWING is the default financial state for all new orders. Upon receiving a new order, Google reviews the order to confirm that it is chargeable. After determining that the order is chargeable, Google will update the financial order state to CHARGEABLE.";
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case 'CHARGEABLE':
|
||||
{
|
||||
|
||||
$order->orderStatus(2,$cart_order_id);
|
||||
//$response->SendProcessOrder($data[$root]['google-order-number']['VALUE'],
|
||||
// $message_log);
|
||||
//$response->SendChargeOrder($data[$root]['google-order-number']['VALUE'],
|
||||
// '', $message_log);
|
||||
|
||||
$transData['notes'] = "The CHARGEABLE state indicates that you may charge the customer for an order.";
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case 'CHARGING':
|
||||
{
|
||||
|
||||
$order->orderStatus(2,$cart_order_id);
|
||||
|
||||
$transData['notes'] = "The CHARGING state indicates that Google is in the process of charging the customer. You may not take any actions on an order in this state. Once the charge is completed, Google will update the financial order state to CHARGED if you charged the customer for the full amount of the order. Google will revert the financial order state to CHARGEABLE if you only partially charged the customer.";
|
||||
|
||||
break;
|
||||
}
|
||||
case 'CHARGED':
|
||||
{
|
||||
/////////////////////
|
||||
// SET ORDER STATUS = PROCESS
|
||||
////
|
||||
$order->orderStatus(3,$cart_order_id);
|
||||
|
||||
$transData['notes'] = "The CHARGED state indicates that you have fully or partially charged the customer for an order. If you have partially charged the customer, the order will still be chargeable until you have charged the customer for the full order amount.
|
||||
|
||||
For partially charged orders, the buyer's account page will display the amount that has been charged.";
|
||||
|
||||
break;
|
||||
}
|
||||
case 'PAYMENT_DECLINED':
|
||||
{
|
||||
|
||||
$order->orderStatus(4,$cart_order_id);
|
||||
|
||||
$transData['notes'] = "The PAYMENT_DECLINED state indicates that Google's effort to authorize or charge the customer's credit card failed. If this happens, Google will email the customer to request a new credit card. The customer will have 72 hours to submit a new card.";
|
||||
|
||||
break;
|
||||
}
|
||||
case 'CANCELLED':
|
||||
{
|
||||
|
||||
$order->orderStatus(6,$cart_order_id);
|
||||
|
||||
$transData['notes'] = "The CANCELLED state indicates that the merchant canceled the order. Once an order is canceled, you may no longer update the order's financial order state.
|
||||
|
||||
You may cancel an order that is in either the CHARGEABLE or the PAYMENT_DECLINED financial state. You may not cancel an order that has already been charged until you have already issued a refund for the offer.";
|
||||
break;
|
||||
|
||||
}
|
||||
case 'CANCELLED_BY_GOOGLE':
|
||||
{
|
||||
|
||||
$order->orderStatus(6,$cart_order_id);
|
||||
//$response->SendBuyerMessage($data[$root]['google-order-number']['VALUE'],
|
||||
// "Sorry, your order is cancelled by Google", true, $message_log);
|
||||
|
||||
$transData['notes'] = "The CANCELLED_BY_GOOGLE state indicates that Google canceled an order. Google may cancel an order if the credit card authorization fails and the customer does not provide a new credit card within 72 hours.";
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
$order->storeTrans($transData,FALSE);
|
||||
|
||||
//$transData['status'] = $new_fulfillment_order;
|
||||
|
||||
/*
|
||||
|
||||
switch($new_fulfillment_order)
|
||||
{
|
||||
|
||||
case 'NEW':
|
||||
{
|
||||
//$transData['notes'] = "NEW is the default fulfillment state for all new orders.";
|
||||
break;
|
||||
}
|
||||
case 'PROCESSING':
|
||||
{
|
||||
//$transData['notes'] = "The PROCESSING fulfillment state indicates that you are in the process of filling the customer's order.";
|
||||
break;
|
||||
}
|
||||
case 'DELIVERED':
|
||||
{
|
||||
//$order->orderStatus(3);
|
||||
//$transData['notes'] = "The DELIVERED fulfillment state indicates that you have shipped the order and it has been delivered.";
|
||||
break;
|
||||
}
|
||||
case 'WILL_NOT_DELIVER':
|
||||
{
|
||||
//$transData['notes'] = "The WILL_NOT_DELIVER fulfillment state indicates that you will not ship the items to the customer.";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// $order->storeTrans($transData,FALSE);
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
/*
|
||||
case "charge-amount-notification":
|
||||
{
|
||||
|
||||
//doDebug();
|
||||
|
||||
$response->SendAck();
|
||||
//$response->SendDeliverOrder($data[$root]['google-order-number']['VALUE'],
|
||||
// <carrier>, <tracking-number>, <send-email>, $message_log);
|
||||
//$response->SendArchiveOrder($data[$root]['google-order-number']['VALUE'],
|
||||
// $message_log);
|
||||
break;
|
||||
}
|
||||
case "chargeback-amount-notification":
|
||||
{
|
||||
//doDebug();
|
||||
$response->SendAck();
|
||||
break;
|
||||
}
|
||||
case "refund-amount-notification":
|
||||
{
|
||||
//doDebug();
|
||||
$response->SendAck();
|
||||
break;
|
||||
}
|
||||
case "risk-information-notification":
|
||||
{
|
||||
//doDebug();
|
||||
$response->SendAck();
|
||||
break;
|
||||
}
|
||||
*/
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* In case the XML API contains multiple open tags
|
||||
with the same value, then invoke this function and
|
||||
perform a foreach on the resultant array.
|
||||
This takes care of cases when there is only one unique tag
|
||||
or multiple tags.
|
||||
Examples of this are "anonymous-address", "merchant-code-string"
|
||||
from the merchant-calculations-callback API
|
||||
*/
|
||||
function get_arr_result($child_node)
|
||||
{
|
||||
|
||||
$result = array();
|
||||
|
||||
if(isset($child_node))
|
||||
{
|
||||
if(is_associative_array($child_node))
|
||||
{
|
||||
$result[] = $child_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($child_node as $curr_node)
|
||||
{
|
||||
$result[] = $curr_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Returns true if a given variable represents an associative array */
|
||||
function is_associative_array( $var )
|
||||
{
|
||||
return is_array( $var ) && !is_numeric( implode( '', array_keys( $var ) ) );
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,453 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is used to create a Google Checkout shopping cart and post it
|
||||
* to the Sandbox or Production environment
|
||||
* A very useful function is the CheckoutButtonCode() which returns the HTML
|
||||
* code to post the cart using the standard technique
|
||||
* Refer demo/cartdemo.php for different use case scenarios for this code
|
||||
*/
|
||||
|
||||
class GoogleCart {
|
||||
var $merchant_id;
|
||||
var $merchant_key;
|
||||
var $server_url;
|
||||
var $schema_url;
|
||||
var $base_url;
|
||||
var $checkout_url;
|
||||
var $checkout_diagnose_url;
|
||||
var $request_url;
|
||||
var $request_diagnose_url;
|
||||
|
||||
var $cart_expiration = "";
|
||||
var $merchant_private_data = "";
|
||||
var $edit_cart_url = "";
|
||||
var $continue_shopping_url = "";
|
||||
var $request_buyer_phone = "";
|
||||
var $merchant_calculated = "";
|
||||
var $merchant_calculations_url = "";
|
||||
var $accept_merchant_coupons = "";
|
||||
var $accept_gift_certificates = "";
|
||||
var $default_tax_table;
|
||||
|
||||
var $item_arr;
|
||||
var $shipping_arr;
|
||||
var $alternate_tax_table_arr;
|
||||
var $xml_data;
|
||||
|
||||
//The Constructor method which requires a merchant id, merchant key
|
||||
//and the operation type(sandbox or checkout)
|
||||
function GoogleCart($id, $key, $server_type ="checkout", $merchant_private_data) {
|
||||
|
||||
$this->merchant_id = $id;
|
||||
$this->merchant_key = $key;
|
||||
|
||||
$this->merchant_private_data = $merchant_private_data;
|
||||
|
||||
if(strtolower($server_type) == "sandbox")
|
||||
// changed from https://sandbox.google.com/ on 17 Jan 2007
|
||||
$this->server_url = "https://sandbox.google.com/checkout/";
|
||||
else
|
||||
$this->server_url= "https://checkout.google.com/";
|
||||
|
||||
$this->schema_url = "http://checkout.google.com/schema/2";
|
||||
$this->base_url = $this->server_url."cws/v2/Merchant/" .
|
||||
$this->merchant_id;
|
||||
$this->checkout_url = $this->base_url . "/checkout";
|
||||
$this->checkout_diagnose_url = $this->base_url .
|
||||
"/checkout/diagnose";
|
||||
$this->request_url = $this->base_url . "/request";
|
||||
$this->request_diagnose_url = $this->base_url .
|
||||
"/request/diagnose";
|
||||
|
||||
//The item, shipping and tax table arrays are initialized
|
||||
$this->item_arr = array();
|
||||
$this->shipping_arr = array();
|
||||
$this->alternate_tax_table_arr = array();
|
||||
}
|
||||
|
||||
function SetCartExpiration($cart_expire) {
|
||||
$this->cart_expiration = $cart_expire;
|
||||
}
|
||||
|
||||
function SetMerchantPrivateData($data) {
|
||||
$this->merchant_private_data = $data;
|
||||
}
|
||||
|
||||
function SetEditCartUrl($url) {
|
||||
$this->edit_cart_url= $url;
|
||||
}
|
||||
|
||||
function SetContinueShoppingUrl($url) {
|
||||
$this->continue_shopping_url = $url;
|
||||
}
|
||||
|
||||
function SetRequestBuyerPhone($req) {
|
||||
$this->_SetBooleanValue('request_buyer_phone', $req, "");
|
||||
}
|
||||
|
||||
function SetMerchantCalculations($url, $tax_option = "false" ,
|
||||
$coupons="false",
|
||||
$gift_cert ="false") {
|
||||
$this->merchant_calculations_url = $url;
|
||||
$this->_SetBooleanValue('merchant_calculated', $tax_option, "false");
|
||||
$this->_SetBooleanValue('accept_merchant_coupons', $coupons, "false");
|
||||
$this->_SetBooleanValue('accept_gift_certificates', $gift_cert, "false");
|
||||
}
|
||||
|
||||
function AddItem($google_item) {
|
||||
$this->item_arr[] = $google_item;
|
||||
}
|
||||
|
||||
function AddShipping($ship) {
|
||||
$this->shipping_arr[] = $ship;
|
||||
}
|
||||
|
||||
function AddTaxTables($tax) {
|
||||
if($tax->type == "default")
|
||||
$this->default_tax_table = $tax;
|
||||
else if ($tax->type == "alternate")
|
||||
$this->alternate_tax_table_arr[] = $tax;
|
||||
}
|
||||
|
||||
function GetXML() {
|
||||
|
||||
require_once('xml-processing/xmlbuilder.php');
|
||||
|
||||
$xml_data = new XmlBuilder();
|
||||
|
||||
$xml_data->Push('checkout-shopping-cart',
|
||||
array('xmlns' => $this->schema_url));
|
||||
$xml_data->Push('shopping-cart');
|
||||
|
||||
$xml_data->Push('merchant-private-data');
|
||||
foreach($this->merchant_private_data as $key => $value){
|
||||
$xml_data->Element($key,
|
||||
$value);}
|
||||
$xml_data->Pop('merchant-private-data');
|
||||
|
||||
//Add cart expiration if set
|
||||
if($this->cart_expiration != "") {
|
||||
$xml_data->Push('cart-expiration');
|
||||
$xml_data->Element('good-until-date', $this->cart_expiration);
|
||||
$xml_data->Pop('cart-expiration');
|
||||
}
|
||||
|
||||
//Add XML data for each of the items
|
||||
$xml_data->Push('items');
|
||||
foreach($this->item_arr as $item) {
|
||||
$xml_data->Push('item');
|
||||
$xml_data->Element('item-name', $item->item_name);
|
||||
$xml_data->Element('item-description', $item->item_description);
|
||||
$xml_data->Element('unit-price', $item->unit_price,
|
||||
array('currency'=> $item->currency));
|
||||
$xml_data->Element('quantity', $item->quantity);
|
||||
if($item->merchant_private_data != '')
|
||||
$xml_data->Push('merchant-private-item-data');
|
||||
if(is_array($item->merchant_private_data)){
|
||||
foreach($item->merchant_private_data as $key => $value){
|
||||
$xml_data->Element($key,
|
||||
$value);}}
|
||||
$xml_data->Pop('merchant-private-item-data');
|
||||
if($item->tax_table_selector != '')
|
||||
$xml_data->Element('tax-table-selector', $item->tax_table_selector);
|
||||
$xml_data->Pop('item');
|
||||
}
|
||||
$xml_data->Pop('items');
|
||||
|
||||
$xml_data->Pop('shopping-cart');
|
||||
|
||||
$xml_data->Push('checkout-flow-support');
|
||||
$xml_data->Push('merchant-checkout-flow-support');
|
||||
if($this->edit_cart_url != '')
|
||||
$xml_data->Element('edit-cart-url', $this->edit_cart_url);
|
||||
if($this->continue_shopping_url != '')
|
||||
$xml_data->Element('continue-shopping-url',
|
||||
$this->continue_shopping_url);
|
||||
|
||||
if(count($this->shipping_arr) > 0)
|
||||
$xml_data->Push('shipping-methods');
|
||||
|
||||
//Add the shipping methods
|
||||
foreach($this->shipping_arr as $ship) {
|
||||
//Pickup shipping handled in else part
|
||||
if($ship->type == "flat-rate" ||
|
||||
$ship->type == "merchant-calculated") {
|
||||
$xml_data->Push($ship->type.'-shipping',
|
||||
array('name' => $ship->name));
|
||||
$xml_data->Element('price', $ship->price,
|
||||
array('currency' => $ship->currency));
|
||||
|
||||
//Check if shipping restrictions have been specifd=ied
|
||||
if( $ship->allowed_restrictions ||
|
||||
$ship->excluded_restrictions) {
|
||||
$xml_data->Push('shipping-restrictions');
|
||||
|
||||
//Check if allowed restrictions specified
|
||||
if($ship->allowed_restrictions) {
|
||||
$xml_data->Push('allowed-areas');
|
||||
if($ship->allowed_country_area != "")
|
||||
$xml_data->Element('us-country-area','',
|
||||
array('country-area' =>
|
||||
$ship->allowed_country_area));
|
||||
foreach($ship->allowed_state_areas_arr as $current) {
|
||||
$xml_data->Push('us-state-area');
|
||||
$xml_data->Element('state', $current);
|
||||
$xml_data->Pop('us-state-area');
|
||||
}
|
||||
foreach($ship->allowed_zip_patterns_arr as $current) {
|
||||
$xml_data->Push('us-zip-area');
|
||||
$xml_data->Element('zip-pattern', $current);
|
||||
$xml_data->Pop('us-zip-area');
|
||||
}
|
||||
$xml_data->Pop('allowed-areas');
|
||||
}
|
||||
|
||||
if($ship->excluded_restrictions) {
|
||||
$xml_data->Push('allowed-areas');
|
||||
$xml_data->Pop('allowed-areas');
|
||||
$xml_data->Push('excluded-areas');
|
||||
if($ship->excluded_country_area != "")
|
||||
$xml_data->Element('us-country-area','',
|
||||
array('country-area' =>
|
||||
$ship->excluded_country_area));
|
||||
foreach($ship->excluded_state_areas_arr as $current) {
|
||||
$xml_data->Push('us-state-area');
|
||||
$xml_data->Element('state', $current);
|
||||
$xml_data->Pop('us-state-area');
|
||||
}
|
||||
foreach($ship->excluded_zip_patterns_arr as $current) {
|
||||
$xml_data->Push('us-zip-area');
|
||||
$xml_data->Element('zip-pattern', $current);
|
||||
$xml_data->Pop('us-zip-area');
|
||||
}
|
||||
$xml_data->Pop('excluded-areas');
|
||||
}
|
||||
$xml_data->Pop('shipping-restrictions');
|
||||
}
|
||||
$xml_data->Pop($ship->type.'-shipping');
|
||||
}
|
||||
else if ($ship->type == "pickup") {
|
||||
$xml_data->Push('pickup', array('name' => $ship->name));
|
||||
$xml_data->Element('price', $ship->price,
|
||||
array('currency' => $ship->currency));
|
||||
$xml_data->Pop('pickup');
|
||||
}
|
||||
}
|
||||
if(count($this->shipping_arr) > 0)
|
||||
$xml_data->Pop('shipping-methods');
|
||||
|
||||
if($this->request_buyer_phone != "")
|
||||
$xml_data->Element('request-buyer-phone-number',
|
||||
$this->request_buyer_phone);
|
||||
|
||||
if($this->merchant_calculations_url != "") {
|
||||
$xml_data->Push('merchant-calculations');
|
||||
$xml_data->Element('merchant-calculations-url',
|
||||
$this->merchant_calculations_url);
|
||||
if($this->accept_merchant_coupons != "")
|
||||
$xml_data->Element('accept-merchant-coupons',
|
||||
$this->accept_merchant_coupons);
|
||||
if($this->accept_gift_certificates != "")
|
||||
$xml_data->Element('accept-gift-certificates',
|
||||
$this->accept_gift_certificates);
|
||||
$xml_data->Pop('merchant-calculations');
|
||||
}
|
||||
|
||||
//Set Default and Alternate tax tables
|
||||
if( (count($this->alternate_tax_table_arr) != 0) || (isset($this->default_tax_table))) {
|
||||
if($this->merchant_calculated != "")
|
||||
$xml_data->Push('tax-tables', array('merchant-calculated' => $this->merchant_calculated));
|
||||
else
|
||||
$xml_data->Push('tax-tables');
|
||||
|
||||
if(isset($this->default_tax_table)) {
|
||||
$curr_table = $this->default_tax_table;
|
||||
foreach($curr_table->tax_rules_arr as $curr_rule) {
|
||||
|
||||
|
||||
$xml_data->Push('default-tax-table');
|
||||
$xml_data->Push('tax-rules');
|
||||
foreach($curr_rule->state_areas_arr as $current) {
|
||||
$xml_data->Push('default-tax-rule');
|
||||
|
||||
$xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
|
||||
$xml_data->Element('rate', $curr_rule->tax_rate);
|
||||
$xml_data->Push('tax-area');
|
||||
if($curr_rule->country_area != "")
|
||||
$xml_data->Element('us-country-area','', array('country-area' => $curr_rule->country_area));
|
||||
$xml_data->Push('us-state-area');
|
||||
$xml_data->Element('state', $current);
|
||||
$xml_data->Pop('us-state-area');
|
||||
|
||||
$xml_data->Pop('tax-area');
|
||||
$xml_data->Pop('default-tax-rule');
|
||||
}
|
||||
foreach($curr_rule->zip_patterns_arr as $current) {
|
||||
$xml_data->Push('default-tax-rule');
|
||||
|
||||
$xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
|
||||
$xml_data->Element('rate', $curr_rule->tax_rate);
|
||||
$xml_data->Push('tax-area');
|
||||
|
||||
if($curr_rule->country_area != "")
|
||||
$xml_data->Element('us-country-area','', array('country-area' => $curr_rule->country_area));
|
||||
$xml_data->Push('us-zip-area');
|
||||
$xml_data->Element('zip-pattern', $current);
|
||||
$xml_data->Pop('us-zip-area');
|
||||
$xml_data->Pop('tax-area');
|
||||
$xml_data->Pop('default-tax-rule');
|
||||
}
|
||||
$xml_data->Pop('tax-rules');
|
||||
$xml_data->Pop('default-tax-table');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(count($this->alternate_tax_table_arr) != 0) {
|
||||
$xml_data->Push('alternate-tax-tables');
|
||||
foreach($this->alternate_tax_table_arr as $curr_table) {
|
||||
foreach($curr_table->tax_rules_arr as $curr_rule) {
|
||||
$xml_data->Push('alternate-tax-table',array('standalone' => $curr_table->standalone, 'name' => $curr_table->name));
|
||||
$xml_data->Push('alternate-tax-rules');
|
||||
foreach($curr_rule->state_areas_arr as $current) {
|
||||
$xml_data->Push('alternate-tax-rule');
|
||||
// shipping-taxed not allowed in alternate rules Al B
|
||||
//$xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
|
||||
$xml_data->Element('rate', $curr_rule->tax_rate);
|
||||
$xml_data->Push('tax-area');
|
||||
if($curr_rule->country_area != "")
|
||||
$xml_data->Element('us-country-area','', array('country-area' => $curr_rule->country_area));
|
||||
|
||||
// Google PHP SDK is CRAP
|
||||
if($current!=="FALSE") {
|
||||
$xml_data->Push('us-state-area');
|
||||
$xml_data->Element('state', $current);
|
||||
$xml_data->Pop('us-state-area');
|
||||
}
|
||||
|
||||
$xml_data->Pop('tax-area');
|
||||
$xml_data->Pop('alternate-tax-rule');
|
||||
}
|
||||
foreach($curr_rule->zip_patterns_arr as $current) {
|
||||
$xml_data->Push('alternate-tax-rule');
|
||||
|
||||
//$xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
|
||||
$xml_data->Element('rate', $curr_rule->tax_rate);
|
||||
$xml_data->Push('tax-area');
|
||||
|
||||
if($curr_rule->country_area != "")
|
||||
$xml_data->Element('us-country-area','', array('country-area' => $curr_rule->country_area));
|
||||
$xml_data->Push('us-zip-area');
|
||||
$xml_data->Element('zip-pattern', $current);
|
||||
$xml_data->Pop('us-zip-area');
|
||||
$xml_data->Pop('tax-area');
|
||||
$xml_data->Pop('alternate-tax-rule');
|
||||
}
|
||||
$xml_data->Pop('alternate-tax-rules');
|
||||
$xml_data->Pop('alternate-tax-table');
|
||||
}
|
||||
}
|
||||
$xml_data->Pop('alternate-tax-tables');
|
||||
}
|
||||
$xml_data->Pop('tax-tables');
|
||||
}
|
||||
$xml_data->Pop('merchant-checkout-flow-support');
|
||||
$xml_data->Pop('checkout-flow-support');
|
||||
$xml_data->Pop('checkout-shopping-cart');
|
||||
|
||||
return $xml_data->GetXML();
|
||||
}
|
||||
|
||||
//Code for generating Checkout button
|
||||
function CheckoutButtonCode($size="large", $style="white",
|
||||
$variant="text", $loc="en_US") {
|
||||
|
||||
switch ($size) {
|
||||
case "large":
|
||||
$width = "180";
|
||||
$height = "46";
|
||||
break;
|
||||
|
||||
case "medium":
|
||||
$width = "168";
|
||||
$height = "44";
|
||||
break;
|
||||
|
||||
case "small":
|
||||
$width = "160";
|
||||
$height = "43";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($variant == "text") {
|
||||
$data =
|
||||
"<form method=\"POST\" action=\"". $this->checkout_url . "\" style=\"margin:0px; padding: 0px;\">
|
||||
<input type=\"hidden\" name=\"cart\" value=\"". base64_encode($this->GetXML()) ."\">
|
||||
<input type=\"hidden\" name=\"signature\" value=\"". base64_encode($this->CalcHmacSha1($this->GetXML())). "\">
|
||||
<input type=\"image\" name=\"Checkout\" alt=\"Checkout\"
|
||||
src=\"". $this->server_url."buttons/checkout.gif?merchant_id=".$this->merchant_id."&w=".$width. "&h=".$height."&style=".$style."&variant=".$variant."&loc=".$loc."\"
|
||||
height=\"".$height."\" width=\"".$width. "\" />
|
||||
</form>";
|
||||
} elseif ($variant == "disabled") {
|
||||
$data = "<img alt=\"Checkout\"
|
||||
src=\"". $this->server_url."buttons/checkout.gif?merchant_id=".$this->merchant_id."&w=".$width. "&h=".$height."&style=".$style."&variant=".$variant."&loc=".$loc."\"
|
||||
height=\"".$height."\" width=\"".$width. "\" />";
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//Method which returns the encrypted google cart to make sure that the carts are not tampered with
|
||||
function CalcHmacSha1($data) {
|
||||
$key = $this->merchant_key;
|
||||
$blocksize = 64;
|
||||
$hashfunc = 'sha1';
|
||||
if (strlen($key) > $blocksize) {
|
||||
$key = pack('H*', $hashfunc($key));
|
||||
}
|
||||
$key = str_pad($key, $blocksize, chr(0x00));
|
||||
$ipad = str_repeat(chr(0x36), $blocksize);
|
||||
$opad = str_repeat(chr(0x5c), $blocksize);
|
||||
$hmac = pack(
|
||||
'H*', $hashfunc(
|
||||
($key^$opad).pack(
|
||||
'H*', $hashfunc(
|
||||
($key^$ipad).$data
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return $hmac;
|
||||
}
|
||||
|
||||
//Method used internally to set true/false cart variables
|
||||
function _SetBooleanValue($string, $value, $default) {
|
||||
$value = strtolower($value);
|
||||
if($value== "true" || $value == "false")
|
||||
eval('$this->'.$string.'="'.$value.'";');
|
||||
else
|
||||
eval('$this->'.$string.'="'.$default.'";');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is used to create items to be added to the shopping cart
|
||||
* Invoke a separate instance of this class for each item to be
|
||||
* added to the cart.
|
||||
* Required fields are the item name, description, quantity and price
|
||||
* The private-data and tax-selector for each item can be set in the
|
||||
* constructor call or using individual Set functions
|
||||
*/
|
||||
class GoogleItem {
|
||||
|
||||
var $item_name;
|
||||
var $item_description;
|
||||
var $unit_price;
|
||||
var $currency;
|
||||
var $quantity;
|
||||
var $merchant_private_data;
|
||||
var $tax_table_selector;
|
||||
|
||||
function GoogleItem($name, $desc, $qty, $price, $money= "USD",
|
||||
$private_data = "", $tax_selector = "") {
|
||||
|
||||
global $config;
|
||||
|
||||
$this->item_name = $name;
|
||||
$this->item_description= $desc;
|
||||
$this->unit_price = $price;
|
||||
$this->quantity = $qty;
|
||||
$this->currency= $config['defaultCurrency'];
|
||||
$this->merchant_private_data = $private_data;
|
||||
$this->tax_table_selector= $tax_selector;
|
||||
}
|
||||
|
||||
function SetMerchantPrivateData($private_data) {
|
||||
$this->merchant_private_data = $private_data;
|
||||
}
|
||||
|
||||
function SetTaxTableSelector($tax_selector) {
|
||||
$this->tax_table_selector= $tax_selector;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is used to create the merchant callback results
|
||||
* when a merchant-calculated-feedback structure is received
|
||||
*
|
||||
* Multiple results are generated depending on the possible
|
||||
* combinations for shipping options and address ids
|
||||
*
|
||||
* Refer demo/responsehandler.php for generating these results
|
||||
*/
|
||||
|
||||
class GoogleMerchantCalculations {
|
||||
var $results_arr;
|
||||
var $schema_url = "http://checkout.google.com/schema/2";
|
||||
|
||||
function GoogleMerchantCalculations() {
|
||||
$this->results_arr = array();
|
||||
}
|
||||
|
||||
function AddResult($results) {
|
||||
$this->results_arr[] = $results;
|
||||
}
|
||||
|
||||
function GetXML() {
|
||||
require_once('xml-processing/xmlbuilder.php');
|
||||
|
||||
$xml_data = new XmlBuilder();
|
||||
$xml_data->Push('merchant-calculation-results',
|
||||
array('xmlns' => $this->schema_url));
|
||||
$xml_data->Push('results');
|
||||
|
||||
foreach($this->results_arr as $result) {
|
||||
if($result->shipping_name != "") {
|
||||
$xml_data->Push('result', array('shipping-name' =>
|
||||
$result->shipping_name, 'address-id' => $result->address_id));
|
||||
$xml_data->Element('shipping-rate', $result->ship_price,
|
||||
array('currency' => $result->ship_currency));
|
||||
$xml_data->Element('shippable', $result->shippable);
|
||||
} else
|
||||
$xml_data->Push('result', array('address-id' => $result->address_id));
|
||||
|
||||
if($result->tax_amount != "")
|
||||
$xml_data->Element('total-tax', $result->tax_amount,
|
||||
array('currency' => $result->tax_currency));
|
||||
|
||||
if((count($result->coupon_arr) != 0) ||
|
||||
(count($result->giftcert_arr) != 0) ) {
|
||||
$xml_data->Push('merchant-code-results');
|
||||
|
||||
foreach($result->coupon_arr as $curr_coupon) {
|
||||
$xml_data->Push('coupon-result');
|
||||
$xml_data->Element('valid', $curr_coupon->coupon_valid);
|
||||
$xml_data->Element('code', $curr_coupon->coupon_code);
|
||||
$xml_data->Element('calculated-amount', $curr_coupon->coupon_amount,
|
||||
array('currency'=> $curr_coupon->coupon_currency));
|
||||
$xml_data->Element('message', $curr_coupon->coupon_message);
|
||||
$xml_data->Pop('coupon-result');
|
||||
}
|
||||
foreach($result->giftcert_arr as $curr_gift) {
|
||||
$xml_data->Push('gift-result');
|
||||
$xml_data->Element('valid', $curr_gift->gift_valid);
|
||||
$xml_data->Element('code', $curr_gift->gift_code);
|
||||
$xml_data->Element('calculated-amount', $curr_gift->gift_amount,
|
||||
array('currency'=> $curr_gift->gift_currency));
|
||||
$xml_data->Element('message', $curr_gift->gift_message);
|
||||
$xml_data->Pop('gift-result');
|
||||
}
|
||||
$xml_data->Pop('merchant-code-results');
|
||||
}
|
||||
$xml_data->Pop('result');
|
||||
}
|
||||
$xml_data->Pop('results');
|
||||
$xml_data->Pop('merchant-calculation-results');
|
||||
return $xml_data->GetXML();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is instantiated everytime any notification or
|
||||
* order processing commands are received.
|
||||
*
|
||||
* It has a SendReq function to post different requests to the Google Server
|
||||
* Send functions are provided for most of the commands that are supported
|
||||
* by the server
|
||||
* Refer demo/responsehandlerdemo.php for different use case scenarios
|
||||
* for this code
|
||||
*/
|
||||
class GoogleResponse {
|
||||
var $merchant_id;
|
||||
var $merchant_key;
|
||||
var $server_url;
|
||||
var $schema_url;
|
||||
var $base_url;
|
||||
var $checkout_url;
|
||||
var $checkout_diagnose_url;
|
||||
var $request_url;
|
||||
var $request_diagnose_url;
|
||||
|
||||
var $response;
|
||||
var $root;
|
||||
var $data;
|
||||
var $xml_parser;
|
||||
|
||||
function GoogleResponse($id, $key, $response, $server_type ="checkout") {
|
||||
$this->merchant_id = $id;
|
||||
$this->merchant_key = $key;
|
||||
|
||||
if($server_type == "sandbox")
|
||||
// changed from https://sandbox.google.com/ on 17 Jan 2007
|
||||
$this->server_url = "https://sandbox.google.com/checkout/";
|
||||
else
|
||||
$this->server_url = "https://checkout.google.com/";
|
||||
|
||||
$this->schema_url = "http://checkout.google.com/schema/2";
|
||||
$this->base_url = $this->server_url."cws/v2/Merchant/" .
|
||||
$this->merchant_id;
|
||||
$this->checkout_url = $this->base_url . "/checkout";
|
||||
$this->checkout_diagnose_url = $this->base_url . "/checkout/diagnose";
|
||||
$this->request_url = $this->base_url . "/request";
|
||||
$this->request_diagnose_url = $this->base_url . "/request/diagnose";
|
||||
|
||||
$this->response = $response;
|
||||
|
||||
if(strpos(__FILE__, ':') !== false)
|
||||
$path_delimiter = ';';
|
||||
else
|
||||
$path_delimiter = ':';
|
||||
|
||||
ini_set('include_path', ini_get('include_path').$path_delimiter.'.');
|
||||
require_once('xml-processing/xmlparser.php');
|
||||
$this->xml_parser = new XmlParser($response);
|
||||
$this->root = $this->xml_parser->GetRoot();
|
||||
$this->data = $this->xml_parser->GetData();
|
||||
}
|
||||
|
||||
function HttpAuthentication($headers) {
|
||||
if(isset($headers['Authorization'])) {
|
||||
$auth_encode = $headers['Authorization'];
|
||||
$auth = base64_decode(substr($auth_encode,
|
||||
strpos($auth_encode, " ") + 1));
|
||||
$compare_mer_id = substr($auth, 0, strpos($auth,":"));
|
||||
$compare_mer_key = substr($auth, strpos($auth,":")+1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if($compare_mer_id != $this->merchant_id ||
|
||||
$compare_mer_key != $this->merchant_key)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function SendChargeOrder($google_order, $amount='', $message_log) {
|
||||
|
||||
global $config;
|
||||
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<charge-order xmlns=\"".$this->schema_url.
|
||||
"\" google-order-number=\"". $google_order. "\">";
|
||||
if ($amount != '') {
|
||||
$postargs .= "<amount currency=\"".$config['defaultCurrency']."\">" . $amount . "</amount>";
|
||||
}
|
||||
$postargs .= "</charge-order>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendRefundOrder($google_order, $amount, $reason, $comment, $message_log) {
|
||||
global $config;
|
||||
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<refund-order xmlns=\"".$this->schema_url.
|
||||
"\" google-order-number=\"". $google_order. "\">
|
||||
<reason>". $reason . "</reason>
|
||||
<amount currency=\"".$config['defaultCurrency']."\">".htmlentities($amount)."</amount>
|
||||
<comment>". htmlentities($comment) . "</comment>
|
||||
</refund-order>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendCancelOrder($google_order, $reason, $comment, $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<cancel-order xmlns=\"".$this->schema_url.
|
||||
"\" google-order-number=\"". $google_order. "\">
|
||||
<reason>". htmlentities($reason) . "</reason>
|
||||
<comment>". htmlentities($comment) . "</comment>
|
||||
</cancel-order>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendTrackingData($google_order, $carrier, $tracking_no, $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<add-tracking-data xmlns=\"". $this->schema_url .
|
||||
"\" google-order-number=\"". $google_order . "\">
|
||||
<tracking-data>
|
||||
<carrier>". htmlentities($carrier) . "</carrier>
|
||||
<tracking-number>". $tracking_no . "</tracking-number>
|
||||
</tracking-data>
|
||||
</add-tracking-data>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendMerchantOrderNumber($google_order, $merchant_order, $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<add-merchant-order-number xmlns=\"". $this->schema_url .
|
||||
"\" google-order-number=\"". $google_order . "\">
|
||||
<merchant-order-number>" . $merchant_order .
|
||||
"</merchant-order-number>
|
||||
</add-merchant-order-number>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendBuyerMessage($google_order, $message, $send_mail="true",$message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<send-buyer-message xmlns=\"". $this->schema_url .
|
||||
"\" google-order-number=\"". $google_order . "\">
|
||||
<message>" . $message . "</message>
|
||||
<send-mail>" . $send_mail . "</send-mail>
|
||||
</send-buyer-message>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendProcessOrder($google_order, $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<process-order xmlns=\"".$this->schema_url .
|
||||
"\" google-order-number=\"". $google_order. "\"/> ";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendDeliverOrder($google_order, $carrier, $tracking_no, $send_mail = "true", $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<deliver-order xmlns=\"". $this->schema_url .
|
||||
"\" google-order-number=\"". $google_order . "\">
|
||||
<tracking-data>
|
||||
<carrier>". htmlentities($carrier) . "</carrier>
|
||||
<tracking-number>". $tracking_no . "</tracking-number>
|
||||
</tracking-data>
|
||||
<send-email>". $send_mail . "</send-email>
|
||||
</deliver-order>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendArchiveOrder($google_order, $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<archive-order xmlns=\"".$this->schema_url.
|
||||
"\" google-order-number=\"". $google_order. "\"/>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function SendUnarchiveOrder($google_order, $message_log) {
|
||||
$postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<unarchive-order xmlns=\"".
|
||||
$this->schema_url."\" google-order-number=\"".
|
||||
$google_order. "\"/>";
|
||||
return $this->SendReq($this->request_url, $this->GetAuthenticationHeaders(),
|
||||
$postargs, $message_log);
|
||||
}
|
||||
|
||||
function ProcessMerchantCalculations($merchant_calc) {
|
||||
$result = $merchant_calc->GetXML();
|
||||
echo $result;
|
||||
}
|
||||
|
||||
function GetAuthenticationHeaders() {
|
||||
$headers = array();
|
||||
$headers[] = "Authorization: Basic ".base64_encode(
|
||||
$this->merchant_id.':'.$this->merchant_key);
|
||||
$headers[] = "Content-Type: application/xml";
|
||||
$headers[] = "Accept: application/xml";
|
||||
return $headers;
|
||||
}
|
||||
|
||||
function SendReq($url, $header_arr, $postargs, $message_log) {
|
||||
global $config;
|
||||
|
||||
// Get the curl session object
|
||||
$session = curl_init($url);
|
||||
|
||||
// Set the POST options.
|
||||
curl_setopt($session, CURLOPT_POST, true);
|
||||
curl_setopt($session, CURLOPT_HTTPHEADER, $header_arr);
|
||||
curl_setopt($session, CURLOPT_POSTFIELDS, $postargs);
|
||||
curl_setopt($session, CURLOPT_HEADER, true);
|
||||
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
|
||||
if($config['proxy']==1){
|
||||
curl_setopt ($session, CURLOPT_PROXY, $config['proxyHost'].":".$config['proxyPort']);
|
||||
}
|
||||
|
||||
// Do the POST and then close the session
|
||||
$response = curl_exec($session);
|
||||
if (curl_errno($session)) {
|
||||
die(curl_error($session));
|
||||
} else {
|
||||
curl_close($session);
|
||||
}
|
||||
|
||||
// Get HTTP Status code from the response
|
||||
$status_code = array();
|
||||
preg_match('/\d\d\d/', $response, $status_code);
|
||||
|
||||
// Check for errors
|
||||
switch( $status_code[0] ) {
|
||||
case 200:
|
||||
// Success
|
||||
break;
|
||||
case 503:
|
||||
die('Error 503: Service unavailable.');
|
||||
break;
|
||||
case 403:
|
||||
die('Error 403: Forbidden.');
|
||||
break;
|
||||
case 400:
|
||||
die('Error 400: Bad request.');
|
||||
break;
|
||||
default:
|
||||
echo $response;
|
||||
die('Error :' . $status_code[0]);
|
||||
}
|
||||
fwrite($message_log, sprintf("\n\r%s:- %s\n",date("D M j G:i:s T Y"),
|
||||
$response));
|
||||
}
|
||||
|
||||
function SendAck() {
|
||||
$acknowledgment = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
|
||||
"<notification-acknowledgment xmlns=\"" .
|
||||
$this->schema_url . "\"/>";
|
||||
echo $acknowledgment;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is used to create a Google Checkout result for merchant
|
||||
* as a response to merchant-calculations feedback structure
|
||||
* Refer demo/responsehandlerdemo.php for usage of this code
|
||||
*
|
||||
* Methods are provided to set the shipping, tax, coupons and gift certificate
|
||||
* options
|
||||
*/
|
||||
|
||||
class GoogleResult {
|
||||
var $shipping_name;
|
||||
var $address_id;
|
||||
var $shippable;
|
||||
var $ship_price;
|
||||
var $ship_currency;
|
||||
|
||||
var $tax_currency;
|
||||
var $tax_amount;
|
||||
|
||||
var $coupon_arr = array();
|
||||
var $giftcert_arr = array();
|
||||
|
||||
function GoogleResult($address_id) {
|
||||
$this->address_id = $address_id;
|
||||
}
|
||||
|
||||
function SetShippingDetails($name, $price, $money = "USD",
|
||||
$shippable = "true") {
|
||||
global $config;
|
||||
$this->shipping_name = $name;
|
||||
$this->ship_price = $price;
|
||||
$this->ship_currency = $config['defaultCurrency'];
|
||||
$this->shippable = $shippable;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function SetTaxDetails($amount, $currency = "USD") {
|
||||
global $config;
|
||||
$this->tax_amount = $amount;
|
||||
$this->tax_currency = $config['defaultCurrency'];
|
||||
}
|
||||
|
||||
function AddCoupons($coupon) {
|
||||
$this->coupon_arr[] = $coupon;
|
||||
}
|
||||
|
||||
function AddGiftCertificates($gift) {
|
||||
$this->giftcert_arr[] = $gift;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is a class used to return the results of coupons
|
||||
* that the buyer entered code for on the place order page
|
||||
*/
|
||||
class GoogleCoupons {
|
||||
var $coupon_valid;
|
||||
var $coupon_code;
|
||||
var $coupon_currency;
|
||||
var $coupon_amount;
|
||||
var $coupon_message;
|
||||
|
||||
function googlecoupons($valid, $code, $amount, $currency, $message) {
|
||||
$this->coupon_valid = $valid;
|
||||
$this->coupon_code = $code;
|
||||
$this->coupon_currency = $currency;
|
||||
$this->coupon_amount = $amount;
|
||||
$this->coupon_message = $message;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is a class used to return the results of gift certificates
|
||||
* that the buyer entered code for on the place order page
|
||||
*/
|
||||
class GoogleGiftcerts {
|
||||
var $gift_valid;
|
||||
var $gift_code;
|
||||
var $gift_currency;
|
||||
var $gift_amount;
|
||||
var $gift_message;
|
||||
|
||||
function googlegiftcerts($valid, $code, $amount, $currency, $message) {
|
||||
$this->gift_valid = $valid;
|
||||
$this->gift_code = $code;
|
||||
$this->gift_currency = $currency;
|
||||
$this->gift_amount = $amount;
|
||||
$this->gift_message = $message;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is used to add the shipping options for the cart
|
||||
* There are 3 types of shipping supported
|
||||
* 1. Flat (Type:flat-rate)
|
||||
* 2. Pickup (Type:pickup)
|
||||
* 3. Merchant calculated (Type:merchant-calculated)
|
||||
*
|
||||
* Invoke a separate instance of this class for each type of shipping
|
||||
* to be included
|
||||
* Required fields are shipping name, shipping type and price
|
||||
* Allowed and excluded country areas can be specified as part of constructor
|
||||
* arguments or using individual Set methods. Possible values here are
|
||||
* 1. CONTINENTAL_48
|
||||
* 2. FULL_50_STATES
|
||||
* 3. ALL
|
||||
* State and zip patterns must be exclusively updated using their individual Set methods
|
||||
*/
|
||||
class GoogleShipping {
|
||||
|
||||
var $type;
|
||||
var $price;
|
||||
var $currency;
|
||||
var $name;
|
||||
|
||||
var $allowed_state_areas_arr;
|
||||
var $allowed_zip_patterns_arr;
|
||||
var $excluded_state_areas_arr;
|
||||
var $excluded_zip_patterns_arr;
|
||||
var $allowed_country_area;
|
||||
var $excluded_country_area;
|
||||
var $allowed_restrictions = false;
|
||||
var $excluded_restrictions = false;
|
||||
|
||||
function GoogleShipping($name, $type, $price, $money = "USD",
|
||||
$allowed_country_area="",
|
||||
$excluded_country_area="") {
|
||||
|
||||
global $config;
|
||||
|
||||
$this->price = $price;
|
||||
$this->name = $name;
|
||||
$this->type= strtolower($type);
|
||||
$this->currency = $config['defaultCurrency'];
|
||||
|
||||
if($allowed_country_area != "")
|
||||
$this->SetAllowedCountryArea($allowed_country_area);
|
||||
|
||||
if($excluded_country_area != "")
|
||||
$this->SetExcludedCountryArea($excluded_country_area);
|
||||
|
||||
$this->allowed_state_areas_arr = array();
|
||||
$this->allowed_zip_patterns_arr = array();
|
||||
$this->excluded_state_areas_arr = array();
|
||||
$this->excluded_zip_patterns_arr = array();
|
||||
}
|
||||
|
||||
function SetAllowedStateAreas($areas) {
|
||||
$this->allowed_restrictions = true;
|
||||
$this->allowed_state_areas_arr = $areas;
|
||||
}
|
||||
|
||||
function SetAllowedZipPattens($zips) {
|
||||
$this->allowed_restrictions = true;
|
||||
$this->allowed_zip_patterns_arr = $zips;
|
||||
}
|
||||
|
||||
function SetExcludedStateAreas($areas) {
|
||||
$this->excluded_restrictions = true;
|
||||
$this->excluded_state_areas_arr = $areas;
|
||||
}
|
||||
|
||||
function SetExcludedZipPatternsStateAreas($zips) {
|
||||
$this->excluded_restrictions = true;
|
||||
$this->excluded_zip_patterns_arr = $zips;
|
||||
}
|
||||
|
||||
function SetAllowedCountryArea($country_area) {
|
||||
if($country_area == "CONTINENTAL_48" ||
|
||||
$country_area == "FULL_50_STATES" ||
|
||||
$country_area = "ALL" ) {
|
||||
$this->allowed_country_area = $country_area;
|
||||
$this->allowed_restrictions = true;
|
||||
}
|
||||
else
|
||||
$this->allowed_country_area = "";
|
||||
}
|
||||
function SetExcludedCountryArea($country_area) {
|
||||
if($country_area == "CONTINENTAL_48" ||
|
||||
$country_area == "FULL_50_STATES" ||
|
||||
$country_area = "ALL" ) {
|
||||
$this->excluded_country_area = $country_area;
|
||||
$this->excluded_restrictions = true;
|
||||
}
|
||||
else
|
||||
$this->excluded_country_area = "";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* This class is used to create Tax rules to be added to the tax tables
|
||||
* in the shopping cart
|
||||
* Ther are two types of tax rules
|
||||
* 1. default (should be added to a default tax table)
|
||||
* 2. alternate (should be added to an alternate tax table)
|
||||
*
|
||||
* Invoke a separate instance of this class for each tax rule to be
|
||||
* added to the cart
|
||||
* Required fields are the rule type and the tax rate
|
||||
* Country area can be specified as part of constructor arguments or
|
||||
* using individual Set methods. Possible values here are
|
||||
* 1. CONTINENTAL_48
|
||||
* 2. FULL_50_STATES
|
||||
* 3. ALL
|
||||
* State and zip patterns must be exclusively updated using their
|
||||
* individual Set methods
|
||||
*/
|
||||
class GoogleTaxRule {
|
||||
|
||||
var $shipping_taxed;
|
||||
var $tax_rule_type;
|
||||
var $tax_rate;
|
||||
|
||||
var $state_areas_arr;
|
||||
var $zip_patterns_arr;
|
||||
var $country_area;
|
||||
|
||||
function GoogleTaxRule($type, $tax_rate, $country_area="",
|
||||
$shipping_taxed="false") {
|
||||
$this->rax_rule_type = strtolower($type);
|
||||
$this->shipping_taxed= $shipping_taxed;
|
||||
$this->tax_rate = $tax_rate;
|
||||
|
||||
if($country_area != "")
|
||||
$this->SetCountryArea($country_area);
|
||||
|
||||
$this->state_areas_arr = array();
|
||||
$this->zip_patterns_arr = array();
|
||||
}
|
||||
|
||||
function SetStateAreas($areas) {
|
||||
if(is_array($areas))
|
||||
$this->state_areas_arr = $areas;
|
||||
else
|
||||
$this->state_areas_arr = array($areas);
|
||||
}
|
||||
|
||||
function SetZipPatterns($zips) {
|
||||
if(is_array($zips))
|
||||
$this->zip_patterns_arr = $zips;
|
||||
else
|
||||
$this->zip_patterns_arr = array($zips);
|
||||
|
||||
}
|
||||
|
||||
function SetCountryArea($country_area) {
|
||||
if($country_area == "CONTINENTAL_48" || $country_area == "FULL_50_STATES"
|
||||
|| $country_area = "ALL" )
|
||||
$this->country_area = $country_area;
|
||||
else
|
||||
$this->country_area = "";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This class is used to add tax tables to the shopping cart
|
||||
* There are two types of tax tables
|
||||
* 1. default (there can be only a single default tax table)
|
||||
* 2. alternate
|
||||
*
|
||||
* Invoke a separate instance of this class for each tax table required
|
||||
* Required field is the type
|
||||
* Multiple default/alternate tax rules can be added using the AddTaxRulesMethod
|
||||
*/
|
||||
|
||||
class GoogleTaxTable {
|
||||
|
||||
var $type;
|
||||
var $name;
|
||||
var $tax_rules_arr;
|
||||
var $standalone;
|
||||
|
||||
function GoogleTaxTable($type, $name = "", $standalone = "false") {
|
||||
if(($type == "default") || ($type == "alternate" && $name != "")) {
|
||||
$this->name = $name;
|
||||
$this->type= strtolower($type);
|
||||
$this->tax_rules_arr = array();
|
||||
$this->standalone = $standalone;
|
||||
}
|
||||
}
|
||||
|
||||
function AddTaxRules($rules) {
|
||||
$this->tax_rules_arr[] = $rules;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2006 Google Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Class used to generate XML data
|
||||
* Based on sample code available at http://simon.incutio.com/code/php/XmlWriter.class.php.txt
|
||||
*/
|
||||
|
||||
class XmlBuilder {
|
||||
var $xml;
|
||||
var $indent;
|
||||
var $stack = array();
|
||||
|
||||
function XmlBuilder($indent = ' ') {
|
||||
$this->indent = $indent;
|
||||
$this->xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
|
||||
}
|
||||
|
||||
function _indent() {
|
||||
for ($i = 0, $j = count($this->stack); $i < $j; $i++) {
|
||||
$this->xml .= $this->indent;
|
||||
}
|
||||
}
|
||||
|
||||
//Used when an element has sub-elements
|
||||
// This function adds an open tag to the output
|
||||
function Push($element, $attributes = array()) {
|
||||
$this->_indent();
|
||||
$this->xml .= '<'.$element;
|
||||
foreach ($attributes as $key => $value) {
|
||||
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
|
||||
}
|
||||
$this->xml .= ">\n";
|
||||
$this->stack[] = $element;
|
||||
}
|
||||
|
||||
//Used when an element has no subelements.
|
||||
//Data within the open and close tags are provided with the
|
||||
//contents variable
|
||||
function Element($element, $content, $attributes = array()) {
|
||||
$this->_indent();
|
||||
$this->xml .= '<'.$element;
|
||||
foreach ($attributes as $key => $value) {
|
||||
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
|
||||
}
|
||||
$this->xml .= '>'.htmlentities($content).'</'.$element.'>'."\n";
|
||||
}
|
||||
|
||||
function EmptyElement($element, $attributes = array()) {
|
||||
$this->_indent();
|
||||
$this->xml .= '<'.$element;
|
||||
foreach ($attributes as $key => $value) {
|
||||
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
|
||||
}
|
||||
$this->xml .= " />\n";
|
||||
}
|
||||
|
||||
//Used to close an open tag
|
||||
function Pop($pop_element) {
|
||||
$element = array_pop($this->stack);
|
||||
$this->_indent();
|
||||
if($element !== $pop_element)
|
||||
die('XML Error: Tag Mismatch when trying to close "'. $pop_element. '"');
|
||||
else
|
||||
$this->xml .= "</$element>\n";
|
||||
}
|
||||
|
||||
function GetXML() {
|
||||
if(count($this->stack) != 0)
|
||||
die ('XML Error: No matching closing tag found for " '. array_pop($this->stack). '"');
|
||||
else
|
||||
return $this->xml;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2006 Google Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* This uses SAX parser to convert XML data into PHP associative arrays
|
||||
* When invoking the constructor with the input data, strip out the first XML line
|
||||
*
|
||||
* Member field Description:
|
||||
* $params: This stores the XML data. The attributes and contents of XML tags
|
||||
* can be accessed as follows
|
||||
*
|
||||
* <addresses>
|
||||
* <anonymous-address id="123"> <test>data 1 </test>
|
||||
* </anonymous-address>
|
||||
* <anonymous-address id="456"> <test>data 2 </test>
|
||||
* </anonymous-address>
|
||||
* </addresses>
|
||||
*
|
||||
* print_r($this->params) will return
|
||||
Array
|
||||
(
|
||||
[addresses] => Array
|
||||
(
|
||||
[anonymous-address] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[id] => 123
|
||||
[test] => Array
|
||||
(
|
||||
[VALUE] => data 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[id] => 456
|
||||
[test] => Array
|
||||
(
|
||||
[VALUE] => data 2
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
* XmlParser returns an empty params array if it encounters
|
||||
* any error during parsing
|
||||
*/
|
||||
class XmlParser {
|
||||
|
||||
var $params= array(); //Stores the object representation of XML data
|
||||
var $root;
|
||||
var $global_index = -1;
|
||||
|
||||
/* Constructor for the class
|
||||
* Takes in XML data as input( do not include the <xml> tag
|
||||
*/
|
||||
function XmlParser($input) {
|
||||
$xmlp = xml_parser_create();
|
||||
xml_parse_into_struct($xmlp, $input, $vals, $index);
|
||||
xml_parser_free($xmlp);
|
||||
$this->root = strtolower($vals[0]['tag']);
|
||||
$this->params = $this->UpdateRecursive($vals);
|
||||
}
|
||||
|
||||
/* Returns true if a given variable represents an associative array */
|
||||
function is_associative_array( $var ) {
|
||||
return is_array( $var ) && !is_numeric( implode( '', array_keys( $var ) ) );
|
||||
}
|
||||
|
||||
/* Converts the output of SAX parser into a PHP associative array similar to the
|
||||
* DOM parser output
|
||||
*/
|
||||
function UpdateRecursive($vals) {
|
||||
$this->global_index++;
|
||||
//Reached end of array
|
||||
if($this->global_index >= count($vals))
|
||||
return;
|
||||
|
||||
$tag = strtolower($vals[$this->global_index]['tag']);
|
||||
$value = trim($vals[$this->global_index]['value']);
|
||||
$type = $vals[$this->global_index]['type'];
|
||||
|
||||
//Add attributes
|
||||
if(isset($vals[$this->global_index]['attributes'])) {
|
||||
foreach($vals[$this->global_index]['attributes'] as $key=>$val) {
|
||||
$key = strtolower($key);
|
||||
$params[$tag][$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if($type == 'open') {
|
||||
$new_arr = array();
|
||||
|
||||
//Read all elements at the next levels and add to an array
|
||||
while($vals[$this->global_index]['type'] != 'close' &&
|
||||
$this->global_index < count($vals)) {
|
||||
$arr = $this->UpdateRecursive($vals);
|
||||
if(count($arr) > 0) {
|
||||
$new_arr[] = $arr;
|
||||
}
|
||||
}
|
||||
$this->global_index++;
|
||||
foreach($new_arr as $arr) {
|
||||
foreach($arr as $key=>$val) {
|
||||
if(isset($params[$tag][$key])) {
|
||||
//If this key already exists
|
||||
if($this->is_associative_array($params[$tag][$key])) {
|
||||
//If this is an associative array and not an indexed array
|
||||
// remove exisiting value and convert to an indexed array
|
||||
$val_key = $params[$tag][$key];
|
||||
array_splice($params[$tag][$key], 0);
|
||||
$params[$tag][$key][0] = $val_key;
|
||||
$params[$tag][$key][] = $val;
|
||||
} else {
|
||||
$params[$tag][$key][] = $val;
|
||||
}
|
||||
} else {
|
||||
$params[$tag][$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($type == 'complete') {
|
||||
if($value != '')
|
||||
$params[$tag]['VALUE'] = $value;
|
||||
}
|
||||
else
|
||||
$params = array();
|
||||
return $params;
|
||||
}
|
||||
|
||||
/* Returns the root of the XML data */
|
||||
function GetRoot() {
|
||||
return $this->root;
|
||||
}
|
||||
|
||||
/* Returns the array representing the XML data */
|
||||
function GetData() {
|
||||
return $this->params;
|
||||
}
|
||||
}
|
||||
?>
|
||||
234
production/modules/altCheckout/PayPal_Pro/admin/index.inc.php
Normal file
234
production/modules/altCheckout/PayPal_Pro/admin/index.inc.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| CubeCart 4
|
||||
| ========================================
|
||||
| CubeCart is a registered trade mark of Devellion Limited
|
||||
| Copyright Devellion Limited 2006. All rights reserved.
|
||||
| Devellion Limited,
|
||||
| 5 Bridge Street,
|
||||
| Bishops Stortford,
|
||||
| HERTFORDSHIRE.
|
||||
| CM23 2JU
|
||||
| UNITED KINGDOM
|
||||
| http://www.devellion.com
|
||||
| UK Private Limited Company No. 5323904
|
||||
| ========================================
|
||||
| Web: http://www.cubecart.com
|
||||
| Email: info (at) cubecart (dot) com
|
||||
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
||||
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
||||
+--------------------------------------------------------------------------
|
||||
| index.inc.php
|
||||
| ========================================
|
||||
| Configure PayPal Express Checkout
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if(!defined('CC_INI_SET')){ die("Access Denied"); }
|
||||
|
||||
permission("settings","read",$halt=TRUE);
|
||||
|
||||
|
||||
|
||||
if(isset($_POST['module'])){
|
||||
require CC_ROOT_DIR.CC_DS.'modules'.CC_DS.'status.inc.php';
|
||||
$cache = new cache("config.".$moduleName);
|
||||
$cache->clearCache();
|
||||
//$module = fetchDbConfig($moduleName); // Uncomment this is you wish to merge old config with new
|
||||
$module = array(); // Comment this out if you don't want the old config to merge with new
|
||||
$msg = writeDbConf($_POST['module'], $moduleName, $module);
|
||||
|
||||
}
|
||||
$module = fetchDbConfig($moduleName);
|
||||
|
||||
$thisPage = currentPage(array("mode"=> 0));
|
||||
|
||||
if(!isset($_GET['mode']) && isset($module['mode']) && !empty($module['mode'])) {
|
||||
httpredir($thisPage."&mode=".$module['mode']);
|
||||
}
|
||||
require($glob['adminFolder'].CC_DS."includes".CC_DS."header.inc.php");
|
||||
?>
|
||||
<p><a href="http://www.paypal.com/"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" alt="" border="0" title="" /></a></p>
|
||||
<?php
|
||||
if(isset($msg)){
|
||||
echo msg($msg);
|
||||
}
|
||||
?>
|
||||
<p class="copyText">"Get our most comprehensive solution to process credit cards directly on your site and also accept PayPal and bank account payments with Website Payments Pro."</p>
|
||||
|
||||
<p>Please choose your module mode: <select name="itdoesntneedonesoicalleditthis" onchange="jumpMenu('parent',this,0)">
|
||||
<?php if(!isset($_GET['mode'])) { ?><option value="<?php echo $thisPage; ?>" <?php if(!isset($_GET['mode'])) echo "selected='selected'"; ?>>-- Select --</option><?php } ?>
|
||||
<option value="<?php echo $thisPage; ?>&mode=US" <?php if($_GET['mode']=="US") echo "selected='selected'"; ?>>Website Payments Pro (US)</option>
|
||||
<option value="<?php echo $thisPage; ?>&mode=UK" <?php if($_GET['mode']=="UK") echo "selected='selected'"; ?>>Website Payments Pro (UK)</option>
|
||||
</select></p>
|
||||
|
||||
<?php if(isset($_GET['mode']) && !empty($_GET['mode'])) { ?>
|
||||
|
||||
<form action="<?php echo $glob['adminFile']; ?>?_g=<?php echo $_GET['_g']; ?>&module=<?php echo $_GET['module']; ?>&mode=<?php echo $_GET['mode']; ?>" method="post" enctype="multipart/form-data">
|
||||
<table border="0" cellspacing="1" cellpadding="3" class="mainTable">
|
||||
<tr>
|
||||
<td colspan="2" class="tdTitle">Configuration Settings </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>PayPal Pro Mode:</strong></td>
|
||||
<td class="tdText">
|
||||
<?php
|
||||
echo "Website Payments Pro (".$_GET['mode'].")";
|
||||
?>
|
||||
<input type="hidden" name="module[mode]" value="<?php echo $_GET['mode'];?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Status:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[status]">
|
||||
<option value="1" <?php if($module['status']==1) echo "selected='selected'"; ?>>Enabled</option>
|
||||
<option value="0" <?php if($module['status']==0) echo "selected='selected'"; ?>>Disabled</option>
|
||||
</select> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Currency:</strong></td>
|
||||
<td class="tdText"><?php echo $config['defaultCurrency']; ?> (This can be edited under general settings)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Enable Card Validation:</strong></td>
|
||||
<td class="tdText"><select name="module[validation]">
|
||||
<option value="1" <?php if($module['validation']==1) echo "selected='selected'"; ?>>Enabled</option>
|
||||
<option value="0" <?php if($module['validation']==0) echo "selected='selected'"; ?>>Disabled</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Gateway Server:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[gateway]">
|
||||
<option value="1" <?php if($module['gateway'] == 1) echo "selected='selected'"; ?>>Live</option>
|
||||
<option value="0" <?php if($module['gateway'] == 0) echo "selected='selected'"; ?>>Sandbox</option>
|
||||
</select> </td>
|
||||
</tr>
|
||||
<?php
|
||||
if($_GET['mode']=="US") {
|
||||
?>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong> API Username:</strong></td>
|
||||
<td class="tdText"><input type="text" name="module[username]" value="<?php echo $module['username']; ?>" class="textbox" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>API Password:</strong></td>
|
||||
<td class="tdText"><input type="text" name="module[password]" value="<?php echo $module['password']; ?>" class="textbox" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>API Signature:</strong></td>
|
||||
<td class="tdText">
|
||||
<input type="text" name="module[signature]" value="<?php echo $module['signature']; ?>" class="textbox" size="65" /> </td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Username:</strong><br />
|
||||
If you set up one or more additional users on the account,
|
||||
this value is the ID of the user authorised to process
|
||||
transactions. If, however, you have not setup additional
|
||||
users on the account, username should be the same value as
|
||||
vendor.</td>
|
||||
<td class="tdText"><input type="text" name="module[user]" value="<?php echo $module['user']; ?>" class="textbox" size="45" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Password:</strong><br />
|
||||
The 6 to 32-character password that you defined while
|
||||
registering for the account.</td>
|
||||
<td class="tdText"><input type="text" name="module[pass]" value="<?php echo $module['pass']; ?>" class="textbox" size="45" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Merchant ID:</strong><br />
|
||||
Your merchant login ID that you created when you
|
||||
registered for the Website Payments Pro account.
|
||||
|
||||
</td>
|
||||
<td class="tdText">
|
||||
<input type="text" name="module[vendor]" value="<?php echo $module['vendor']; ?>" class="textbox" size="45" /> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Partner:</strong><br />
|
||||
The ID provided to you by the authorised PayPal Reseller
|
||||
who registered. If you
|
||||
purchased your account directly from PayPal, use
|
||||
PayPalUK.</td>
|
||||
<td class="tdText">
|
||||
<input type="text" name="module[partner]" value="<?php echo $module['partner']; ?>" class="textbox" size="45" /> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td width="33%" align="left" valign="top" class="tdText"><strong>Require PayPal confirmed address:</strong><br />
|
||||
(Express Checkout Only)</td>
|
||||
<td class="tdText"><select name="module[confAddress]">
|
||||
<option value="0" <?php if($module['confAddress'] == 0) echo "selected='selected'"; ?>>No</option>
|
||||
<option value="1" <?php if($module['confAddress'] == 1) echo "selected='selected'"; ?>>Yes</option>
|
||||
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" valign="top" class="tdText"><strong>Send Welcome Email:</strong><br />
|
||||
(Contains user/password for future access)</td>
|
||||
<td class="tdText"><select name="module[welcomeEmail]">
|
||||
<option value="0" <?php if($module['welcomeEmail'] == 0) echo "selected='selected'"; ?>>No</option>
|
||||
<option value="1" <?php if($module['welcomeEmail'] == 1) echo "selected='selected'"; ?>>Yes</option>
|
||||
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" valign="top" class="tdText"><strong>Payment Acton:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[paymentAction]">
|
||||
<option value="Sale" <?php if($module['paymentAction'] == "Sale") echo "selected='selected'"; ?>>Sale</option>
|
||||
<option value="Authorization" <?php if($module['paymentAction'] == "Authorization") echo "selected='selected'"; ?>>Authorization</option>
|
||||
<?php
|
||||
if($_GET['mode']=="US") {
|
||||
?>
|
||||
<option value="Order" <?php if($module['paymentAction'] == "Order") echo "selected='selected'"; ?>>Order (Express Checkout Only*)</option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
- Sale indicates that this is a final sale for which you are requesting payment.<br />
|
||||
- Authorization <?php if($_GET['mode']=="US") { ?>or Order<?php } ?> indicates that this payment is subject to settlement with PayPal Authorization & Capture.
|
||||
<?php if($_GET['mode']=="US") { ?><p>* If this is selected and a credit card payment is made it will force "Authorization" instead.</p><?php } ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="left" class="tdText"><strong>Debug:</strong></td>
|
||||
<td class="tdText">
|
||||
<select name="module[debug]">
|
||||
<option value="1" <?php if($module['debug'] == 1) echo "selected='selected'"; ?>>Yes</option>
|
||||
<option value="0" <?php if($module['debug'] == 0) echo "selected='selected'"; ?>>No</option>
|
||||
</select> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" align="right" class="tdText"> </td>
|
||||
<td class="tdText"><input type="submit" class="submit" value="Edit Config" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if($module['mode']=="US") { ?>
|
||||
<p class="pageTitle">How to add PayPal Merchant Referral Banner</p>
|
||||
The Merchant Referral Bonus Program rewards you for bringing new businesses to PayPal.<br /><br />
|
||||
1. Login to your PayPal account at <a href="http://www.paypal.com" target="_blank" class="txtLink">http://www.paypal.com</a><br />
|
||||
2. Click on the "Referrals" link.<br />
|
||||
3. You can then see HTML code which can be cut and paste into the stores HTML template files.<br />
|
||||
<br />
|
||||
The HTML template files can be found and edited using an <a href="http://en.wikipedia.org/wiki/FTP_Client" target="_blank" class="txtLink">FTP</a> Client to access the website files:<br />
|
||||
<br />
|
||||
<span style="font-family:'Courier New', Courier, monospace;">/skins/<?php echo $config['skinDir'];?>/styleTemplates/global/index.tpl</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
</ol>
|
||||
BIN
production/modules/altCheckout/PayPal_Pro/admin/logo.gif
Normal file
BIN
production/modules/altCheckout/PayPal_Pro/admin/logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
66
production/modules/altCheckout/PayPal_Pro/button.php
Normal file
66
production/modules/altCheckout/PayPal_Pro/button.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| CubeCart 4
|
||||
| ========================================
|
||||
| CubeCart is a registered trade mark of Devellion Limited
|
||||
| Copyright Devellion Limited 2006. All rights reserved.
|
||||
| Devellion Limited,
|
||||
| 5 Bridge Street,
|
||||
| Bishops Stortford,
|
||||
| HERTFORDSHIRE.
|
||||
| CM23 2JU
|
||||
| UNITED KINGDOM
|
||||
| http://www.devellion.com
|
||||
| UK Private Limited Company No. 5323904
|
||||
| ========================================
|
||||
| Web: http://www.cubecart.com
|
||||
| Email: info (at) cubecart (dot) com
|
||||
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
||||
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
||||
+--------------------------------------------------------------------------
|
||||
| button.inc.php
|
||||
| ========================================
|
||||
| Button PayPal EC
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
class PayPal_Pro {
|
||||
|
||||
function buildIt($moduleName="", $urlOnly = false) {
|
||||
|
||||
global $subTotal,$config,$orderSum;
|
||||
|
||||
switch(strtolower(LANG_FOLDER)) {
|
||||
case "es":
|
||||
$locale = "es_ES";
|
||||
break;
|
||||
case "fr":
|
||||
$locale = "fr_FR";
|
||||
break;
|
||||
case "nl":
|
||||
$locale = "nl_NL";
|
||||
break;
|
||||
case "de":
|
||||
$locale = "de_DE";
|
||||
break;
|
||||
case "it":
|
||||
$locale = "it_IT";
|
||||
break;
|
||||
default:
|
||||
$locale = "en_US";
|
||||
break;
|
||||
}
|
||||
|
||||
if($urlOnly==true) {
|
||||
$link = "index.php?_g=rm&type=altCheckout&cmd=process&module=PayPal_Pro&ccb=".base64_encode($orderSum['prod_total'].",".$config['defaultCurrency']);
|
||||
} else {
|
||||
|
||||
$link = "<a href='index.php?_g=rm&type=altCheckout&cmd=process&module=PayPal_Pro&ccb=".base64_encode($subTotal.",".$config['defaultCurrency'])."' target='_self' /><img src='https://www.paypal.com/".$locale."/i/btn/btn_xpressCheckout.gif' border='0' title='' alt='' /></a>";
|
||||
|
||||
}
|
||||
|
||||
return $link;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
421
production/modules/altCheckout/PayPal_Pro/form.inc.php
Normal file
421
production/modules/altCheckout/PayPal_Pro/form.inc.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| CubeCart 4
|
||||
| ========================================
|
||||
| CubeCart is a Trade Mark of Devellion Limited
|
||||
| Copyright Devellion Limited 2005 - 2006. All rights reserved.
|
||||
| Devellion Limited,
|
||||
| 5 Bridge Street,
|
||||
| Bishops Stortford,
|
||||
| HERTFORDSHIRE.
|
||||
| CM23 2JU
|
||||
| UNITED KINGDOM
|
||||
| http://www.devellion.com
|
||||
| UK Private Limited Company No. 5323904
|
||||
| ========================================
|
||||
| Web: http://www.cubecart.com
|
||||
| Date: Tuesday, 17th October 2006
|
||||
| Email: sales (at) cubecart (dot) com
|
||||
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
||||
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
||||
+--------------------------------------------------------------------------
|
||||
| form.inc.php
|
||||
| ========================================
|
||||
| PayPal Direct Payment Gateway
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//if(detectSSL() == FALSE) die ("<strong>Critical Error:</strong> This page can ONLY be viewed under SSL!");
|
||||
|
||||
// Get Direct Payment module vars
|
||||
$module = fetchDbConfig("PayPal_Pro");
|
||||
|
||||
if($_GET['process']==1){
|
||||
|
||||
$gatewayName = "PayPal Website Payments Pro (".$module['paymentAction'].")";
|
||||
|
||||
$transData['customer_id'] = $orderSum["customer_id"];
|
||||
$transData['order_id'] = $orderSum['cart_order_id'];
|
||||
$transData['amount'] = $orderSum['prod_total'];
|
||||
$transData['gateway'] = $gatewayName;
|
||||
$transData['extra'] = "C";
|
||||
|
||||
require("classes".CC_DS."validate".CC_DS."validateCard.php");
|
||||
|
||||
$card = new validateCard();
|
||||
|
||||
if($module['mode']=="US") {
|
||||
|
||||
$cardNo = trim($_POST['cardNumber']);
|
||||
$issueNo = trim($_POST['issueNo']);
|
||||
$issueDate = false;
|
||||
$issueFormat = false;
|
||||
$expireDate = trim($_POST["expirationYear"]).str_pad(trim($_POST["expirationMonth"]), 2, '0', STR_PAD_LEFT);
|
||||
$expireFormat = 6;
|
||||
$scReqd = TRUE;
|
||||
$securityCode = trim($_POST["cvc2"]);
|
||||
|
||||
} else {
|
||||
|
||||
$cardNo = trim($_POST['cardNumber']);
|
||||
$issueNo = trim($_POST['issueNo']);
|
||||
$issueDate = trim($_POST["issueYear"]).str_pad(trim($_POST["issueMonth"]), 2, '0', STR_PAD_LEFT);
|
||||
$issueFormat = 6;
|
||||
$expireDate = trim($_POST["expirationYear"]).str_pad(trim($_POST["expirationMonth"]), 2, '0', STR_PAD_LEFT);
|
||||
$expireFormat = 6;
|
||||
$scReqd = TRUE;
|
||||
$securityCode = trim($_POST["cvc2"]);
|
||||
|
||||
}
|
||||
|
||||
$card = $card->check($cardNo, $issueNo, $issueDate, $issueFormat, $expireDate, $expireFormat, $scReqd, $securityCode);
|
||||
|
||||
if($module['validation']==1 && $card['response']=="FAIL"){
|
||||
|
||||
$errorMsg['customer'] = "";
|
||||
|
||||
foreach($card['error'] as $val){
|
||||
|
||||
$errorMsg['customer'] .= $val."<br />";
|
||||
|
||||
}
|
||||
|
||||
$transData['trans_id'] = "";
|
||||
$transData['status'] = "Fail";
|
||||
$transData['notes'] = $errorMsg['customer'];
|
||||
|
||||
} else {
|
||||
|
||||
$extraNotes = "";
|
||||
|
||||
include("modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."wpp-".$module['mode'].CC_DS."DoDirectPaymentReceipt.php");
|
||||
|
||||
if($ack=="SUCCESS") {
|
||||
|
||||
// Sale = Funds taken immediately otherwise they may be taken later
|
||||
$paymentResult = ($module['paymentAction'] == "Sale") ? 3 : 2; // 3 is payment complete, 2 is processing
|
||||
$confirmationScreen = ($module['paymentAction'] == "Sale") ? 2 : 3; // Just to confuse matter Al you plonker!! 2 = money taken 3 = money not yet taken (Athorized)
|
||||
$order->orderStatus($paymentResult,$orderSum['cart_order_id']);
|
||||
$jumpTo = "index.php?_g=co&_a=confirmed&s=".$confirmationScreen;
|
||||
|
||||
$transData['trans_id'] = $resArray['TRANSACTIONID'];
|
||||
$transData['status'] = "SUCCESS";
|
||||
$transData['notes'] = "Successful transaction via Credit Card. ".$extraNotes;
|
||||
|
||||
} else {
|
||||
$transData['trans_id'] = "";
|
||||
$transData['status'] = "FAIL";
|
||||
$transData['notes'] = "<strong>Error displayed to customer:</strong> ".$errorMsg['customer']."<br /><strong>Error:</strong> ".$errorMsg['admin']."<br /><strong>PayPal Response:</strong> ".$errorMsg['paypal'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$order->storeTrans($transData);
|
||||
|
||||
if(isset($jumpTo) && !empty($jumpTo)) {
|
||||
|
||||
httpredir($jumpTo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$formTemplate = new XTemplate ("modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."form.tpl",'',null,'main',true,$skipPath=TRUE);
|
||||
|
||||
if(isset($errorMsg)) {
|
||||
|
||||
$formTemplate->assign("LANG_ERROR",$errorMsg['customer']);
|
||||
$formTemplate->parse("form.error");
|
||||
|
||||
}
|
||||
|
||||
$formTemplate->assign("VAL_AMOUNT_DUE",sprintf($lang['gateway']['amount_due'],priceformat($orderSum['prod_total'],true)));
|
||||
|
||||
$formTemplate->assign("VAL_FIRST_NAME",$cc_session->ccUserData['firstName']);
|
||||
$formTemplate->assign("VAL_LAST_NAME",$cc_session->ccUserData['lastName']);
|
||||
$formTemplate->assign("VAL_EMAIL_ADDRESS",$orderSum['email']);
|
||||
$formTemplate->assign("VAL_ADD_1",$orderSum['add_1']);
|
||||
$formTemplate->assign("VAL_ADD_2",$orderSum['add_2']);
|
||||
$formTemplate->assign("VAL_CITY",$orderSum['town']);
|
||||
|
||||
$siteCountryIso = getCountryFormat($config['siteCountry'],"id","iso");
|
||||
|
||||
if($siteCountryIso=="US" || $siteCountryIso=="CA") {
|
||||
|
||||
// look up county
|
||||
$isoLookup = $db->select("SELECT abbrev FROM `".$glob['dbprefix']."CubeCart_iso_counties`
|
||||
WHERE `name` LIKE '%".ucfirst(str_replace(" ","",strtolower($orderSum['county'])))."%'");
|
||||
|
||||
$states = array (
|
||||
"Alberta" => "AB",
|
||||
"British Columbia" => "BC",
|
||||
"Manitoba" => "MB",
|
||||
"New Brunswick" => "NB",
|
||||
"Newfoundland and Labrador" => "NF",
|
||||
"Northwest Territories" => "NT",
|
||||
"Nova Scotia" => "NS",
|
||||
"Nunavut" => "NU",
|
||||
"Ontario" => "ON",
|
||||
"Prince Edward Island" => "PE",
|
||||
"Quebec" => "QC",
|
||||
"Saskatchewan" => "SK",
|
||||
"Yukon" => "YK",
|
||||
"Alabama" => "AL",
|
||||
"Alaska" => "AK",
|
||||
"American Samoa" => "AS",
|
||||
"Arizona" => "AZ",
|
||||
"Arkansas" => "AR",
|
||||
"California" => "CA",
|
||||
"Colorado" => "CO",
|
||||
"Connecticut" => "CT",
|
||||
"Delaware" => "DE",
|
||||
"District of Columbia" => "DC",
|
||||
"Federated States of Micronesia" => "FM",
|
||||
"Florida" => "FL",
|
||||
"Georgia" => "GA",
|
||||
"Guam" => "GU",
|
||||
"Hawaii" => "HI",
|
||||
"Idaho" => "ID",
|
||||
"Illinois" => "IL",
|
||||
"Indiana" => "IN",
|
||||
"Iowa" => "IA",
|
||||
"Kansas" => "KS",
|
||||
"Kentucky" => "KY",
|
||||
"Louisiana" => "LA",
|
||||
"Maine" => "ME",
|
||||
"Marshall" => "Islands MH",
|
||||
"Maryland" => "MD",
|
||||
"Massachusetts" => "MA",
|
||||
"Michigan" => "MI",
|
||||
"Minnesota" => "MN",
|
||||
"Mississippi" => "MS",
|
||||
"Missouri" => "MO",
|
||||
"Montana" => "MT",
|
||||
"Nebraska" => "NE",
|
||||
"Nevada" => "NV",
|
||||
"New Hampshire" => "NH",
|
||||
"New Jersey" => "NJ",
|
||||
"New Mexico" => "NM",
|
||||
"New York" => "NY",
|
||||
"North Carolina" => "NC",
|
||||
"North Dakota" => "ND",
|
||||
"Northern Mariana Islands" => "MP",
|
||||
"Ohio" => "OH",
|
||||
"Oklahoma" => "OK",
|
||||
"Oregon" => "OR",
|
||||
"Palau" => "PW",
|
||||
"Pennsylvania" => "PA",
|
||||
"Puerto Rico" => "PR",
|
||||
"Rhode Island" => "RI",
|
||||
"South Carolina" => "SC",
|
||||
"South Dakota" => "SD",
|
||||
"Tennessee" => "TN",
|
||||
"Texas" => "TX",
|
||||
"Utah" => "UT",
|
||||
"Vermont" => "VT",
|
||||
"Virgin Islands" => "VI",
|
||||
"Virginia" => "VA",
|
||||
"Washington" => "WA",
|
||||
"West Virginia" => "WV",
|
||||
"Wisconsin" => "WI",
|
||||
"Wyoming" => "WY",
|
||||
"Armed Forces Americas" => "A",
|
||||
"Armed Forces" => "AE",
|
||||
"Armed Forces Pacific" => "AP"
|
||||
);
|
||||
|
||||
foreach($states as $key => $value) {
|
||||
if($value == $isoLookup[0]['abbrev']) {
|
||||
$formTemplate->assign("VAL_STATE_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("VAL_STATE_SELECTED","");
|
||||
}
|
||||
|
||||
$formTemplate->assign("VAL_STATE_ABBR",$value);
|
||||
$formTemplate->assign("VAL_STATE",$key);
|
||||
$formTemplate->parse("form.states_list.states_loop");
|
||||
}
|
||||
|
||||
$formTemplate->assign("LANG_STATE",$lang['gateway']['state']);
|
||||
|
||||
$formTemplate->parse("form.states_list");
|
||||
|
||||
} else {
|
||||
$formTemplate->assign("LANG_STATE",$lang['gateway']['state']);
|
||||
$formTemplate->assign("VAL_STATE",$orderSum['county']);
|
||||
$formTemplate->parse("form.states_txtbox");
|
||||
}
|
||||
|
||||
$formTemplate->assign("VAL_POST_CODE",$orderSum['postcode']);
|
||||
$formTemplate->assign("VAL_CART_ORDER_ID",$basket['cart_order_id']);
|
||||
$formTemplate->assign("VAL_ORDER_TOTAL",$basket['grandTotal']);
|
||||
$formTemplate->assign("VAL_ITEM_TOTAL",$basket['subTotal']);
|
||||
$formTemplate->assign("VAL_TAX_TOTAL",$basket['tax']);
|
||||
$formTemplate->assign("VAL_SHIPPING_TOTAL",$basket['shipCost']);
|
||||
|
||||
|
||||
$currency = $db->select("SELECT currency FROM ".$glob['dbprefix']."CubeCart_sessions WHERE sessId = ".$db->mySQLSafe($GLOBALS[CC_SESSION_NAME]));
|
||||
|
||||
if($currency == TRUE && $currency[0]['currency'] != ''){
|
||||
$formTemplate->assign("VAL_CURRENCY_ID", $currency[0]['currency']);
|
||||
} else {
|
||||
$formTemplate->assign("VAL_CURRENCY_ID", $config['defaultCurrency']);
|
||||
}
|
||||
|
||||
if($module['mode']=="US") {
|
||||
|
||||
$cards = array(
|
||||
"Visa" => "Visa",
|
||||
"MasterCard" => "MasterCard",
|
||||
"Discover" => "Discover",
|
||||
"Amex" => "American Express"
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
$cards = array(
|
||||
"0" => "Visa",
|
||||
"8" => "Visa Electron",
|
||||
"8" => "Delta",
|
||||
"1" => "MasterCard",
|
||||
"9" => "Maestro / Switch",
|
||||
"S" => "Solo"
|
||||
//"8" => "Other"
|
||||
);
|
||||
}
|
||||
|
||||
foreach($cards as $key => $value) {
|
||||
|
||||
$formTemplate->assign("VAL_CARD_TYPE",$key);
|
||||
|
||||
if($key == $_POST['cardType']){
|
||||
$formTemplate->assign("CARD_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("CARD_SELECTED","");
|
||||
}
|
||||
$formTemplate->assign("VAL_CARD_NAME",$value);
|
||||
|
||||
$formTemplate->parse("form.repeat_cards");
|
||||
|
||||
}
|
||||
|
||||
for($i=1;$i<=12;$i++) {
|
||||
|
||||
$val = sprintf('%02d',$i);
|
||||
|
||||
if($val == $_POST['expirationMonth']){
|
||||
$formTemplate->assign("EXPIRE_MONTHS_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("EXPIRE_MONTHS_SELECTED","");
|
||||
}
|
||||
$formTemplate->assign("VAL_EXPIRE_MONTH",$val);
|
||||
|
||||
$formTemplate->parse("form.expiration_months");
|
||||
|
||||
}
|
||||
|
||||
$thisYear = date("Y");
|
||||
$maxYear = $thisYear + 10;
|
||||
|
||||
for($i=$thisYear;$i<=$maxYear;$i++) {
|
||||
|
||||
if($i == $_POST['expirationYear']){
|
||||
$formTemplate->assign("EXPIRE_YEARS_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("EXPIRE_YEARS_SELECTED","");
|
||||
}
|
||||
$formTemplate->assign("VAL_EXPIRE_YEAR",$i);
|
||||
|
||||
$formTemplate->parse("form.expiration_years");
|
||||
|
||||
}
|
||||
|
||||
|
||||
$cache = new cache('glob.countries');
|
||||
$countries = $cache->readCache();
|
||||
|
||||
$countries = $db->select("SELECT id, iso, printable_name FROM ".$glob['dbprefix']."CubeCart_iso_countries ORDER BY printable_name");
|
||||
|
||||
for($i=0; $i<count($countries); $i++){
|
||||
|
||||
if($countries[$i]['id'] == $orderSum['country']){
|
||||
$formTemplate->assign("COUNTRY_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("COUNTRY_SELECTED","");
|
||||
}
|
||||
|
||||
$formTemplate->assign("VAL_COUNTRY_ISO",$countries[$i]['iso']);
|
||||
|
||||
$countryName = "";
|
||||
$countryName = $countries[$i]['printable_name'];
|
||||
|
||||
if(strlen($countryName)>20){
|
||||
$countryName = substr($countryName,0,20)."…";
|
||||
}
|
||||
|
||||
$formTemplate->assign("VAL_COUNTRY_NAME",$countryName);
|
||||
$formTemplate->parse("form.repeat_countries");
|
||||
}
|
||||
|
||||
$formTemplate->assign("LANG_CC_INFO_TITLE",$lang['gateway']['cc_info_title']);
|
||||
$formTemplate->assign("LANG_FIRST_NAME",$lang['gateway']['first_name']);
|
||||
$formTemplate->assign("LANG_LAST_NAME",$lang['gateway']['last_name']);
|
||||
$formTemplate->assign("LANG_CARD_TYPE",$lang['gateway']['card_type']);
|
||||
$formTemplate->assign("LANG_CARD_NUMBER",$lang['gateway']['card_number']);
|
||||
$formTemplate->assign("LANG_EXPIRES",$lang['gateway']['expires']);
|
||||
$formTemplate->assign("LANG_MMYYYY",$lang['gateway']['mmyyyy']);
|
||||
$formTemplate->assign("LANG_SECURITY_CODE",$lang['gateway']['security_code']);
|
||||
$formTemplate->assign("LANG_CUST_INFO_TITLE",$lang['gateway']['customer_info']);
|
||||
$formTemplate->assign("LANG_EMAIL",$lang['gateway']['email']);
|
||||
$formTemplate->assign("LANG_ADDRESS",$lang['gateway']['address']);
|
||||
$formTemplate->assign("LANG_CITY",$lang['gateway']['city']);
|
||||
$formTemplate->assign("LANG_ZIPCODE",$lang['gateway']['zipcode']);
|
||||
$formTemplate->assign("LANG_COUNTRY",$lang['gateway']['country']);
|
||||
$formTemplate->assign("LANG_OPTIONAL",$lang['gateway']['optional']);
|
||||
|
||||
if($module['mode']=="UK"){
|
||||
|
||||
|
||||
for($i=1;$i<=12;$i++) {
|
||||
|
||||
$val = sprintf('%02d',$i);
|
||||
|
||||
if($val == $_POST['issueMonth']){
|
||||
$formTemplate->assign("ISSUE_MONTHS_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("ISSUE_MONTHS_SELECTED","");
|
||||
}
|
||||
$formTemplate->assign("VAL_ISSUE_MONTH",$val);
|
||||
|
||||
$formTemplate->parse("form.issue_info.issue_months");
|
||||
|
||||
}
|
||||
|
||||
$minYear = $thisYear - 10;
|
||||
|
||||
for($i = $thisYear; $i>=$minYear; $i--) {
|
||||
|
||||
if($i == $_POST['issueYear']){
|
||||
$formTemplate->assign("ISSUE_YEARS_SELECTED","selected='selected'");
|
||||
} else {
|
||||
$formTemplate->assign("ISSUE_YEARS_SELECTED","");
|
||||
}
|
||||
$formTemplate->assign("VAL_ISSUE_YEAR",$i);
|
||||
|
||||
$formTemplate->parse("form.issue_info.issue_years");
|
||||
|
||||
}
|
||||
|
||||
|
||||
$formTemplate->assign("LANG_ISSUE_DATE", $lang['gateway']['issue_date']);
|
||||
$formTemplate->assign("LANG_ISSUE_NO", $lang['gateway']['issue_number']);
|
||||
$formTemplate->parse("form.issue_info");
|
||||
}
|
||||
|
||||
$formTemplate->assign("VAL_GATEWAY","PayPal Website Payments Pro (".$module['paymentAction'].")");
|
||||
|
||||
$formTemplate->parse("form");
|
||||
$formTemplate = $formTemplate->text("form");
|
||||
?>
|
||||
132
production/modules/altCheckout/PayPal_Pro/form.tpl
Normal file
132
production/modules/altCheckout/PayPal_Pro/form.tpl
Normal file
@@ -0,0 +1,132 @@
|
||||
<!-- BEGIN: form -->
|
||||
<!-- BEGIN: error -->
|
||||
<p class="txtError" style="text-align: left;">{LANG_ERROR}</p>
|
||||
<!-- END: error -->
|
||||
<p>{VAL_AMOUNT_DUE}</p>
|
||||
<table width="100%" cellpadding="3" cellspacing="0" border="0">
|
||||
<tr align="left">
|
||||
<td colspan="4" class="tdcartTitle"><strong>{LANG_CC_INFO_TITLE}</strong></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td><strong>{LANG_FIRST_NAME}</strong></td>
|
||||
<td><input type="text" name="firstName" value="{VAL_FIRST_NAME}" class="textbox" /></td>
|
||||
<td><strong>{LANG_LAST_NAME}</strong></td>
|
||||
<td><input type="text" name="lastName" value="{VAL_LAST_NAME}" class="textbox" /></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td align="left"><strong>{LANG_CARD_NUMBER}</strong></td>
|
||||
<td align="left"><input type="text" name="cardNumber" value="" size="19" maxlength="19" class="textbox" /></td>
|
||||
<td><strong>{LANG_CARD_TYPE}</strong></td>
|
||||
<td><select name="cardType" class="textbox">
|
||||
<!-- BEGIN: repeat_cards -->
|
||||
<option value="{VAL_CARD_TYPE}" {CARD_SELECTED}>{VAL_CARD_NAME}</option>
|
||||
<!-- END: repeat_cards -->
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td align="left"><strong>{LANG_EXPIRES}</strong>
|
||||
|
||||
<td align="left">
|
||||
<select name="expirationMonth" class="textbox">
|
||||
<!-- BEGIN: expiration_months -->
|
||||
<option value="{VAL_EXPIRE_MONTH}" {EXPIRE_MONTHS_SELECTED}>{VAL_EXPIRE_MONTH}</option>
|
||||
<!-- END: expiration_months -->
|
||||
</select>
|
||||
/
|
||||
<select name="expirationYear" class="textbox">
|
||||
<!-- BEGIN: expiration_years -->
|
||||
<option value="{VAL_EXPIRE_YEAR}" {EXPIRE_YEARS_SELECTED}>{VAL_EXPIRE_YEAR}</option>
|
||||
<!-- END: expiration_years -->
|
||||
</select></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<!-- BEGIN: issue_info -->
|
||||
<tr align="left">
|
||||
<td><strong>{LANG_ISSUE_DATE}</strong>
|
||||
<td>
|
||||
<select name="issueMonth" class="textbox">
|
||||
<!-- BEGIN: issue_months -->
|
||||
<option value="{VAL_ISSUE_MONTH}" {ISSUE_MONTHS_SELECTED}>{VAL_ISSUE_MONTH}</option>
|
||||
<!-- END: issue_months -->
|
||||
</select>
|
||||
/
|
||||
<select name="issueYear" class="textbox">
|
||||
<!-- BEGIN: issue_years -->
|
||||
<option value="{VAL_ISSUE_YEAR}" {ISSUE_YEARS_SELECTED}>{VAL_ISSUE_YEAR}</option>
|
||||
<!-- END: issue_years -->
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td><strong>{LANG_ISSUE_NO}</strong>
|
||||
<td><input type="text" name="issueNo" value="" size="4" maxlength="4" class="textbox" style="text-align: center" /></td>
|
||||
</tr>
|
||||
<!-- END: issue_info -->
|
||||
<tr align="left">
|
||||
<td align="left"><strong>{LANG_SECURITY_CODE}</strong>
|
||||
<td align="left"><input type="text" name="cvc2" value="" size="4" maxlength="4" class="textbox" style="text-align: center" />
|
||||
<span onmouseover="findObj('cvv-img').src='images/general/cvv.gif'" onmouseout="findObj('cvv-img').src='images/general/px.gif'" style="cursor: pointer; cursor: hand;"> ? </span> <div id="cvv" style="position:absolute; width: 1px; height: 1px;"><img src="images/general/px.gif" border="0" id="cvv-img" alt="" /></div></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" align="right" valign="bottom"> </td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td colspan="6" class="tdcartTitle"><strong>{LANG_CUST_INFO_TITLE}</strong></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td><strong>{LANG_EMAIL}</strong>
|
||||
<td colspan="3"><input type="text" name="emailAddress" value="{VAL_EMAIL_ADDRESS}" size="50" class="textbox" /></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td><strong>{LANG_ADDRESS}</strong></td>
|
||||
<td colspan="3"><input type="text" name="addr1" value="{VAL_ADD_1}" size="50" class="textbox" /></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td> </td>
|
||||
<td colspan="3"><input type="text" name="addr2" value="{VAL_ADD_2}" size="50" class="textbox" /> {LANG_OPTIONAL}</td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td>
|
||||
<strong>{LANG_CITY}</strong> </td>
|
||||
<td colspan="3">
|
||||
<input type="text" name="city" value="{VAL_CITY}" class="textbox" /> </td>
|
||||
</tr>
|
||||
|
||||
<tr align="left">
|
||||
<td>
|
||||
<strong>{LANG_STATE}</strong> </td>
|
||||
<td colspan="3">
|
||||
<!-- BEGIN: states_list -->
|
||||
<select id="state" name="state" class="textbox">
|
||||
<!-- BEGIN: states_loop -->
|
||||
<option value="{VAL_STATE_ABBR}" {VAL_STATE_SELECTED}>{VAL_STATE}</option>
|
||||
<!-- END: states_loop -->
|
||||
</select>
|
||||
<!-- END: states_list -->
|
||||
<!-- BEGIN: states_txtbox -->
|
||||
<input type="text" name="state" value="{VAL_STATE}" class="textbox" />
|
||||
<!-- END: states_txtbox --> </td>
|
||||
</tr>
|
||||
|
||||
<tr align="left">
|
||||
<td>
|
||||
<strong>{LANG_ZIPCODE}</strong> </td>
|
||||
<td colspan="3">
|
||||
<input type="text" name="postalCode" value="{VAL_POST_CODE}" size="10" maxlength="10" class="textbox" /> </td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<td><strong>{LANG_COUNTRY}</strong>
|
||||
<td colspan="3">
|
||||
<select name="country" class="textbox">
|
||||
<!-- BEGIN: repeat_countries -->
|
||||
<option value="{VAL_COUNTRY_ISO}" {COUNTRY_SELECTED}>{VAL_COUNTRY_NAME}</option>
|
||||
<!-- END: repeat_countries -->
|
||||
</select> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="gateway" value="{VAL_GATEWAY}" />
|
||||
<!-- END: form -->
|
||||
3
production/modules/altCheckout/PayPal_Pro/index.php
Normal file
3
production/modules/altCheckout/PayPal_Pro/index.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
die("Access Denied");
|
||||
?>
|
||||
1
production/modules/altCheckout/PayPal_Pro/logs/index.htm
Normal file
1
production/modules/altCheckout/PayPal_Pro/logs/index.htm
Normal file
@@ -0,0 +1 @@
|
||||
Access Denied
|
||||
BIN
production/modules/altCheckout/PayPal_Pro/paypal_cards_uk.gif
Normal file
BIN
production/modules/altCheckout/PayPal_Pro/paypal_cards_uk.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
BIN
production/modules/altCheckout/PayPal_Pro/paypal_cards_us.gif
Normal file
BIN
production/modules/altCheckout/PayPal_Pro/paypal_cards_us.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
33
production/modules/altCheckout/PayPal_Pro/process.inc.php
Normal file
33
production/modules/altCheckout/PayPal_Pro/process.inc.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| CubeCart 4
|
||||
| ========================================
|
||||
| CubeCart is a registered trade mark of Devellion Limited
|
||||
| Copyright Devellion Limited 2006. All rights reserved.
|
||||
| Devellion Limited,
|
||||
| 5 Bridge Street,
|
||||
| Bishops Stortford,
|
||||
| HERTFORDSHIRE.
|
||||
| CM23 2JU
|
||||
| UNITED KINGDOM
|
||||
| http://www.devellion.com
|
||||
| UK Private Limited Company No. 5323904
|
||||
| ========================================
|
||||
| Web: http://www.cubecart.com
|
||||
| Email: info (at) cubecart (dot) com
|
||||
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
||||
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
||||
+--------------------------------------------------------------------------
|
||||
| process.inc.php
|
||||
| ========================================
|
||||
| Process PayPal Express Checkout
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
if($_GET['payment']==1) {
|
||||
$orderSum = $order->getOrderSum($_GET['cart_order_id']);
|
||||
include("modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."wpp-".$module['mode'].CC_DS."DoExpressCheckoutPayment.php");
|
||||
} else {
|
||||
include("modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."wpp-".$module['mode'].CC_DS."ReviewOrder.php");
|
||||
}
|
||||
?>
|
||||
49
production/modules/altCheckout/PayPal_Pro/transfer.inc.php
Normal file
49
production/modules/altCheckout/PayPal_Pro/transfer.inc.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| CubeCart 4
|
||||
| ========================================
|
||||
| CubeCart is a Trade Mark of Devellion Limited
|
||||
| Copyright Devellion Limited 2005 - 2006. All rights reserved.
|
||||
| Devellion Limited,
|
||||
| 5 Bridge Street,
|
||||
| Bishops Stortford,
|
||||
| HERTFORDSHIRE.
|
||||
| CM23 2JU
|
||||
| UNITED KINGDOM
|
||||
| http://www.devellion.com
|
||||
| UK Private Limited Company No. 5323904
|
||||
| ========================================
|
||||
| Web: http://www.cubecart.com
|
||||
| Date: Tuesday, 17th October 2006
|
||||
| Email: sales (at) cubecart (dot) com
|
||||
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
||||
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
||||
+--------------------------------------------------------------------------
|
||||
| transfer.inc.php
|
||||
| ========================================
|
||||
| Core functions for the PayPal Direct Payment Gateway
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function repeatVars(){
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
function fixedVars(){
|
||||
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Other Vars
|
||||
////////
|
||||
$formAction = "index.php?_g=co&_a=step3&process=1&cart_order_id=".$_GET['cart_order_id'];
|
||||
$formMethod = "post";
|
||||
$formTarget = "_self";
|
||||
$transfer = "manual";
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*************************************************
|
||||
APIError.php
|
||||
|
||||
Displays error parameters.
|
||||
|
||||
Called by DoDirectPaymentReceipt.php, TransactionDetails.php,
|
||||
GetExpressCheckoutDetails.php and DoExpressCheckoutPayment.php.
|
||||
|
||||
*************************************************/
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
session_start();
|
||||
$resArray=$_SESSION['reshash'];
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PayPal PHP API Response</title>
|
||||
<link href="sdk.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body alink=#0000FF vlink=#0000FF>
|
||||
|
||||
<center>
|
||||
|
||||
<table width="700">
|
||||
<tr>
|
||||
<td colspan="2"><h3>The PayPal API has returned an error!</h3></td>
|
||||
</tr>
|
||||
|
||||
<?php //it will print if any URL errors
|
||||
if(isset($_SESSION['curl_error_no'])) {
|
||||
$errorCode = $_SESSION['curl_error_no'] ;
|
||||
$errorMessage = $_SESSION['curl_error_msg'] ;
|
||||
?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><strong>Error Number:</strong></td>
|
||||
<td><?php $errorCode ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Error Message:</strong></td>
|
||||
<td><?php $errorMessage ?></td>
|
||||
</tr>
|
||||
<?php } else {
|
||||
|
||||
/* If there is no URL Errors, Construct the HTML page with
|
||||
Response Error parameters.
|
||||
*/
|
||||
?>
|
||||
|
||||
<td><strong>Ack:</strong></td>
|
||||
<td><?php $resArray['ACK']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Correlation ID:</strong></td>
|
||||
<td><?php $resArray['CORRELATIONID']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Version:</strong></td>
|
||||
<td><?php $resArray['VERSION']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$count=0;
|
||||
while (isset($resArray["L_SHORTMESSAGE".$count])) {
|
||||
$errorCode = $resArray["L_ERRORCODE".$count];
|
||||
$shortMessage = $resArray["L_SHORTMESSAGE".$count];
|
||||
$longMessage = $resArray["L_LONGMESSAGE".$count];
|
||||
$count=$count+1;
|
||||
?>
|
||||
<tr>
|
||||
<td><strong>Error Number:</strong></td>
|
||||
<td><?php $errorCode; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Short Message:</strong></td>
|
||||
<td><?php $shortMessage; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Long Message:</strong></td>
|
||||
<td><?php $longMessage; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php }//end while
|
||||
}// end else
|
||||
?>
|
||||
</table>
|
||||
<a class="home" id="CallsLink" href="index.php">Home</a>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
session_unset();
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,695 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'constants.php';
|
||||
|
||||
session_start();
|
||||
|
||||
function pp_debug($nvpreq,$response) {
|
||||
|
||||
$filename = "modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."logs".CC_DS.'PayPal-NVP-UK-Log-'.date("Ymd");
|
||||
$content = "=== ".date("r")." ===\n";
|
||||
$content .= "NVP String:\n".$nvpreq."\n--------------------\n";
|
||||
$content .= "cURL Response:\n".$response."\n=======================================\n\n\n\n";
|
||||
|
||||
$handle = @fopen($filename, 'a');
|
||||
@fwrite($handle, $content);
|
||||
@fclose($handle);
|
||||
}
|
||||
|
||||
function hash_call($TENDER,$TRXTYPE,$nvpStr,$request_id) {
|
||||
|
||||
global $ini;
|
||||
|
||||
$headers[] = "Content-Type: text/namevalue"; // either text/namevalue or text/xml
|
||||
$headers[] = "X-VPS-Timeout: 30";
|
||||
$headers[] = "X-VPS-VIT-OS-Name: ".PHP_OS; // Name of your Operating System (OS)
|
||||
$headers[] = "X-VPS-VIT-OS-Version: Unknown"; // OS Version
|
||||
$headers[] = "X-VPS-VIT-Client-Type: PHP/cURL"; // Language you are using
|
||||
$headers[] = "X-VPS-VIT-Client-Version: 0.01"; // For your info
|
||||
$headers[] = "X-VPS-VIT-Client-Architecture: Unknown"; // For your info
|
||||
$headers[] = "X-VPS-VIT-Client-Certification-Id: 33baf5893fc2123d8b191d2d011b7fdc"; // This header requirement will be removed
|
||||
$headers[] = "X-VPS-VIT-Integration-Product: CubeCart"; // For your info, would populate with application name
|
||||
$headers[] = "X-VPS-VIT-Integration-Version: ".$ini['ver']; // Application version
|
||||
$headers[] = "X-VPS-Request-ID: ".$request_id;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, API_ENDPOINT);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0); // tells curl to include headers in response
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
if(USE_PROXY) curl_setopt ($ch, CURLOPT_PROXY, PROXY_HOST.":".PROXY_PORT);
|
||||
|
||||
//NVPRequest for submitting to server
|
||||
|
||||
$verbosity = "MEDIUM";
|
||||
|
||||
$nvpreq = "TRXTYPE[".strlen($TRXTYPE)."]=".$TRXTYPE.
|
||||
"&TENDER[".strlen($TENDER)."]=".$TENDER.
|
||||
"&PWD[".strlen(PWD)."]=".PWD.
|
||||
"&USER[".strlen(USER)."]=".USER.
|
||||
"&VENDOR[".strlen(VENDOR)."]=".VENDOR.
|
||||
"&PARTNER[".strlen(PARTNER)."]=".PARTNER.
|
||||
"&VERBOSITY[".strlen($verbosity)."]=".$verbosity.
|
||||
$nvpStr;
|
||||
|
||||
//setting the nvpreq as POST FIELD to curl
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS,$nvpreq);
|
||||
|
||||
//getting response from server
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if(PAYPAL_DEBUG==true) {
|
||||
pp_debug($nvpreq,$response);
|
||||
}
|
||||
|
||||
//convrting NVPResponse to an Associative Array
|
||||
$nvpResArray = deformatNVP($response);
|
||||
$nvpReqArray = deformatNVP($nvpreq);
|
||||
$_SESSION['nvpReqArray']=$nvpReqArray;
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
echo "<strong>Curl Error No:</strong> ".curl_errno($ch)."<br />For further info please see: <a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'>http://curl.haxx.se/libcurl/c/libcurl-errors.html</a>";
|
||||
exit;
|
||||
|
||||
} else {
|
||||
//closing the curl
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
return $nvpResArray;
|
||||
|
||||
}
|
||||
|
||||
function deformatNVP($nvpStr) {
|
||||
|
||||
$intial=0;
|
||||
$nvpArray = array();
|
||||
|
||||
|
||||
while(strlen($nvpStr)){
|
||||
//postion of Key
|
||||
$keypos= strpos($nvpStr,'=');
|
||||
//position of value
|
||||
$valuepos = strpos($nvpStr,'&') ? strpos($nvpStr,'&'): strlen($nvpStr);
|
||||
|
||||
/*getting the Key and Value values and storing in a Associative Array*/
|
||||
$keyval=substr($nvpStr,$intial,$keypos);
|
||||
$valval=substr($nvpStr,$keypos+1,$valuepos-$keypos-1);
|
||||
//decoding the respose
|
||||
$nvpArray[urldecode($keyval)] = urldecode( $valval);
|
||||
$nvpStr=substr($nvpStr,$valuepos+1,strlen($nvpStr));
|
||||
}
|
||||
return $nvpArray;
|
||||
}
|
||||
|
||||
function paypalErrors($resArray) {
|
||||
|
||||
|
||||
switch($resArray["RESULT"]) {
|
||||
|
||||
case 1:
|
||||
$error['admin'] = "User authentication failed. Error is caused by one or more of the following:
|
||||
Invalid Processor information entered. Contact merchant bank to verify.
|
||||
'Allowed IP Address' security feature implemented. The transaction is coming from
|
||||
an unknown IP address. See PayPal Manager Online Help for details on how to use
|
||||
Manager to update the allowed IP addresses.
|
||||
You are using a test (not active) account to submit a transaction to the live PayPal
|
||||
servers. Change the URL from test-payflow.verisign.com to payflow.verisign.com.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$error['admin'] = "Invalid tender type. Your merchant bank account does not support the following
|
||||
credit card type that was submitted.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$error['admin'] = "Invalid transaction type. Transaction type is not appropriate for this transaction. For
|
||||
example, you cannot credit an authorisation-only transaction.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$error['admin'] = "Invalid amount format. Use the format: “#####.##” Do not include currency symbols
|
||||
or commas.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$error['admin'] = "Invalid merchant information. Processor does not recognise your merchant account
|
||||
information. Contact your bank account acquirer to resolve this problem.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$error['admin'] = "Invalid or unsupported currency code";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
$error['admin'] = "Field format error. Invalid information entered. See RESPMSG.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$error['admin'] = "Not a transaction server";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
$error['admin'] = "Too many parameters or invalid stream";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
$error['admin'] = "Too many line items";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 11:
|
||||
$error['admin'] = "Client time-out waiting for response";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$error['admin'] = "Declined. Check the credit card number, expiry date and transaction information to
|
||||
make sure they were entered correctly. If this does not resolve the problem, have the
|
||||
customer call their card issuing bank to resolve.";
|
||||
$error['customer'] = "Card declined. Please check the card number and expiry date have been entered correctly.";
|
||||
break;
|
||||
|
||||
case 13:
|
||||
$error['admin'] = "Referral. Transaction cannot be approved electronically but can be approved with a
|
||||
verbal authorisation. Contact your merchant bank to obtain an authorisation and submit
|
||||
a manual Voice Authorisation transaction.";
|
||||
$error['customer'] = "Unfortunately this transaction cannot be approved electronically. Please contact you bank and ask them to manually authorize this transaction.";
|
||||
break;
|
||||
|
||||
case 14:
|
||||
$error['admin'] = "Invalid Client Certification ID. Check the HTTP header. If the tag, X-VPS-VIT-
|
||||
CLIENT-CERTIFICATION-ID, is missing, RESULT code 14 is returned.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
$error['admin'] = "Original transaction ID not found. The transaction ID you entered for this
|
||||
transaction is not valid. See RESPMSG.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 20:
|
||||
$error['admin'] = "Cannot find the customer reference number";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 22:
|
||||
$error['admin'] = "Invalid ABA number";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 23:
|
||||
$error['admin'] = "Invalid account number. Check credit card number and re-submit.";
|
||||
$error['customer'] = "The credit card number entered is invalid. Please check and try again.";
|
||||
break;
|
||||
|
||||
case 24:
|
||||
$error['admin'] = "Invalid expiry date. Check and re-submit.";
|
||||
$error['customer'] = "Invalid expiry date. Please check and try again.";
|
||||
break;
|
||||
|
||||
case 25:
|
||||
$error['admin'] = "Invalid Host Mapping. You are trying to process a tender type such as Discover Card,
|
||||
but you are not set up with your merchant bank to accept this card type.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 26:
|
||||
$error['admin'] = "Invalid vendor account";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 27:
|
||||
$error['admin'] = "Insufficient partner permissions";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 28:
|
||||
$error['admin'] = "Insufficient user permissions";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 29:
|
||||
$error['admin'] = "Invalid XML document. This could be caused by an unrecognised XML tag or a bad
|
||||
XML format that cannot be parsed by the system.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
$error['admin'] = "Duplicate transaction";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 31:
|
||||
$error['admin'] = "Error in adding the recurring profile";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
$error['admin'] = "Error in modifying the recurring profile";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
$error['admin'] = "Error in cancelling the recurring profile";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
$error['admin'] = "Error in forcing the recurring profile";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 35:
|
||||
$error['admin'] = "Error in reactivating the recurring profile";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 36:
|
||||
$error['admin'] = "OLTP Transaction failed";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 37:
|
||||
$error['admin'] = "Invalid recurring profile ID";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 50:
|
||||
$error['admin'] = "Insufficient funds available in account";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 51:
|
||||
$error['admin'] = "Exceeds per transaction limit";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 99:
|
||||
$error['admin'] = "General error. See RESPMSG.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 100:
|
||||
$error['admin'] = "Transaction type not supported by host";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 101:
|
||||
$error['admin'] = "Time-out value too small";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 102:
|
||||
$error['admin'] = "Processor not available";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 103:
|
||||
$error['admin'] = "Error reading response from host";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 104:
|
||||
$error['admin'] = "Timeout waiting for processor response. Try your transaction again.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 105:
|
||||
$error['admin'] = "Credit error. Make sure you have not already credited this transaction, or that this
|
||||
transaction ID is for a creditable transaction. (For example, you cannot credit an
|
||||
authorisation.)";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 106:
|
||||
$error['admin'] = "Host not available";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 107:
|
||||
$error['admin'] = "Duplicate suppression time-out";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 108:
|
||||
$error['admin'] = "Void error. See RESPMSG. Make sure the transaction ID entered has not already been
|
||||
voided. If not, then look at the Transaction Detail screen for this transaction to see if it
|
||||
has settled. (The Batch field is set to a number greater than zero if the transaction has
|
||||
been settled.) If the transaction has already settled, your only recourse is a reversal
|
||||
(credit a payment or submit a payment for a credit).";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 109:
|
||||
$error['admin'] = "Time-out waiting for host response";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 110:
|
||||
$error['admin'] = "Referenced auth (against order) Error";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 111:
|
||||
$error['admin'] = "Capture error. Either an attempt to capture a transaction that is not an authorisation
|
||||
transaction type, or an attempt to capture an authorisation transaction that has already
|
||||
been captured.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 112:
|
||||
$error['admin'] = "Failed AVS check. Address and ZIP code do not match. An authorisation may still
|
||||
exist on the cardholder’s account.";
|
||||
$error['customer'] = "Failed AVS check. The address and zip/postcode does not match the card holders account details.";
|
||||
break;
|
||||
|
||||
case 113:
|
||||
$error['admin'] = "Merchant sale total will exceed the sales cap with current transaction. ACH
|
||||
transactions only.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 114:
|
||||
$error['admin'] = "Card Security Code (CSC) Mismatch. An authorisation may still exist on the
|
||||
cardholder’s account.";
|
||||
$error['customer'] = "The CVV2 security code does not match. Please try again.";
|
||||
break;
|
||||
|
||||
case 115:
|
||||
$error['admin'] = "System busy, try again later";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 116:
|
||||
$error['admin'] = "VPS Internal error. Failed to lock terminal number";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 117:
|
||||
$error['admin'] = "Failed merchant rule check. One or more of the following three failures occurred:
|
||||
An attempt was made to submit a transaction that failed to meet the security settings
|
||||
specified on the PayPal Manager Security Settings page. If the transaction exceeded the
|
||||
Maximum Amount security setting, then no values are returned for AVS or CSC.
|
||||
AVS validation failed. The AVS return value should appear in the RESPMSG.
|
||||
CSC validation failed. The CSC return value should appear in the RESPMSG.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 118:
|
||||
$error['admin'] = "Invalid keywords found in string fields";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 119:
|
||||
$error['admin'] = "General failure within PIM Adapter";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 120:
|
||||
$error['admin'] = "Attempt to reference a failed transaction";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 121:
|
||||
$error['admin'] = "Not enabled for feature";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 122:
|
||||
$error['admin'] = "Merchant sale total will exceed the credit cap with current transaction. ACH
|
||||
transactions only.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 125:
|
||||
$error['admin'] = "Fraud Protection Services Filter — Declined by filters";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 126:
|
||||
$error['admin'] = "Fraud Protection Services Filter — Flagged for review by filters
|
||||
Important Note: Result code 126 indicates that a transaction triggered a fraud filter.
|
||||
This is not an error, but a notice that the transaction is in a review status. The
|
||||
transaction has been authorised but requires you to review and manually accept the
|
||||
transaction before it will be allowed to settle.
|
||||
Result code 126 is intended to give you an idea of the kind of transaction that is
|
||||
considered suspicious to enable you to evaluate whether you can benefit from using the
|
||||
Fraud Protection Services.
|
||||
To eliminate result 126, turn the filters off.
|
||||
For more information, see the Fraud Protection Services documentation for your
|
||||
payments solution. It is available on the PayPal Manager Documentation page.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 127:
|
||||
$error['admin'] = "Fraud Protection Services Filter — Not processed by filters";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 128:
|
||||
$error['admin'] = "Fraud Protection Services Filter — Declined by merchant after being flagged for
|
||||
review by filters";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 131:
|
||||
$error['admin'] = "Version 1 Website Payments Pro SDK client no longer supported. Upgrade to the
|
||||
most recent version of the Website Payments Pro client.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 132:
|
||||
$error['admin'] = "Card has not been submitted for update";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 133:
|
||||
$error['admin'] = "Data mismatch in HTTP retry request";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 150:
|
||||
$error['admin'] = "Issuing bank timed out";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 151:
|
||||
$error['admin'] = "Issuing bank unavailable";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 200:
|
||||
$error['admin'] = "Reauth error";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 201:
|
||||
$error['admin'] = "Order error";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 402:
|
||||
$error['admin'] = "PIM Adapter Unavailable";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 403:
|
||||
$error['admin'] = "PIM Adapter stream error";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 404:
|
||||
$error['admin'] = "PIM Adapter Timeout";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 600:
|
||||
$error['admin'] = "Cybercash Batch Error";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 601:
|
||||
$error['admin'] = "Cybercash Query Error";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1000:
|
||||
$error['admin'] = "Generic host error. This is a generic message returned by your credit card processor.
|
||||
The RESPMSG will contain more information describing the error.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1001:
|
||||
$error['admin'] = "Buyer Authentication Service unavailable";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1002:
|
||||
$error['admin'] = "Buyer Authentication Service — Transaction timeout";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1003:
|
||||
$error['admin'] = "Buyer Authentication Service — Invalid client version";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1004:
|
||||
$error['admin'] = "Buyer Authentication Service — Invalid timeout value";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1011:
|
||||
$error['admin'] = "Buyer Authentication Service unavailable";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1012:
|
||||
$error['admin'] = "Buyer Authentication Service unavailable";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1013:
|
||||
$error['admin'] = "Buyer Authentication Service unavailable";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1014:
|
||||
$error['admin'] = "Buyer Authentication Service — Merchant is not enrolled for Buyer
|
||||
Authentication Service (3-D Secure).";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1016:
|
||||
$error['admin'] = "Buyer Authentication Service — 3-D Secure error response received. Instead of
|
||||
receiving a PARes response to a Validate Authentication transaction, an error response
|
||||
was received.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1017:
|
||||
$error['admin'] = "Buyer Authentication Service — 3-D Secure error response is invalid. An error
|
||||
response is received and the response is not well formed for a Validate Authentication
|
||||
transaction.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1021:
|
||||
$error['admin'] = "Buyer Authentication Service — Invalid card type";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1022:
|
||||
$error['admin'] = "Buyer Authentication Service — Invalid or missing currency code";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1023:
|
||||
$error['admin'] = "Buyer Authentication Service — merchant status for 3D secure is invalid";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1041:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: missing or
|
||||
invalid PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1042:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: PARES format is
|
||||
invalid";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1043:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Cannot find
|
||||
successful Verify Enrolment";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1044:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Signature
|
||||
validation failed for PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1045:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid amount in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1046:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid acquirer in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1047:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid Merchant ID in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1048:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid card number in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1049:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid currency code in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1050:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid XID in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1051:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: Mismatched or
|
||||
invalid order date in PARES";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
case 1052:
|
||||
$error['admin'] = "Buyer Authentication Service — Validate Authentication failed: This PARES was
|
||||
already validated for a previous Validate Authentication transaction";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
$error['admin'] = "No error code returned by PayPal. I have no idea what is going on.";
|
||||
$error['customer'] = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if($error['customer'] == false) {
|
||||
$error['customer'] = "This transaction is pending approval. A member of staff should contact you shortly with further advice. If you have any questions concerning this message or if you do not hear back from a staff member within a reasonable time please contact us quoting your order number.";
|
||||
}
|
||||
|
||||
$error['paypal'] = $resArray["RESPMSG"];
|
||||
|
||||
return $error;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$pppro = $db->select(sprintf("SELECT min(`id`), trans_id FROM `%sCubeCart_transactions` WHERE order_id = %s and `status` = 'SUCCESS' GROUP BY `id`",$glob['dbprefix'],$db->MySQLSafe($order_id)));
|
||||
|
||||
$authorizationID = trim($_POST['authorizationID']);
|
||||
$amount = sprintf("%.2f",trim($_POST['amount']));
|
||||
$note = trim($_POST['note']);
|
||||
$finalCapture = $_POST['CompleteCodeType']=="Complete" ? "Y" : "N";
|
||||
|
||||
$nvpStr = "&ORIGID[".strlen($authorizationID)."]=".$authorizationID."&AMT[".strlen($amount)."]=".$amount."&COMMENT1[".strlen($note)."]=".$note."&CAPTURECOMPLETE[".strlen($finalCapture)."]=".$finalCapture;
|
||||
|
||||
$request_id = md5($authorizationID.date('YmdGis')."1");
|
||||
|
||||
$resArray = hash_call($_POST['TENDER'],"D",$nvpStr,$request_id);
|
||||
|
||||
$ack = $resArray["RESULT"] == 0 ? "SUCCESS" : "FAIL";
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
|
||||
$errorMsg = paypalErrors($resArray);
|
||||
$transNotes = "<strong>Error:</strong> ".$errorMsg["admin"]."<br /><strong>PayPal Response:</strong> ".$errorMsg["paypal"];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".nl2br($transNotes)."</p>";
|
||||
} else {
|
||||
$transNotes = priceFormat($amount,true)." of authorization ID ".$authorizationID." captured successfully.";
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
|
||||
$query = "UPDATE ".$glob['dbprefix']."CubeCart_transactions SET `remainder` = `remainder` + ".$amount." WHERE `id` = '".$_POST['id']."';";
|
||||
$db->misc($query);
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoCapture)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $resArray['PNREF'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = $amount;
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$AMT = sprintf("%.2f",$orderSum['prod_total']);
|
||||
$ACCTTYPE = trim($_POST['cardType']);
|
||||
$ACCT = trim($_POST['cardNumber']);
|
||||
$EXPDATE = str_pad(trim($_POST['expirationMonth']), 2, '0', STR_PAD_LEFT).substr(trim($_POST['expirationYear']),2,2);
|
||||
$CVV2 = trim($_POST['cvc2']);
|
||||
$INVNUM = $orderSum['cart_order_id'];
|
||||
$EMAIL = $orderSum['email'];
|
||||
$FIRSTNAME = trim($_POST['firstName']);
|
||||
$LASTNAME = trim($_POST['lastName']);
|
||||
$STREET = trim($_POST['addr1']." ".$_POST['addr2']);
|
||||
$CITY = trim($_POST['city']);
|
||||
$STATE = trim($_POST['state']);
|
||||
$ZIP = trim($_POST['postalCode']);
|
||||
$COUNTRY = trim($_POST['country']);
|
||||
$CURRENCY = $config['defaultCurrency'];
|
||||
$CLIENTIP = trim(get_ip_address());
|
||||
|
||||
$CARDSTART = str_pad(trim($_POST['issueMonth']), 2, '0', STR_PAD_LEFT).substr(trim($_POST['issueYear']),2,2);
|
||||
$CARDISSUE = trim($_POST['issueNo']);
|
||||
|
||||
|
||||
|
||||
|
||||
$nvpStr =
|
||||
"&AMT[".strlen($AMT)."]=".$AMT
|
||||
."&ACCTTYPE[".strlen($ACCTTYPE)."]=".$ACCTTYPE
|
||||
."&ACCT[".strlen($ACCT)."]=".$ACCT
|
||||
."&EXPDATE[".strlen($EXPDATE)."]=".$EXPDATE
|
||||
."&CVV2[".strlen($CVV2)."]=".$CVV2
|
||||
."&INVNUM[".strlen($INVNUM)."]=".$INVNUM
|
||||
."&EMAIL[".strlen($EMAIL)."]=".$EMAIL
|
||||
."&FIRSTNAME[".strlen($FIRSTNAME)."]=".$FIRSTNAME
|
||||
."&LASTNAME[".strlen($LASTNAME)."]=".$LASTNAME
|
||||
."&STREET[".strlen($STREET)."]=".$STREET
|
||||
."&CITY[".strlen($CITY)."]=".$CITY
|
||||
."&STATE[".strlen($STATE)."]=".$STATE
|
||||
."&ZIP[".strlen($ZIP)."]=".$ZIP
|
||||
."&COUNTRY[".strlen($COUNTRY)."]=".$COUNTRY
|
||||
."&CURRENCY[".strlen($CURRENCY)."]=".$CURRENCY
|
||||
."&CLIENTIP[".strlen($CLIENTIP)."]=".$CLIENTIP;
|
||||
|
||||
// start && || issue for Solo/Maestro
|
||||
if($_POST['cardType'] == "9" || $_POST['cardType'] == "S") {
|
||||
$nvpStr .= "&CARDISSUE[".strlen($CARDISSUE)."]=".$CARDISSUE
|
||||
."&CARDSTART[".strlen($CARDSTART)."]=".$CARDSTART;
|
||||
}
|
||||
|
||||
$BUTTONSOURCE = "CubeCart_Cart_PRO2DP";
|
||||
|
||||
$nvpStr .="&BUTTONSOURCE[".strlen($BUTTONSOURCE)."]=".$BUTTONSOURCE;
|
||||
|
||||
$TRXTYPE = $module['paymentAction'] == "Sale" ? "S" : "A";
|
||||
|
||||
$request_id = md5($_POST['ACCT'].$_POST['AMT'].date('YmdGis')."1");
|
||||
|
||||
$resArray = hash_call("C",$TRXTYPE,$nvpStr,$request_id);
|
||||
|
||||
if($resArray["RESULT"] > 0) {
|
||||
|
||||
$ack = "FAIL";
|
||||
$errorMsg = paypalErrors($resArray);
|
||||
|
||||
} else {
|
||||
|
||||
$ack = "SUCCESS";
|
||||
// PPREF is the PayPal response transaction ID
|
||||
$resArray['TRANSACTIONID'] = $resArray["PNREF"];
|
||||
|
||||
include("responseCodes.php");
|
||||
|
||||
if(isset($resArray["AVSADDR"])) {
|
||||
$extraNotes .= "<strong>Address:</strong> ".basicResponse($resArray["AVSADDR"])."<br />";
|
||||
}
|
||||
if(isset($resArray["AVSZIP"])) {
|
||||
$extraNotes .= "<strong>Zip/Post Code:</strong> ".basicResponse($resArray["AVSZIP"])."<br />";
|
||||
}
|
||||
|
||||
if(isset($resArray["AUTHCODE"])) {
|
||||
$extraNotes .= "<strong>Auth code:</strong> ".basicResponse($resArray["AUTHCODE"])."<br />";
|
||||
}
|
||||
|
||||
if(isset($resArray["CVV2MATCH"])) {
|
||||
$extraNotes .= "<strong>CVV2 Match:</strong> ".basicResponse($resArray["CVV2MATCH"])."<br />";
|
||||
}
|
||||
if(isset($resArray["IAVS"])) {
|
||||
$extraNotes .= "<strong>International AVS address response:</strong> ".basicResponse($resArray["IAVS"])."<br />";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$nvpStr = "&ACTION[1]=D".
|
||||
"&TOKEN[".strlen($_SESSION['token'])."]=".$_SESSION['token'].
|
||||
"&PAYERID[".strlen($_SESSION['payer_id'])."]=".$_SESSION['payer_id'].
|
||||
"&AMT[".strlen($orderSum['prod_total'])."]=".$orderSum['prod_total'].
|
||||
"&INVNUM[".strlen($_GET['cart_order_id'])."]=".$_GET['cart_order_id'];
|
||||
|
||||
$BUTTONSOURCE = "CubeCart_Cart_PRO2EC";
|
||||
|
||||
$nvpStr.="&BUTTONSOURCE[".strlen($BUTTONSOURCE)."]=".$BUTTONSOURCE;
|
||||
|
||||
$TRXTYPE = $module['paymentAction'] == "Sale" ? "S" : "A";
|
||||
|
||||
$request_id = md5($_SESSION['payer_id'].$orderSum['prod_total'].$_SESSION['token'].date('YmdGis')."1");
|
||||
|
||||
$resArray = hash_call("P",$TRXTYPE,$nvpStr,$request_id);
|
||||
|
||||
$ack = $resArray["RESULT"] == 0 ? "SUCCESS" : "FAIL";
|
||||
|
||||
$transData['customer_id'] = $orderSum["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (".$_SESSION['paymentType'].")";
|
||||
$transData['extra'] = "P";
|
||||
$transData['trans_id'] = $resArray['PNREF'];
|
||||
$transData['order_id'] = $_GET['cart_order_id'];
|
||||
$transData['amount'] = $orderSum['prod_total'];
|
||||
$transData['status'] = $ack;
|
||||
|
||||
include("responseCodes.php");
|
||||
|
||||
if(isset($resArray["AVSADDR"])) {
|
||||
$extraNotes .= "Address: ".basicResponse($resArray["AVSADDR"]).", ";
|
||||
}
|
||||
if(isset($resArray["AVSZIP"])) {
|
||||
$extraNotes .= "Zip/Post Code: ".basicResponse($resArray["AVSZIP"]).", ";
|
||||
}
|
||||
|
||||
$extraNotes = substr($extraNotes0,-2);
|
||||
|
||||
if(strlen($extraNotes>5)) {
|
||||
$extraNotes = substr($extraNotes0,-2).".";
|
||||
}
|
||||
|
||||
$transData['notes'] = "Successful transaction via PayPal Express Checkout. Payer status is '".strtolower($_SESSION['PAYERSTATUS'])."'. ".$extraNotes;
|
||||
$order->storeTrans($transData);
|
||||
|
||||
if($ack=="SUCCESS"){
|
||||
// Sale = Funds taken immediately otherwise they may be taken later
|
||||
$orderStatus = ($_SESSION['paymentType'] == "Sale") ? 3 : 2; // 3 is payment complete, 2 is processing
|
||||
|
||||
$paymentResult = ($_SESSION['paymentType'] == "Sale") ? 2 : 3; // Just to confuse matter Al you plonker!! 2 = money taken 3 = money not yet taken (Athorized)
|
||||
|
||||
$order->orderStatus($orderStatus,$_GET['cart_order_id']);
|
||||
} else {
|
||||
$paymentResult = 1;
|
||||
}
|
||||
|
||||
session_unset();
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$pppro = $db->select(sprintf("SELECT min(`id`), trans_id FROM `%sCubeCart_transactions` WHERE order_id = %s and `status` = 'SUCCESS' GROUP BY `id`",$glob['dbprefix'],$db->MySQLSafe($order_id)));
|
||||
|
||||
$authorizationID=urlencode(trim($_POST['authorizationID']));
|
||||
|
||||
$amount=urlencode(trim($_POST['amount']));
|
||||
|
||||
$currency=urlencode($config['defaultCurrency']);
|
||||
|
||||
$nvpStr="&AUTHORIZATIONID[".strlen($authorizationID)."]=".$authorizationID."&AMT[".strlen($amount)."]=".$amount."&CURRENCYCODE[".strlen($currency)."]=".$currency;
|
||||
|
||||
$resArray=hash_call("DoReauthorization",$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$transNotes = $resArray['L_LONGMESSAGE0'];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".$resArray['L_LONGMESSAGE0']."</p>";
|
||||
} else {
|
||||
$transNotes = priceFormat($_POST['amount'],true)." of authorization ID ".$_POST['authorizationID']." reauthorized successfully.";
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoAuthorization)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $resArray['AUTHORIZATIONID'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = trim($_POST['amount']);
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$authorizationID = trim($_POST['authorization_id']);
|
||||
$note = trim($_POST['note']);
|
||||
|
||||
$nvpStr="&ORIGID[".strlen($authorizationID)."]=".$authorizationID;
|
||||
$nvpStr.="&NOTE[".strlen($note)."]=".$note;
|
||||
|
||||
$request_id = md5($authorizationID.date('YmdGis')."1");
|
||||
|
||||
$resArray = hash_call($_POST['TENDER'],"V",$nvpStr,$request_id);
|
||||
|
||||
$ack = $resArray["RESULT"] == 0 ? "SUCCESS" : "FAIL";
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$errorMsg = paypalErrors($resArray);
|
||||
$transNotes = "<strong>Error:</strong> ".$errorMsg["admin"]."<br /><strong>PayPal Response:</strong> ".$errorMsg["paypal"];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".nl2br($transNotes)."</p>";
|
||||
} else {
|
||||
$transNotes = "Authorization ".$_POST['authorization_id']." has been void.";
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoVoid)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $authorizationID;
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = "";
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
session_start();
|
||||
|
||||
$_SESSION['token'] = $_REQUEST['token'];
|
||||
$_SESSION['payer_id'] = $_REQUEST['PayerID'];
|
||||
|
||||
$_SESSION['paymentAmount'] = $_REQUEST['paymentAmount'];
|
||||
$_SESSION['currCodeType'] = $_REQUEST['currencyCodeType'];
|
||||
$_SESSION['paymentType'] = $_REQUEST['paymentType'];
|
||||
|
||||
$resArray = $_SESSION['reshash'];
|
||||
|
||||
if(!isset($resArray["SHIPTOSTATE"])) {
|
||||
session_unset();
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$customer = $db->select("SELECT `customer_id` FROM ".$glob['dbprefix']."CubeCart_customer WHERE `email` = ".$db->MySQLSafe($resArray['EMAIL']));
|
||||
|
||||
$countryId = getCountryFormat($resArray["SHIPTOCOUNTRY"],"iso","id");
|
||||
|
||||
$state = $db->select("SELECT `name` FROM ".$glob['dbprefix']."CubeCart_iso_counties WHERE `name` = ".$db->MySQLSafe($resArray["SHIPTOSTATE"])." AND `countryId` = '".$countryId."'");
|
||||
|
||||
if($state==true) {
|
||||
$stateName = $state[0]['name'];
|
||||
} else {
|
||||
$stateName = $resArray["SHIPTOSTATE"];
|
||||
}
|
||||
|
||||
$customerData['title'] = $db->MySQLSafe("");
|
||||
$customerData['firstName'] = $db->MySQLSafe($resArray["FIRSTNAME"]);
|
||||
$customerData['lastName'] = $db->MySQLSafe($resArray["LASTNAME"]);
|
||||
$customerData['add_1'] = $db->MySQLSafe($resArray["SHIPTOSTREET"]);
|
||||
$customerData['add_2'] = $db->MySQLSafe($resArray["SHIPTOSTREET2"]);
|
||||
$customerData['town'] = $db->MySQLSafe($resArray["SHIPTOCITY"]);
|
||||
$customerData['county'] = $db->MySQLSafe($stateName);
|
||||
$customerData['postcode'] = $db->MySQLSafe($resArray["SHIPTOZIP"]);
|
||||
$customerData['country'] = $db->MySQLSafe($countryId);
|
||||
$customerData['phone'] = $db->MySQLSafe("");
|
||||
|
||||
|
||||
if($customer==TRUE) {
|
||||
$db->update($glob['dbprefix']."CubeCart_customer",$customerData,"`email` = ".$db->MySQLSafe($resArray['EMAIL']));
|
||||
$customer_id = $customer[0]['customer_id'];
|
||||
} else {
|
||||
|
||||
// added insert data
|
||||
$password = randomPass(6);
|
||||
$customerData['password'] = $db->MySQLSafe(md5($password));
|
||||
$customerData['email'] = $db->MySQLSafe($resArray['EMAIL']);
|
||||
$customerData['regTime'] = $db->MySQLSafe(time());
|
||||
$customerData['ipAddress'] = $db->MySQLSafe(get_ip_address()); // this will be googles IP :-/
|
||||
// ghost membership
|
||||
$customerData['type'] = $db->MySQLSafe(2);
|
||||
|
||||
$db->insert($glob['dbprefix']."CubeCart_customer",$customerData);
|
||||
$customer_id = $db->insertid();
|
||||
|
||||
// send welcome email
|
||||
if($module['welcomeEmail'] == 1) {
|
||||
$emailLang = getLang("email.inc.php");
|
||||
|
||||
include(CC_ROOT_DIR.CC_DS."classes".CC_DS."htmlMimeMail".CC_DS."htmlMimeMail.php");
|
||||
$lang = getLang("email.inc.php");
|
||||
$mail = new htmlMimeMail();
|
||||
|
||||
$macroArray = array(
|
||||
"CUSTOMER_NAME" => sanitizeVar($resArray["FIRSTNAME"])." ".sanitizeVar($resArray["LASTNAME"]),
|
||||
"EMAIL" => sanitizeVar($resArray['EMAIL']),
|
||||
##"PASSWORD" => sanitizeVar((isset($randomPass)) ? $randomPass : $_POST['password']),
|
||||
"PASSWORD" => $password,
|
||||
"STORE_URL" => $GLOBALS['storeURL'],
|
||||
"SENDER_IP" => get_ip_address()
|
||||
);
|
||||
|
||||
$text = macroSub($lang['email']['new_reg_body'],$macroArray);
|
||||
unset($macroArray);
|
||||
|
||||
$mail->setText($text);
|
||||
$mail->setFrom($config['masterName'].' <'.$config['masterEmail'].'>');
|
||||
$mail->setSubject($lang['email']['new_reg_subject']);
|
||||
$mail->setHeader('X-Mailer', 'CubeCart Mailer');
|
||||
$mail->send(array(sanitizeVar($resArray['EMAIL'])), $config['mailMethod']);
|
||||
}
|
||||
|
||||
}
|
||||
## Add Customer ID to session data
|
||||
$data['customer_id'] = $customer_id;
|
||||
$update = $db->update($glob['dbprefix']."CubeCart_sessions", $data,"sessId=".$db->mySQLSafe($_COOKIE[CC_SESSION_NAME]));
|
||||
header("Location: index.php?_g=co&_a=step2");
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$ORIGID = trim($_POST['transactionId']);
|
||||
|
||||
$amount = sprintf("%.2f",trim($_POST['amount']));
|
||||
$refundType = $amount == $orderSum[0]['prod_total'] ? "FULL" : "PARTIAL";
|
||||
$memo = trim($_POST['note']);
|
||||
$nvpStr = "&ORIGID[".strlen($ORIGID)."]=".$ORIGID."&MEMO[".strlen($memo)."]=".$memo;
|
||||
|
||||
if($refundType=="PARTIAL") $nvpStr .= "&AMT[".strlen($amount)."]=".$amount;
|
||||
|
||||
$request_id = md5($_POST['transactionId'].date('YmdGis')."1");
|
||||
|
||||
$resArray = hash_call($_POST['TENDER'],"C",$nvpStr,$request_id);
|
||||
|
||||
$ack = $resArray["RESULT"] == 0 ? "SUCCESS" : "FAIL";
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$errorMsg = paypalErrors($resArray);
|
||||
$transNotes = "<strong>Error:</strong> ".$errorMsg["admin"]."<br /><strong>PayPal Response:</strong> ".$errorMsg["paypal"];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".nl2br($transNotes)."</p>";
|
||||
} else {
|
||||
$transNotes = ucfirst(strtolower($refundType))." Refund of ".priceFormat($amount,true)." successful.";
|
||||
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
$db->misc("UPDATE ".$glob['dbprefix']."CubeCart_transactions SET `remainder` = `remainder` + ".$amount." WHERE `id` = '".$_POST['id']."';");
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoRefund)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $resArray['PNREF'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = $amount;
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
require_once 'constants.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$token = $_REQUEST['token'];
|
||||
$TRXTYPE = $module['paymentAction'] == "Sale" ? "S" : "A";
|
||||
|
||||
if(!isset($token)) {
|
||||
|
||||
$parts = explode(",",base64_decode($_GET['ccb']));
|
||||
$paymentAmount = $parts[0];
|
||||
$currencyCodeType = $parts[1];
|
||||
$paymentType = $module['paymentAction'];
|
||||
|
||||
$returnURL = $glob['storeURL'].'/index.php?_g=rm&type=altCheckout&cmd=process&module=PayPal_Pro¤cyCodeType='.$currencyCodeType.'&paymentType='.$paymentType.'&paymentAmount='.$paymentAmount;
|
||||
|
||||
$cancelURL = $glob['storeURL']."/index.php?_g=rm&type=altCheckout&cmd=process&module=PayPal_Pro&paymentType=".$paymentType;
|
||||
|
||||
$AMT = sprintf("%.2f",$paymentAmount);
|
||||
|
||||
$nvpStr = "&ACTION[1]=S".
|
||||
"&AMT[".strlen($AMT)."]=".$AMT.
|
||||
"&RETURNURL[".strlen($returnURL)."]=".$returnURL.
|
||||
"&CANCELURL[".strlen($cancelURL)."]=".$cancelURL;
|
||||
|
||||
if($module['confAddress']==1) {
|
||||
$nvpStr.="&REQCONFIRMSHIPPING[1]=1";
|
||||
} else {
|
||||
$nvpStr.="&REQCONFIRMSHIPPING[1]=0";
|
||||
}
|
||||
|
||||
$BUTTONSOURCE = "CubeCart_Cart_PRO2EC";
|
||||
|
||||
$nvpStr.="&BUTTONSOURCE[".strlen($BUTTONSOURCE)."]=".$BUTTONSOURCE;
|
||||
$request_id = md5($_POST['ACCT'].$paymentAmount.date('YmdGis')."1");
|
||||
//$resArray = hash_call("SetExpressCheckout",$nvpStr);
|
||||
$resArray = hash_call("P",$TRXTYPE,$nvpStr,$request_id);
|
||||
|
||||
$_SESSION['reshash'] = $resArray;
|
||||
|
||||
if($resArray["RESULT"]==0){
|
||||
// Redirect to paypal.com here
|
||||
$token = urldecode($resArray["TOKEN"]);
|
||||
$payPalURL = PAYPAL_URL.$token;
|
||||
header("Location: ".$payPalURL);
|
||||
exit;
|
||||
} else {
|
||||
include("APIError.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$nvpStr = "&ACTION[1]=G&TOKEN[".strlen($token)."]=".$token;
|
||||
$request_id = md5($token.date('YmdGis')."1");
|
||||
//$resArray=hash_call("GetExpressCheckoutDetails",$nvpStr);
|
||||
$resArray = hash_call("P",$TRXTYPE,$nvpStr,$request_id);
|
||||
|
||||
$_SESSION['reshash']=$resArray;
|
||||
$_SESSION['PAYERSTATUS'] = $resArray['PAYERSTATUS'];
|
||||
|
||||
if($resArray["RESULT"]==0){
|
||||
require_once "GetExpressCheckoutDetails.php";
|
||||
exit;
|
||||
} else {
|
||||
include("APIError.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
define('USER', $module['user']);
|
||||
define('PWD', $module['pass']);
|
||||
define('VENDOR', $module['vendor']);
|
||||
define('PARTNER', $module['partner']);
|
||||
|
||||
if($module['gateway']==1){ ## LIVE MODE
|
||||
|
||||
define('API_ENDPOINT', 'https://payflowpro.verisign.com/transaction:443/');
|
||||
define('PAYPAL_URL', 'https://www.paypal.com/webscr&cmd=_express-checkout&token=');
|
||||
} else { ## SANDBOX MODE
|
||||
define('API_ENDPOINT', 'https://pilot-payflowpro.verisign.com/transaction:443/');
|
||||
//define('API_ENDPOINT', 'https://test-payflow.verisign.com/transaction:443/');
|
||||
define('PAYPAL_URL', 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=');
|
||||
}
|
||||
|
||||
if($config['proxy']==1){
|
||||
define('USE_PROXY', true);
|
||||
define('PROXY_HOST', $config['proxyHost']);
|
||||
define('PROXY_PORT', $config['proxyPort']);
|
||||
} else {
|
||||
define('USE_PROXY', false);
|
||||
define('PROXY_HOST', '127.0.0.1');
|
||||
define('PROXY_PORT', '808');
|
||||
}
|
||||
|
||||
if($module['debug']==true) {
|
||||
define("PAYPAL_DEBUG", true);
|
||||
} else {
|
||||
define("PAYPAL_DEBUG", false);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
Access Denied
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
function basicResponse($in) {
|
||||
|
||||
switch ($in) {
|
||||
|
||||
case "Y":
|
||||
|
||||
$out = "Matches.";
|
||||
|
||||
break;
|
||||
|
||||
case "N":
|
||||
$out = "Does not match.";
|
||||
break;
|
||||
|
||||
case "X":
|
||||
$out = "The cardholder’s bank does not support this service.";
|
||||
break;
|
||||
|
||||
default:
|
||||
$out = "No Response.";
|
||||
break;
|
||||
}
|
||||
|
||||
return $out;
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*************************************************
|
||||
APIError.php
|
||||
|
||||
Displays error parameters.
|
||||
|
||||
Called by DoDirectPaymentReceipt.php, TransactionDetails.php,
|
||||
GetExpressCheckoutDetails.php and DoExpressCheckoutPayment.php.
|
||||
|
||||
*************************************************/
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
session_start();
|
||||
$resArray=$_SESSION['reshash'];
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PayPal PHP API Response</title>
|
||||
<link href="sdk.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body alink=#0000FF vlink=#0000FF>
|
||||
|
||||
<center>
|
||||
|
||||
<table width="700">
|
||||
<tr>
|
||||
<td colspan="2"><h3>The PayPal API has returned an error!</h3></td>
|
||||
</tr>
|
||||
|
||||
<?php //it will print if any URL errors
|
||||
if(isset($_SESSION['curl_error_no'])) {
|
||||
$errorCode = $_SESSION['curl_error_no'] ;
|
||||
$errorMessage = $_SESSION['curl_error_msg'] ;
|
||||
?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><strong>Error Number:</strong></td>
|
||||
<td><?php $errorCode ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Error Message:</strong></td>
|
||||
<td><?php $errorMessage ?></td>
|
||||
</tr>
|
||||
<?php } else {
|
||||
|
||||
/* If there is no URL Errors, Construct the HTML page with
|
||||
Response Error parameters.
|
||||
*/
|
||||
?>
|
||||
|
||||
<td><strong>Ack:</strong></td>
|
||||
<td><?php $resArray['ACK']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Correlation ID:</strong></td>
|
||||
<td><?php $resArray['CORRELATIONID']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Version:</strong></td>
|
||||
<td><?php $resArray['VERSION']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$count=0;
|
||||
while (isset($resArray["L_SHORTMESSAGE".$count])) {
|
||||
$errorCode = $resArray["L_ERRORCODE".$count];
|
||||
$shortMessage = $resArray["L_SHORTMESSAGE".$count];
|
||||
$longMessage = $resArray["L_LONGMESSAGE".$count];
|
||||
$count=$count+1;
|
||||
?>
|
||||
<tr>
|
||||
<td><strong>Error Number:</strong></td>
|
||||
<td><?php $errorCode; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Short Message:</strong></td>
|
||||
<td><?php $shortMessage; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Long Message:</strong></td>
|
||||
<td><?php $longMessage; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php }//end while
|
||||
}// end else
|
||||
?>
|
||||
</table>
|
||||
<a class="home" id="CallsLink" href="index.php">Home</a>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
session_unset();
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/****************************************************
|
||||
CallerService.php
|
||||
|
||||
This file uses the constants.php to get parameters needed
|
||||
to make an API call and calls the server.if you want use your
|
||||
own credentials, you have to change the constants.php
|
||||
|
||||
Called by TransactionDetails.php, ReviewOrder.php,
|
||||
DoDirectPaymentReceipt.php and DoExpressCheckoutPayment.php.
|
||||
|
||||
****************************************************/
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
require_once 'constants.php';
|
||||
|
||||
$API_UserName=API_USERNAME;
|
||||
$API_Password=API_PASSWORD;
|
||||
$API_Signature=API_SIGNATURE;
|
||||
$API_Endpoint =API_ENDPOINT;
|
||||
$version=VERSION;
|
||||
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* hash_call: Function to perform the API call to PayPal using API signature
|
||||
* @methodName is name of API method.
|
||||
* @nvpStr is nvp string.
|
||||
* returns an associtive array containing the response from the server.
|
||||
*/
|
||||
function pp_debug($nvpreq,$response) {
|
||||
|
||||
// sanitize string
|
||||
$filename = "modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."logs".CC_DS.'PayPal-NVP-US-Log-'.date("Ymd");
|
||||
$content = "=== ".date("r")." ===\n";
|
||||
$content .= "NVP String:\n".$nvpreq."\n--------------------\n";
|
||||
$content .= "cURL Response:\n".$response."\n=======================================\n\n\n\n";
|
||||
|
||||
$handle = @fopen($filename, 'a');
|
||||
@fwrite($handle, $content);
|
||||
@fclose($handle);
|
||||
}
|
||||
|
||||
function hash_call($methodName,$nvpStr) {
|
||||
//declaring of global variables
|
||||
global $API_Endpoint,$version,$API_UserName,$API_Password,$API_Signature;
|
||||
|
||||
//setting the curl parameters.
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
||||
|
||||
//turning off the server and peer verification(TrustManager Concept).
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
|
||||
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
|
||||
if(USE_PROXY)
|
||||
curl_setopt ($ch, CURLOPT_PROXY, PROXY_HOST.":".PROXY_PORT);
|
||||
|
||||
//NVPRequest for submitting to server
|
||||
$nvpreq = "METHOD=".urlencode($methodName).
|
||||
"&VERSION=".urlencode($version).
|
||||
"&PWD=".urlencode($API_Password).
|
||||
"&USER=".urlencode($API_UserName).
|
||||
"&SIGNATURE=".urlencode($API_Signature).$nvpStr;
|
||||
|
||||
//setting the nvpreq as POST FIELD to curl
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
||||
|
||||
//getting response from server
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if(PAYPAL_DEBUG==true) {
|
||||
pp_debug($nvpreq,$response);
|
||||
}
|
||||
|
||||
//convrting NVPResponse to an Associative Array
|
||||
$nvpResArray=deformatNVP($response);
|
||||
$nvpReqArray=deformatNVP($nvpreq);
|
||||
$_SESSION['nvpReqArray']=$nvpReqArray;
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
switch (curl_errno($ch)) {
|
||||
case 18:
|
||||
break;
|
||||
default:
|
||||
echo "<strong>Curl Error No:</strong> ".curl_errno($ch)."<br />For further info please see: <a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'>http://curl.haxx.se/libcurl/c/libcurl-errors.html</a>";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
curl_close($ch);
|
||||
return $nvpResArray;
|
||||
}
|
||||
|
||||
/** This function will take NVPString and convert it to an Associative Array and it will decode the response.
|
||||
* It is usefull to search for a particular key and displaying arrays.
|
||||
* @nvpstr is NVPString.
|
||||
* @nvpArray is Associative Array.
|
||||
*/
|
||||
|
||||
function deformatNVP($nvpStr)
|
||||
{
|
||||
|
||||
$intial=0;
|
||||
$nvpArray = array();
|
||||
|
||||
|
||||
while(strlen($nvpStr)){
|
||||
//postion of Key
|
||||
$keypos= strpos($nvpStr,'=');
|
||||
//position of value
|
||||
$valuepos = strpos($nvpStr,'&') ? strpos($nvpStr,'&'): strlen($nvpStr);
|
||||
|
||||
/*getting the Key and Value values and storing in a Associative Array*/
|
||||
$keyval=substr($nvpStr,$intial,$keypos);
|
||||
$valval=substr($nvpStr,$keypos+1,$valuepos-$keypos-1);
|
||||
//decoding the respose
|
||||
$nvpArray[urldecode($keyval)] =urldecode( $valval);
|
||||
$nvpStr=substr($nvpStr,$valuepos+1,strlen($nvpStr));
|
||||
}
|
||||
return $nvpArray;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$pppro = $db->select(sprintf("SELECT min(`id`), trans_id FROM `%sCubeCart_transactions` WHERE order_id = %s and `status` = 'SUCCESS' GROUP BY `id`",$glob['dbprefix'],$db->MySQLSafe($order_id)));
|
||||
|
||||
$authorizationID = urlencode(trim($_POST['authorizationID']));
|
||||
$completeCodeType = urlencode(trim($_POST['CompleteCodeType']));
|
||||
$amount = urlencode(trim($_POST['amount']));
|
||||
$invoiceID = urlencode($order_id);
|
||||
$currency = urlencode($config['defaultCurrency']);
|
||||
$note = urlencode(trim($_POST['note']));
|
||||
|
||||
$nvpStr = "&AUTHORIZATIONID=$authorizationID&AMT=$amount&COMPLETETYPE=$completeCodeType&CURRENCYCODE=$currency&NOTE=$note";
|
||||
|
||||
$resArray = hash_call("DOCapture",$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$transNotes = $resArray['L_LONGMESSAGE0'];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".$resArray['L_LONGMESSAGE0']."</p>";
|
||||
} else {
|
||||
$transNotes = priceFormat(trim($_POST['amount']),true)." of authorization ID ".$_POST['authorizationID']." captured successfully.";
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
// Update balance (remainder)
|
||||
if($_POST['CompleteCodeType'] == "Complete"){
|
||||
$query = "UPDATE ".$glob['dbprefix']."CubeCart_transactions SET `remainder` = `amount` WHERE `id` = '".$_POST['id']."';";
|
||||
$db->misc($query);
|
||||
$transNotes .= " Final capture complete.";
|
||||
} else {
|
||||
$query = "UPDATE ".$glob['dbprefix']."CubeCart_transactions SET `remainder` = `remainder` + ".$resArray['AMT']." WHERE `id` = '".$_POST['id']."';";
|
||||
$db->misc($query);
|
||||
}
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoCapture)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $resArray['TRANSACTIONID'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = $resArray['AMT'];
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
// Order is Express Checkkout Only
|
||||
if($module['paymentAction'] == "Order") {
|
||||
$module['paymentAction'] = "Authorization";
|
||||
}
|
||||
|
||||
$paymentType = urlencode($module['paymentAction']);
|
||||
$firstName = urlencode(trim($_POST['firstName']));
|
||||
$lastName = urlencode(trim($_POST['lastName']));
|
||||
$creditCardType = urlencode(trim($_POST['cardType']));
|
||||
$creditCardNumber = urlencode(trim($_POST['cardNumber']));
|
||||
$expDateMonth = urlencode(trim($_POST['expirationMonth']));
|
||||
$expDateYear = urlencode(trim($_POST['expirationYear']));
|
||||
$cvv2Number = urlencode(trim($_POST['cvc2']));
|
||||
$address1 = urlencode(trim($_POST['addr1']));
|
||||
$address2 = urlencode(trim($_POST['addr2']));
|
||||
$city = urlencode(trim($_POST['city']));
|
||||
$state = urlencode(trim($_POST['state']));
|
||||
$zip = urlencode(trim($_POST['postalCode']));
|
||||
$amount = urlencode(sprintf("%.2f",$orderSum['prod_total']));
|
||||
$currencyCode = urlencode($config['defaultCurrency']);
|
||||
$countryCode = urlencode(trim($_POST['country']));
|
||||
$ipAddress = urlencode(trim(get_ip_address()));
|
||||
$padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
|
||||
|
||||
$nvpStr =
|
||||
"&PAYMENTACTION=".$paymentType
|
||||
."&AMT=".$amount
|
||||
."&CREDITCARDTYPE=".$creditCardType
|
||||
."&ACCT=".$creditCardNumber
|
||||
."&EXPDATE=".$padDateMonth.$expDateYear
|
||||
."&CVV2=".$cvv2Number
|
||||
."&FIRSTNAME=".$firstName
|
||||
."&LASTNAME=".$lastName
|
||||
."&STREET=".$address1
|
||||
."&CITY=".$city
|
||||
."&STATE=".$state
|
||||
."&ZIP=".$zip
|
||||
."&COUNTRYCODE=".$countryCode
|
||||
."&CURRENCYCODE=".$currencyCode
|
||||
."&IPADDRESS=".$ipAddress
|
||||
.="&BUTTONSOURCE=CubeCart_Cart_DP_US";
|
||||
|
||||
$resArray=hash_call("doDirectPayment",$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
$errorMsg['customer'] = $resArray["L_LONGMESSAGE0"];
|
||||
?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$token =urlencode($_SESSION['token']);
|
||||
|
||||
$paymentAmount = urlencode($orderSum['prod_total']);
|
||||
$paymentType = urlencode($_SESSION['paymentType']);
|
||||
$currCodeType = urlencode($_SESSION['currCodeType']);
|
||||
$payerID = urlencode($_SESSION['payer_id']);
|
||||
$serverName = urlencode($_SERVER['SERVER_NAME']);
|
||||
|
||||
$nvpStr='&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION='.$paymentType.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currCodeType.'&IPADDRESS='.$serverName.'&INVNUM='.$_GET['cart_order_id'] ;
|
||||
|
||||
$nvpStr.="&BUTTONSOURCE=CubeCart_Cart_EC_US";
|
||||
|
||||
$resArray=hash_call("DoExpressCheckoutPayment",$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
$transData['customer_id'] = $orderSum["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (".$paymentType.")";
|
||||
$transData['extra'] = "P";
|
||||
$transData['trans_id'] = $resArray['TRANSACTIONID'];
|
||||
$transData['order_id'] = $_GET['cart_order_id'];
|
||||
$transData['amount'] = $orderSum['prod_total'];
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = "Successful transaction via PayPal Express Checkout. Buyers address '".strtolower($_SESSION['ADDRESSSTATUS'])."' and payer status is '".strtolower($_SESSION['PAYERSTATUS'])."'.";
|
||||
$order->storeTrans($transData);
|
||||
|
||||
if($ack=="SUCCESS"){
|
||||
// Sale = Funds taken immediately otherwise they may be taken later
|
||||
$orderStatus = ($paymentType == "Sale") ? 3 : 2; // 3 is payment complete, 2 is processing
|
||||
|
||||
$paymentResult = ($paymentType == "Sale") ? 2 : 3; // Just to confuse matter Al you plonker!! 2 = money taken 3 = money not yet taken (Athorized)
|
||||
|
||||
$order->orderStatus($orderStatus,$_GET['cart_order_id']);
|
||||
} else {
|
||||
$paymentResult = 1;
|
||||
}
|
||||
|
||||
session_unset();
|
||||
?>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$pppro = $db->select(sprintf("SELECT min(`id`), trans_id FROM `%sCubeCart_transactions` WHERE order_id = %s and `status` = 'SUCCESS' GROUP BY `id`",$glob['dbprefix'],$db->MySQLSafe($order_id)));
|
||||
|
||||
$authorizationID = urlencode(trim($_POST['authorizationID']));
|
||||
|
||||
$amount=urlencode(trim($_POST['amount']));
|
||||
|
||||
$currency=urlencode($config['defaultCurrency']);
|
||||
|
||||
if($ppfunction=="doReAuth") {
|
||||
$nvpStr = "&AUTHORIZATIONID=".$authorizationID."&AMT=$amount&CURRENCYCODE=$currency";
|
||||
$authMode = "DoReauthorization";
|
||||
$pre = "re";
|
||||
} else {
|
||||
$nvpStr = "&TRANSACTIONID=".$authorizationID."&AMT=$amount&CURRENCYCODE=$currency&TRANSACTIONENTITY=Order";
|
||||
$authMode = "DoAuthorization";
|
||||
$pre = "";
|
||||
}
|
||||
|
||||
$resArray=hash_call($authMode,$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$transNotes = $resArray['L_LONGMESSAGE0'];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".$resArray['L_LONGMESSAGE0']."</p>";
|
||||
} else {
|
||||
$transNotes = priceFormat($_POST['amount'],true)." of ".$_POST['authorizationID']." ".$pre."authorized successfully.";
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoAuthorization)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = isset($resArray['TRANSACTIONID']) ? $resArray['TRANSACTIONID'] : $resArray['AUTHORIZATIONID'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = trim($_POST['amount']);
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$authorizationID=urlencode(trim($_POST['authorization_id']));
|
||||
$note=urlencode(trim($_POST['note']));
|
||||
|
||||
$nvpStr="&AUTHORIZATIONID=$authorizationID&NOTE=$note";
|
||||
|
||||
$resArray=hash_call("DoVoid",$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$transNotes = $resArray['L_LONGMESSAGE0'];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".$resArray['L_LONGMESSAGE0']."</p>";
|
||||
} else {
|
||||
$transNotes = "Authorization ".$_POST['authorization_id']." has been void.";
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoVoid)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $_POST['authorization_id'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = "";
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
session_start();
|
||||
|
||||
$_SESSION['token']=$_REQUEST['token'];
|
||||
$_SESSION['payer_id'] = $_REQUEST['PayerID'];
|
||||
|
||||
$_SESSION['paymentAmount'] = $_REQUEST['paymentAmount'];
|
||||
$_SESSION['currCodeType'] = $_REQUEST['currencyCodeType'];
|
||||
$_SESSION['paymentType'] = $_REQUEST['paymentType'];
|
||||
|
||||
$resArray = $_SESSION['reshash'];
|
||||
|
||||
if(!isset($resArray["SHIPTOSTATE"])) {
|
||||
session_unset();
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$customer = $db->select("SELECT `customer_id` FROM ".$glob['dbprefix']."CubeCart_customer WHERE `email` = ".$db->MySQLSafe($resArray['EMAIL']));
|
||||
|
||||
$countryId = getCountryFormat($resArray["SHIPTOCOUNTRYNAME"],"printable_name","id");
|
||||
|
||||
$state = $db->select("SELECT `name` FROM ".$glob['dbprefix']."CubeCart_iso_counties WHERE `abbrev` = ".$db->MySQLSafe($resArray["SHIPTOSTATE"])." AND `countryId` = ".$countryId);
|
||||
|
||||
if($state==true) {
|
||||
$stateName = $state[0]['name'];
|
||||
} else {
|
||||
$stateName = $resArray["SHIPTOSTATE"];
|
||||
}
|
||||
|
||||
$customerData['title'] = $db->MySQLSafe("");
|
||||
$customerData['firstName'] = $db->MySQLSafe($resArray["FIRSTNAME"]);
|
||||
$customerData['lastName'] = $db->MySQLSafe($resArray["LASTNAME"]);
|
||||
$customerData['add_1'] = $db->MySQLSafe($resArray["SHIPTOSTREET"]);
|
||||
$customerData['add_2'] = $db->MySQLSafe("");
|
||||
$customerData['town'] = $db->MySQLSafe($resArray["SHIPTOCITY"]);
|
||||
$customerData['county'] = $db->MySQLSafe($stateName);
|
||||
$customerData['postcode'] = $db->MySQLSafe($resArray["SHIPTOZIP"]);
|
||||
$customerData['country'] = $db->MySQLSafe($countryId);
|
||||
$customerData['phone'] = $db->MySQLSafe("");
|
||||
|
||||
|
||||
if($customer==TRUE) {
|
||||
$db->update($glob['dbprefix']."CubeCart_customer",$customerData,"`email` = ".$db->MySQLSafe($resArray['EMAIL']));
|
||||
$customer_id = $customer[0]['customer_id'];
|
||||
} else {
|
||||
|
||||
// added insert data
|
||||
$password = randomPass(6);
|
||||
$customerData['password'] = $db->MySQLSafe(md5($password));
|
||||
$customerData['email'] = $db->MySQLSafe($resArray['EMAIL']);
|
||||
$customerData['regTime'] = $db->MySQLSafe(time());
|
||||
$customerData['ipAddress'] = $db->MySQLSafe(get_ip_address()); // this will be googles IP :-/
|
||||
// ghost membership
|
||||
$customerData['type'] = $db->MySQLSafe(2);
|
||||
|
||||
$db->insert($glob['dbprefix']."CubeCart_customer",$customerData);
|
||||
$customer_id = $db->insertid();
|
||||
|
||||
// send welcome email
|
||||
if($module['welcomeEmail'] == 1) {
|
||||
$emailLang = getLang("email.inc.php");
|
||||
|
||||
include(CC_ROOT_DIR.CC_DS."classes".CC_DS."htmlMimeMail".CC_DS."htmlMimeMail.php");
|
||||
$lang = getLang("email.inc.php");
|
||||
$mail = new htmlMimeMail();
|
||||
|
||||
$macroArray = array(
|
||||
"CUSTOMER_NAME" => sanitizeVar($resArray["FIRSTNAME"])." ".sanitizeVar($resArray["LASTNAME"]),
|
||||
"EMAIL" => sanitizeVar($resArray['EMAIL']),
|
||||
##"PASSWORD" => sanitizeVar((isset($randomPass)) ? $randomPass : $_POST['password']),
|
||||
"PASSWORD" => $password,
|
||||
"STORE_URL" => $GLOBALS['storeURL'],
|
||||
"SENDER_IP" => get_ip_address()
|
||||
);
|
||||
|
||||
$text = macroSub($lang['email']['new_reg_body'],$macroArray);
|
||||
unset($macroArray);
|
||||
|
||||
$mail->setText($text);
|
||||
$mail->setFrom($config['masterName'].' <'.$config['masterEmail'].'>');
|
||||
$mail->setSubject($lang['email']['new_reg_subject']);
|
||||
$mail->setHeader('X-Mailer', 'CubeCart Mailer');
|
||||
$mail->send(array(sanitizeVar($resArray['EMAIL'])), $config['mailMethod']);
|
||||
}
|
||||
|
||||
}
|
||||
## Add Customer ID to session data
|
||||
$data['customer_id'] = $customer_id;
|
||||
$update = $db->update($glob['dbprefix']."CubeCart_sessions", $data,"sessId=".$db->mySQLSafe($_COOKIE[CC_SESSION_NAME]));
|
||||
header("Location: index.php?_g=co&_a=step2");
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
$transaction_id = urlencode(trim($_POST['transactionId']));
|
||||
$amount = sprintf("%.2f",trim($_POST['amount']));
|
||||
$refundType = $amount == $orderSum[0]['prod_total'] ? "FULL" : "PARTIAL";
|
||||
$refundType = urlencode($refundType);
|
||||
$amount = urlencode($amount);
|
||||
$currency = urlencode($config['defaultCurrency']);
|
||||
$memo = urlencode(trim($_POST['note']));
|
||||
|
||||
$nvpStr = "&TRANSACTIONID=$transaction_id&REFUNDTYPE=$refundType&CURRENCYCODE=$currency&NOTE=$memo";
|
||||
|
||||
if($refundType=="PARTIAL") $nvpStr .="&AMT=$amount";
|
||||
|
||||
$resArray = hash_call("RefundTransaction",$nvpStr);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
if($ack!=="SUCCESS"){
|
||||
$transNotes = $resArray['L_LONGMESSAGE0'];
|
||||
$ppMsg = "<p class='warnText' id='ppresult'>".$resArray['L_LONGMESSAGE0']."</p>";
|
||||
} else {
|
||||
$transNotes = ucfirst(strtolower($refundType))." Refund of ".priceFormat($resArray['GROSSREFUNDAMT'],true)." successful.";
|
||||
|
||||
$ppMsg = "<p class='infoText' id='ppresult'>".$transNotes."</p>";
|
||||
$db->misc("UPDATE ".$glob['dbprefix']."CubeCart_transactions SET `remainder` = `remainder` + ".$resArray['GROSSREFUNDAMT']." WHERE `id` = '".$_POST['id']."';");
|
||||
}
|
||||
|
||||
$transData['customer_id'] = $orderSum[0]["customer_id"];
|
||||
$transData['gateway'] = "PayPal Website Payments Pro (DoRefund)";
|
||||
$transData['extra'] = $_POST['TENDER'];
|
||||
$transData['trans_id'] = $resArray['REFUNDTRANSACTIONID'];
|
||||
$transData['order_id'] = $orderSum[0]['cart_order_id'];
|
||||
$transData['amount'] = $resArray['GROSSREFUNDAMT'];
|
||||
$transData['status'] = $ack;
|
||||
$transData['notes'] = $transNotes;
|
||||
$order->storeTrans($transData);
|
||||
?>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
|
||||
require_once 'CallerService.php';
|
||||
|
||||
require_once 'constants.php';
|
||||
|
||||
session_start();
|
||||
|
||||
|
||||
$token = $_REQUEST['token'];
|
||||
|
||||
if(! isset($token)) {
|
||||
|
||||
$parts = explode(",",base64_decode($_GET['ccb']));
|
||||
$paymentAmount = $parts[0];
|
||||
$currencyCodeType = $parts[1];
|
||||
$paymentType = $module['paymentAction'];
|
||||
|
||||
$returnURL =urlencode($glob['storeURL'].'/index.php?_g=rm&type=altCheckout&cmd=process&module=PayPal_Pro¤cyCodeType='.$currencyCodeType.'&paymentType='.$paymentType.'&paymentAmount='.$paymentAmount);
|
||||
|
||||
$cancelURL =urlencode($glob['storeURL']."/index.php?_g=rm&type=altCheckout&cmd=process&module=PayPal_Pro&paymentType=".$paymentType);
|
||||
|
||||
$nvpStr="&Amt=".sprintf("%.2f",$paymentAmount)."&PAYMENTACTION=".$paymentType."&ReturnUrl=".$returnURL."&CANCELURL=".$cancelURL ."&CURRENCYCODE=".$currencyCodeType;
|
||||
|
||||
$resArray=hash_call("SetExpressCheckout",$nvpStr);
|
||||
|
||||
$_SESSION['reshash']=$resArray;
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
|
||||
if($ack=="SUCCESS"){
|
||||
// Redirect to paypal.com here
|
||||
$token = urldecode($resArray["TOKEN"]);
|
||||
$payPalURL = PAYPAL_URL.$token;
|
||||
header("Location: ".$payPalURL);
|
||||
exit;
|
||||
} else {
|
||||
include("APIError.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$token = urlencode( $_REQUEST['token']);
|
||||
|
||||
$nvpStr="&TOKEN=".$token;
|
||||
|
||||
$resArray=hash_call("GetExpressCheckoutDetails",$nvpStr);
|
||||
|
||||
$_SESSION['reshash']=$resArray;
|
||||
$_SESSION['PAYERSTATUS'] = $resArray['PAYERSTATUS'];
|
||||
$_SESSION['ADDRESSSTATUS'] = $resArray["ADDRESSSTATUS"];
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
|
||||
if($module['confAddress']==1 && strtoupper($resArray["ADDRESSSTATUS"])!=="CONFIRMED") {
|
||||
httpredir("index.php?_g=co&_a=error&code=10003");
|
||||
}
|
||||
|
||||
if($ack=="SUCCESS"){
|
||||
require_once "GetExpressCheckoutDetails.php";
|
||||
exit;
|
||||
} else {
|
||||
include("APIError.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
if (!defined('CC_INI_SET')) die("Access Denied");
|
||||
/****************************************************
|
||||
constants.php
|
||||
|
||||
This is the configuration file for the samples.This file
|
||||
defines the parameters needed to make an API call.
|
||||
|
||||
PayPal includes the following API Signature for making API
|
||||
calls to the PayPal sandbox:
|
||||
|
||||
API Username sdk-three_api1.sdk.com
|
||||
API Password QFZCWN5HZM8VBG7Q
|
||||
API Signature A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU
|
||||
|
||||
Called by CallerService.php.
|
||||
****************************************************/
|
||||
|
||||
/**
|
||||
# API user: The user that is identified as making the call. you can
|
||||
# also use your own API username that you created on PayPal’s sandbox
|
||||
# or the PayPal live site
|
||||
*/
|
||||
define('API_USERNAME', $module['username']);
|
||||
/**
|
||||
# API_password: The password associated with the API user
|
||||
# If you are using your own API username, enter the API password that
|
||||
# was generated by PayPal below
|
||||
# IMPORTANT - HAVING YOUR API PASSWORD INCLUDED IN THE MANNER IS NOT
|
||||
# SECURE, AND ITS ONLY BEING SHOWN THIS WAY FOR TESTING PURPOSES
|
||||
*/
|
||||
define('API_PASSWORD', $module['password']);
|
||||
/**
|
||||
# API_Signature:The Signature associated with the API user. which is generated by paypal.
|
||||
*/
|
||||
define('API_SIGNATURE', $module['signature']);
|
||||
|
||||
if($module['gateway']==1){ ## LIVE MODE
|
||||
/**
|
||||
# Endpoint: this is the server URL which you have to connect for submitting your API request.
|
||||
*/
|
||||
define('API_ENDPOINT', 'https://api-3t.paypal.com/nvp');
|
||||
/* Define the PayPal URL. This is the URL that the buyer is
|
||||
first sent to to authorize payment with their paypal account
|
||||
change the URL depending if you are testing on the sandbox
|
||||
or going to the live PayPal site
|
||||
For the sandbox, the URL is
|
||||
https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
|
||||
For the live site, the URL is
|
||||
https://www.paypal.com/webscr&cmd=_express-checkout&token=
|
||||
*/
|
||||
define('PAYPAL_URL', 'https://www.paypal.com/webscr&cmd=_express-checkout&token=');
|
||||
} else { ## SANDBOX MODE
|
||||
define('API_ENDPOINT', 'https://api-3t.sandbox.paypal.com/nvp');
|
||||
define('PAYPAL_URL', 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=');
|
||||
}
|
||||
|
||||
if($config['proxy']==1){
|
||||
|
||||
/**
|
||||
USE_PROXY: Set this variable to true to route all the API requests through proxy.
|
||||
like define('USE_PROXY',true);
|
||||
*/
|
||||
define('USE_PROXY',true);
|
||||
/**
|
||||
PROXY_HOST: Set the host name or the IP address of proxy server.
|
||||
PROXY_PORT: Set proxy port.
|
||||
|
||||
PROXY_HOST and PROXY_PORT will be read only if USE_PROXY is set to true
|
||||
*/
|
||||
define('PROXY_HOST', $config['proxyHost']);
|
||||
define('PROXY_PORT', $config['proxyPort']);
|
||||
} else {
|
||||
define('USE_PROXY',false);
|
||||
define('PROXY_HOST', '127.0.0.1');
|
||||
define('PROXY_PORT', '808');
|
||||
}
|
||||
/**
|
||||
# Version: this is the API version in the request.
|
||||
# It is a mandatory parameter for each API request.
|
||||
# The only supported value at this time is 2.3
|
||||
*/
|
||||
if($module['debug']==true) {
|
||||
define("PAYPAL_DEBUG", true);
|
||||
} else {
|
||||
define("PAYPAL_DEBUG", false);
|
||||
}
|
||||
|
||||
define('VERSION', '2.3');
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
Access Denied
|
||||
Reference in New Issue
Block a user