Click to See Complete Forum and Search --> : Parse error: syntax error, unexpected T_EXIT


RyanL
03-18-2008, 12:19 AM
I'm getting the following error:

Parse error: syntax error, unexpected T_EXIT in /home/snh/public_html/AHYRadio/amember/plugins/payment/1shoppingcart/1shoppingcart.inc.php on line 1

Here is what I have - the copying and pasting messed up the formatting - sorry!

It was working fine, but I was told I could edit the line var $title = "1ShoppingCart" to whatever I wanted. I changed it to "Pay with Credit Card" and then I started getting this error.

Any help would be greately appreciated!!

<?phpif (!defined('INCLUDED_AMEMBER_CONFIG')) die("Direct access to this location is not allowed");/**** Author: Alex Scott* Email: alex@cgi-central.net* Web: http://www.cgi-central.net* Details: 1ShoppingCart Payment Plugin* FileName $RCSfile: paypal_r.inc.php,v $* Release: 3.0.9PRO ($Revision: 1.8 $)** Please direct bug reports,suggestions or feedback to the cgi-central forums.* http://www.cgi-central.net/forum/** aMember PRO is a commercial software. Any distribution is strictly prohibited.*/class payment_1shoppingcart extends amember_payment { var $title = "1ShoppingCart"; var $description = "All major credit cards accepted"; var $fixed_price=1; var $recurring=1; var $built_in_trials=1; function do_bill($amount, $title, $products, $u, $invoice){ global $config; $_SESSION['_amember_payment_id'] = $invoice; $vars = array( 'MerchantID' => $this->config['merchant_id'], 'ProductID' => $products[0]['1shoppingcart_id'], 'AMemberID' => $invoice, 'PostBackURL' => $config['root_url'] . "/plugins/payment/1shoppingcart/ipn.php", );

NogDog
03-18-2008, 02:55 AM
If you use this forum's PHP bbcode tags (http://www.webdeveloper.com/forum/misc.php?do=bbcode) around your code sample, it will save everyone a lot of grief.

Anyway, you're missing the closing curly braces for the class method (function) as well as the class itself. Also, you have a comma at the end of the last element in the $vars array declaration, which is a no-no.

<?php
if (!defined('INCLUDED_AMEMBER_CONFIG'))
die("Direct access to this location is not allowed");

/**
*
* Author: Alex Scott
* Email: alex@cgi-central.net
* Web: http://www.cgi-central.net
* Details: 1ShoppingCart Payment Plugin
* FileName $RCSfile: paypal_r.inc.php,v $
* Release: 3.0.9PRO ($Revision: 1.8 $)
*
* Please direct bug reports,suggestions or feedback to the cgi-central forums.
* http://www.cgi-central.net/forum/
*
* aMember PRO is a commercial software. Any distribution is strictly prohibited.
*/
class payment_1shoppingcart extends amember_payment {
var $title = "1ShoppingCart";
var $description = "All major credit cards accepted";
var $fixed_price=1;
var $recurring=1;
var $built_in_trials=1;
function do_bill($amount, $title, $products, $u, $invoice){
global $config;
$_SESSION['_amember_payment_id'] = $invoice;
$vars = array(
'MerchantID' => $this->config['merchant_id'],
'ProductID' => $products[0]['1shoppingcart_id'],
'AMemberID' => $invoice,
'PostBackURL' => $config['root_url'] . "/plugins/payment/1shoppingcart/ipn.php"
);
}
}

RyanL
03-18-2008, 08:36 AM
Thanks for your help and being understanding - this is really new to me! I'm sure this was completely my fault since I didn't copy and paste the entire code over, but now I am getting:

Fatal error: No parent class available in /home/snh/public_html/AHYRadio/amember/plugins/payment/1shoppingcart/1shoppingcart.inc.php on line 133

Here is the code - again, any help is greately appreciated!

By the way - I tried to format it better this time - I hit enter every time there was a break, so hopefully this is set up right- thanks again.


<?php
if (!defined('INCLUDED_AMEMBER_CONFIG'))
die("Direct access to this location is not allowed");

/**
*
* Author: Alex Scott
* Email: alex@cgi-central.net
* Web: http://www.cgi-central.net
* Details: 1ShoppingCart Payment Plugin
* FileName $RCSfile: paypal_r.inc.php,v $
* Release: 3.0.9PRO ($Revision: 1.8 $)
*
* Please direct bug reports,suggestions or feedback to the cgi-central forums.
* http://www.cgi-central.net/forum/
*
* aMember PRO is a commercial software. Any distribution is strictly prohibited.
*/
class payment_1shoppingcart extends amember_payment {
var $title = "1ShoppingCart";
var $description = "All major credit cards accepted";
var $fixed_price=1;
var $recurring=1;
var $built_in_trials=1;
function do_bill($amount, $title, $products, $u, $invoice){
global $config;
$_SESSION['_amember_payment_id'] = $invoice;
$vars = array(
'MerchantID' => $this->config['merchant_id'],
'ProductID' => $products[0]['1shoppingcart_id'],
'AMemberID' => $invoice,
'PostBackURL' => $config['root_url'] . "/plugins/payment/1shoppingcart/ipn.php"
);
}
}
return $this->encode_and_redirect("http://www.marketerschoice.com/app/netcart.asp", $vars);

function validate_ipn($vars){
//print_rr($vars, "POST we received from you");
$sign = $vars['VerifySign'];
unset($vars['VerifySign']);
$vars['PostbackPassword'] = $this->config['postback_password'];
$str = join('', array_values($vars));
$md5 = md5($str);
if ($md5 != $sign){
global $db;
$db->log_error( "DEBUG: Validation error: verifysign incorrect. Make sure you set the same password in both 1ShoppingCart and aMember Pro CP<br>
[md5($str)] != [$sign] <Br>
");
return "Validation error: verifysign incorrect. Make sure you set the same password in both 1ShoppingCart and aMember Pro CP";
}
//print_rr($vars, "vars to contactenate");
//print_rr($str, "str");
//print_rr($md5, "md5(str) (should be the same as sign)");
//print_rr($sign, "sign (we received from you), it is anything but MD5 hash of str");
//exit(); } function process_postback($vars){
global $db, $config;
// validate if it is true PayPal IPN
if (($err = $this->validate_ipn($vars)) != '')
$this->postback_error($err);
$invoice = intval($vars['AMemberID']);
$next_rebill = date('Y-m-d', strtotime($vars['NextRebillDate']));
switch ($vars['Status']){
case 'start_recurring':
case 'payment':
$err = $db->finish_waiting_payment(
$invoice, $this->get_plugin_name(),
$vars['OrderID'], '', $vars);
if ($err)
$this->postback_error("finish_waiting_payment error: $err");
if ($vars['Status'] != 'start_recurring') break;
$p = $db->get_payment($invoice);
$p['expire_date'] = $next_rebill;
$db->update_payment($p['payment_id'], $p);
break;
case 'rebill':
$p = $db->get_payment($invoice);
if (!$p['payment_id'])
$this->postback_error("Cannot find original payment for [$invoice]");
$begin_date = $this->get_next_begin_date($invoice);
$newp = array();
$newp['member_id'] = $p['member_id'];
$newp['product_id'] = $p['product_id'];
$newp['paysys_id'] = $this->get_plugin_name();
$newp['receipt_id'] = $vars['OrderID'];
$newp['begin_date'] = $begin_date;
$newp['expire_date'] = $next_rebill;
$newp['amount']
= $vars['Amount'];
$newp['completed']
= $p['completed'];
$newp['data']
= array('RENEWAL_ORIG' => "RENEWAL ORIG: $invoice");
$newp['data'][] = $vars;
$db->add_payment($newp);
break;
case 'recurring_eot':
$yesterday = date('Y-m-d', time()-3600*24);
$orig_p = $db->get_payment($invoice);
if (!$orig_p['payment_id'])
$this->postback_error("Cannot find original payment for [$invoice]");
foreach ($db->get_user_payments($orig_p['member_id'], 1) as $p){
if (($p['product_id'] == $orig_p['product_id'])
&& (($p['data']['RENEWAL_ORIG'] == "RENEWAL ORIG: $invoice")
|| ($p['payment_id'] == $invoice))
&& ($p['expire_date'] >= $yesterday)){
$p['expire_date'] = $yesterday;
$p['data'][] = $vars;
$db->update_payment($p['payment_id'], $p);
}
}
break;
default: $this->postback_error("Unknown status: [$vars[Status]]");
}
}
function get_next_begin_date($invoice){
global $db; $orig_p = $db->get_payment($invoice);
$ret = $orig_p['expire_date'];
foreach ($db->get_user_payments($orig_p['member_id'], 1) as $p){
if (($p['product_id'] == $orig_p['product_id'])
&& ($p['data']['RENEWAL_ORIG'] == "RENEWAL ORIG: $invoice")
&& ($p['expire_date'] > $ret))
$ret = $p['expire_date'];
}
return $ret;
}
/*
function get_cancel_link($payment_id){
return "http://www.1shoppingcart.com/cancel_payment.php";
}
*/
function init(){
parent::init();
add_product_field('1shoppingcart_id',
'1ShoppingCart Product ID#',
'text',
"please take product ID# from 1ShoppingCart control panel<br>
and enter here. To avoid confusion, product must have the same<br>
price and duration settings"
);
}}$pl = & instantiate_plugin('payment', '1shoppingcart');?>

NogDog
03-18-2008, 04:48 PM
This line...

class payment_1shoppingcart extends amember_payment {
...can only work if the class amember_payment has already been defined. You may need to require_once() (http://www.php.net/require_once) the file that defines that class at the start of this script before you attempt to define this payment_1shoppingcart class.