PageCompCheckoutInfo_db_num ); $_page_cont[$_ni]['provider_list'] = DesignBoxContent( _t('_Payment methods'), PageCompProviderList(), $oTemplConfig -> PageCompProviderList_db_num ); } break; case 'collect': $res = CollectCheckoutInfo( $_REQUEST ); if ( !$res ) { PageCompErrorMessage( _t('_no data given') ); } else { $_page_cont[$_ni]['checkout_info'] = DesignBoxContent( _t('_Payment info'), PageCompCheckoutInfo(), $oTemplConfig -> PageCompCheckoutInfo_db_num ); $_page_cont[$_ni]['provider_list'] = DesignBoxContent( _t('_Payment methods'), PageCompProviderList(), $oTemplConfig -> PageCompProviderList_db_num ); } break; case 'start_checkout': $res = CollectCheckoutInfo( $_REQUEST ); if ( !$res ) { PageCompErrorMessage( _t('_no data given') ); } else { $res = StartCheckout( $errorMessage ); if ( !$res ) { PageCompErrorMessage( $errorMessage ); } } break; default: PageCompErrorMessage( _t('_no data given') ); break; } // --------------- [END] page components PageCode(); // --------------- page components functions /** * calculate checkout info */ function CalculateCheckoutInfo( $source ) { if ( !isset($source['checkout_action']) || strlen($source['data']) == 0 ) return false; $res = array(); $res['checkout_action'] = $source['checkout_action']; $res['data'] = $source['data']; if ( isset($source['allow_subscribe']) ) { $res['allow_subscribe'] = $source['allow_subscribe']; } if ( isset($source['subscribe_days']) ) { $res['subscribe_days'] = $source['subscribe_days']; } switch ( $source['checkout_action'] ) { case 'membership': $res['amount'] = $source['amount']; $prices = getMembershipPrices( $res['data'] ); $pricingOptionExists = false; foreach ($prices as $days => $price) { if ( $res['amount'] == $price ) { if ( $days == 0 ) { $res['allow_subscribe'] = ''; $res['subscribe_days'] = 0; } else { $res['allow_subscribe'] = 'on'; $res['subscribe_days'] = $days; } $pricingOptionExists = true; break; } } if ( !$pricingOptionExists ) return false; else return $res; case 'speeddating': return $res; case 'profiles': return $res; default: return false; } } /** * collect data from source */ function CollectCheckoutInfo( $source ) { global $collectDataArr; global $collectDataInputs; if ( !isset($source['checkout_action']) || strlen($source['data']) == 0 ) return false; $collectDataArr['checkout_action'] = process_pass_data( $source['checkout_action'] ); $collectDataArr['amount'] = process_pass_data( $source['amount'] ); $collectDataArr['data'] = process_pass_data( $source['data'] ); if ( isset($source['allow_subscribe']) ) { $collectDataArr['allow_subscribe'] = process_pass_data( $source['allow_subscribe'] ); } if ( isset($source['subscribe_days']) ) { $collectDataArr['subscribe_days'] = process_pass_data( $source['subscribe_days'] ); } $collectDataArr['description'] = returnDescByAction( $collectDataArr['checkout_action'], $collectDataArr['data'], true ); if ( strlen($collectDataArr['description']) == 0 ) return false; $collectDataInputs = ''; $collectDataInputs .= "\n"; $collectDataInputs .= "\n"; $collectDataInputs .= "\n"; if ( isset($source['allow_subscribe']) ) { $collectDataInputs .= "\n"; } if ( isset($source['subscribe_days']) ) { $collectDataInputs .= "\n"; } return true; } /** * start checkout process */ function StartCheckout( &$errorMessage ) { global $dir; global $memberID; // defined in checkout.inc.php global $collectDataArr; global $enable_recurring; // these globals for module require call global $site; global $providerConf; global $checkoutFilename; global $checkoutURL; global $debugFilename; $providerID = (int)$_REQUEST['prov_id']; $providerRes = db_res( "SELECT `Name`, `CheckoutFilename` FROM `PaymentProviders` WHERE `ID` = {$providerID} AND `Active`" ); if ( !$providerRes || mysql_num_rows($providerRes) == 0 ) { $errorMessage = 'Wrong payment provider specified'; return false; } $providerArr = mysql_fetch_assoc( $providerRes ); if ( strlen(trim($providerArr['CheckoutFilename'])) ) $checkoutFilename = $providerArr['CheckoutFilename']; else $checkoutFilename = $dir['checkout'] . $providerArr['Name'] . '.php'; if ( !file_exists( $checkoutFilename ) ) { $errorMessage = 'Checkout file not found'; return false; } require_once( $checkoutFilename ); $validateRes = moduleValidateConfiguration( $errorMessage ); if ( !$validateRes ) { return false; } $localTranID = initiateTransaction( $collectDataArr, $memberID, $providerID ); if ( $localTranID === false ) { $errorMessage = 'Transaction initiating error'; return false; } $subscriptionalPayment = $enable_recurring && $collectDataArr['allow_subscribe'] == 'on' && $_REQUEST['prov_recurring'] == 'on'; if ( $subscriptionalPayment ) { $subsRes = initiateSubscription( $localTranID, $collectDataArr['subscribe_days'] ); if ( !$subsRes ) { $errorMessage = 'Subscription initiating error'; return false; } } $startRes = moduleStartTransaction( $localTranID, $subscriptionalPayment, $collectDataArr['subscribe_days'] ); if ( !$startRes ) { $errorMessage = 'Transaction starting error'; return false; } return true; } /** * prints errom message in checkout info box end empty provider list box */ function PageCompErrorMessage( $message ) { global $_page_cont; global $_ni; global $oTemplConfig; $designBox = DesignBoxContentBorder( _t('_Error'), '
'. $message .'
' ); $content = "
\n{$designBox}\n
\n"; $_page_cont[$_ni]['checkout_info'] = DesignBoxContent( _t('_Payment info'), $content, $oTemplConfig -> PageCompErrorMessage_db_num ); $_page_cont[$_ni]['provider_list'] = ''; } /** * common checkout info */ function PageCompCheckoutInfo() { global $collectDataArr; global $doll; ob_start(); ?> 0 ) { ?>
:
:
:
\n{$designBox}\n\n"; return $content; } /** * list of all active payment providers */ function PageCompProviderList() { global $dir; global $site; global $enable_recurring; global $memberID; // defined in checkout.inc.php global $collectDataArr; global $collectDataInputs; $ret = ''; $res = db_res( "SELECT `ID`, `Name`, `Caption`, `SupportsRecurring`, `LogoFilename` FROM `PaymentProviders` WHERE `Active`" ); while ( $arr = mysql_fetch_assoc($res) ) { if ( $enable_recurring && $collectDataArr['allow_subscribe'] == 'on' ) { if ( $arr['SupportsRecurring'] ) { $recurringField = " "; if ( (int)$collectDataArr['subscribe_days'] == 0 ) { $daysVariants = array( 10, 20, 30, 60, 180 ); $recurringField .= " \n"; } } else { $recurringField = _t('_recurring not supported'); } } else { $recurringField = _t('_recurring not allowed'); } ob_start(); ?>
0 && file_exists($dir['checkout'] . 'images/' . $arr['LogoFilename']) ? "\""." : ' ' ?>
\n{$designBox}\n\n"; } return $ret; } ?>