Exemple #1
0
}
if (isset($_POST)) {
    if (is_array($_POST) && count($_POST) >= 1) {
        $step2 = true;
        $token = isset($_POST['stripeToken']) ? $_POST['stripeToken'] : '';
        try {
            $customer = Stripe_Customer::create(array('email' => isset($_POST['stripeEmail']) ? $_POST['stripeEmail'] : '', 'card' => $token));
            $charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $amount_to_pay, 'currency' => Yii::app()->functions->adminCurrencyCode()));
            $chargeArray = $charge->__toArray(true);
            $db_ext = new DbExt();
            $FunctionsK = new FunctionsK();
            $info = $FunctionsK->getFaxPackagesById($package_id);
            $params = array('merchant_id' => Yii::app()->functions->getMerchantID(), 'fax_package_id' => $package_id, 'payment_type' => $payment_code, 'package_price' => $price, 'fax_limit' => $info['fax_limit'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_gateway_response' => json_encode($chargeArray), 'status' => "paid");
            if ($db_ext->insertData("{{fax_package_trans}}", $params)) {
                $merchantinfo = Yii::app()->functions->getMerchantInfo();
                $FunctionsK->faxSendNotification((array) $merchantinfo[0], $package_id, "Stripe", $price);
                header('Location: ' . Yii::app()->request->baseUrl . "/merchant/{$redirect}/id/" . Yii::app()->db->getLastInsertID());
            } else {
                $error = Yii::t("default", "ERROR: Cannot insert record.");
            }
        } catch (Exception $e) {
            $error = $e;
        }
    }
}
?>
<div class="page-right-sidebar payment-option-page">
  <div class="main">  
  <?php 
if (!empty($error)) {
    ?>
Exemple #2
0
 public function paymentPaypalVerification()
 {
     $raw = base64_decode(isset($this->data['raw']) ? $this->data['raw'] : '');
     parse_str($raw, $raw_decode);
     $price = '';
     $description = '';
     if (is_array($raw_decode) && count($raw_decode) >= 1) {
         $price = isset($raw_decode['price']) ? $raw_decode['price'] : '';
         $description = isset($raw_decode['description']) ? $raw_decode['description'] : '';
     }
     $paypal_con = Yii::app()->functions->getPaypalConnectionAdmin();
     $paypal = new Paypal($paypal_con);
     if ($res_paypal = $paypal->getExpressDetail()) {
         $paypal->params['PAYERID'] = $res_paypal['PAYERID'];
         $paypal->params['AMT'] = $res_paypal['AMT'];
         $paypal->params['TOKEN'] = $res_paypal['TOKEN'];
         $paypal->params['CURRENCYCODE'] = $res_paypal['CURRENCYCODE'];
         if ($res = $paypal->expressCheckout()) {
             /*now insert transaction logs*/
             if ($this->data['purchase'] == "fax_package") {
                 $payment_code = Yii::app()->functions->paymentCode("paypal");
                 $FunctionsK = new FunctionsK();
                 $info = $FunctionsK->getFaxPackagesById($this->data['package_id']);
                 $params = array('merchant_id' => Yii::app()->functions->getMerchantID(), 'fax_package_id' => $this->data['package_id'], 'payment_type' => $payment_code, 'package_price' => $price, 'fax_limit' => $info['fax_limit'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_gateway_response' => json_encode($res), 'status' => "paid");
                 if ($this->insertData("{{fax_package_trans}}", $params)) {
                     $this->details = websiteUrl() . "/merchant/faxreceipt/id/" . Yii::app()->db->getLastInsertID();
                     $this->code = 1;
                     $this->msg = Yii::t("default", "Successful");
                     $merchantinfo = Yii::app()->functions->getMerchantInfo();
                     $FunctionsK = new FunctionsK();
                     $FunctionsK->faxSendNotification((array) $merchantinfo[0], $this->data['package_id'], $payment_code, $price);
                 } else {
                     $this->msg = Yii::t("default", "ERROR: Cannot insert record.");
                 }
             } else {
                 $this->msg = t("Uknown transaction");
             }
         } else {
             $this->msg = $paypal->getError();
         }
     } else {
         $this->msg = $paypal->getError();
     }
 }