コード例 #1
0
     } else {
         $privkey = FALSE;
     }
 }
 if (!$privkey) {
     echo $this->Lang('err_parameter');
     return;
 }
 if (!empty($params['stg_currency'])) {
     $row['currency'] = $params['stg_currency'];
 }
 if (!empty($params['stg_surrate'])) {
     $row['surchargerate'] = $params['stg_surrate'];
 }
 $symbol = StripeGate\Utils::GetSymbol($row['currency']);
 $amount = StripeGate\Utils::GetPrivateAmount($params['stg_amount'], $row['amountformat'], $symbol);
 if ($row['surchargerate'] > 0.0 && empty($params['sgt_nosur'])) {
     $amount = ceil($amount * (1.0 + $row['surchargerate']));
 }
 $card = array('number' => $params['stg_number'], 'exp_month' => $params['stg_month'], 'exp_year' => $params['stg_year'], 'cvc' => $params['stg_cvc']);
 $exdata = array('paywhat' => $params['stg_paywhat'], 'payfor' => $params['stg_payfor']);
 $data = array('amount' => $amount, 'currency' => $row['currency'], 'source' => $card, 'metadata' => $exdata);
 try {
     Stripe\Stripe::setApiKey($privkey);
     $charge = Stripe\Charge::create($data);
     //synchronous
     $params = array_merge($params, $charge->__toArray(TRUE));
     $caller = NULL;
     $funcs = new StripeGate\Payer($caller, $this);
     $funcs->HandleResult($params);
     //redirects
コード例 #2
0
 document.getElementById('stripestyles').setAttribute('href',"{$u}");
//]]>
</script>

EOS;
    $tplvars['cssscript'] = $t;
}
//button label
$symbol = StripeGate\Utils::GetSymbol($row['currency']);
if (strpos($params['amount'], $symbol) !== FALSE) {
    $t = $symbol;
} else {
    $t = '';
}
//cope with optional currency symbol in amount
$amount = StripeGate\Utils::GetPrivateAmount($params['amount'], $row['amountformat'], $t);
$public = StripeGate\Utils::GetPublicAmount($amount, $row['amountformat'], $symbol);
$tplvars['submit'] = $this->Lang('pay', $public);
/*
NB CMSMS top interpreter (index.php) includes undocumented response to a parameter 'showtemplate' == 'false' (NO prefix, NOT any other flavour of FALSE)
instead of that, the backend ajax processor clears all output buffers before reporting
NB maybe faster to provide a returnid to index.php, instead of forcing it to interpret the default
*/
//ajax-parameters : mimic API link-creators
$myname = $this->GetName();
$ajaxfirst = "mact={$myname},cntnt01,payprocess,0&cntnt01stg_account={$row['account_id']}&cntnt01stg_amount={$amount}&cntnt01stg_token=";
$defaulterr = $this->Lang('err_pay');
$jsincs[] = <<<EOS
<script src="https://checkout.stripe.com/checkout.js"></script>
EOS;
$jsloads[] = <<<EOS