Beispiel #1
0
function metacharge_error($msg)
{
    global $order_id, $payment_id, $pnref, $db;
    global $vars;
    $db->log_error(sprintf(_PLUG_PAY_METACHARGE_FERROR, $msg, $pnref, $payment_id, '<br />') . "\n" . metacharge_get_dump($vars));
    die($msg);
}
 function do_payment($payment_id, $member_id, $product_id, $price, $begin_date, $expire_date, &$vars)
 {
     global $config, $db;
     $orig_product_id = $product_id;
     if (is_array($product_id)) {
         $product_id = $product_id[0];
     }
     $product =& get_product($product_id);
     if (count($orig_product_id) > 1) {
         $product->config['title'] = $config['multi_title'];
     }
     $u = $db->get_user($member_id);
     $vars = array('intInstID' => $this->config['installation_id'], 'strCartID' => $payment_id, 'strCurrency' => 'USD', 'strDesc' => substr($product->config['title'], 0, 192), 'strEmail' => substr($u['email'], 0, 100), 'strCardHolder' => substr($u['name_f'] . ' ' . $u['name_l'], 0, 20));
     if ($config['use_address_info']) {
         $vars += array('strAddress' => substr($u['street'], 0, 255), 'strCity' => substr($u['city'], 0, 40), 'strState' => substr($u['state'], 0, 40), 'strCountry' => substr($u['country'], 0, 2), 'strPostcode' => substr($u['zip'], 0, 15));
     }
     if ($this->config['testing']) {
         $vars['intTestMode'] = 1;
         // If included, indicates a test purchase.
         // A VISA card with card number 1234123412341234 should be used on the payment page.
         // Values: 0=equivalent to field omitted (payment is live), 1=all payments are successful, 2=all payments fail.
         // Banks are not involved in test payments.
     }
     if ($product->config['metacharge_currency']) {
         $vars['strCurrency'] = $product->config['metacharge_currency'];
     }
     if ($product->config['is_recurring']) {
         $p = $db->get_payment($payment_id);
         $vars['intRecurs'] = '1';
         // For scheduled payments, indicates if scheduled payments should recur. Values: 0=no, 1=yes.
         if ($product->config['rebill_times']) {
             $vars['intCancelAfter'] = intval($product->config['rebill_times']);
         }
         // Cancel a subscription after this many successful payments.
         $has_trials = false;
         if ($product->config['trial1_days'] && $product->config['trial1_price']) {
             $has_trials = true;
             $vars['fltSchAmount1'] = metacharge_get_price($product->config['trial1_price']);
             $vars['strSchPeriod1'] = metacharge_get_period($product->config['trial1_days'], 'trial1_days');
             $p['expire_date'] = $product->get_expire($begin_date, 'trial1_days');
             $p['amount'] = $product->config['trial1_price'];
             $db->update_payment($payment_id, $p);
         }
         if ($has_trials && $product->config['trial2_days'] && $product->config['trial2_price']) {
             $vars['fltSchAmount2'] = metacharge_get_price($product->config['trial2_price']);
             $vars['strSchPeriod2'] = metacharge_get_period($product->config['trial2_days'], 'trial2_days');
         }
         if ($has_trials && $product->config['trial3_days'] && $product->config['trial3_price']) {
             $vars['fltSchAmount3'] = metacharge_get_price($product->config['trial3_price']);
             $vars['strSchPeriod3'] = metacharge_get_period($product->config['trial3_days'], 'trial3_days');
         }
         //            if (!$has_trials){
         $vars['fltSchAmount'] = metacharge_get_price($price);
         $vars['strSchPeriod'] = metacharge_get_period($product->config['expire_days'], 'expire_days');
         // char(4)
         //            }
     }
     $vars['fltAmount'] = metacharge_get_price($price);
     $db->log_error("METACHARGE SENT: " . metacharge_get_dump($vars));
     $t =& new_smarty();
     $t->template_dir = dirname(__FILE__);
     $t->assign(array('vars' => $vars));
     $t->display('metacharge.html');
     exit;
 }