示例#1
0
    $stripe = array("secret_key" => $secret_key, "publishable_key" => $publishable_key);
    Stripe::setApiKey($stripe['secret_key']);
} else {
    $error = Yii::t("default", "Stripe payment is not properly configured on admin portal.");
}
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">
示例#2
0
 public function updateFaxTransaction()
 {
     $f = new FunctionsK();
     if (empty($this->data['id'])) {
         if ($res = $f->getFaxPackagesById($this->data['fax_package_id'])) {
             if ($res['promo_price'] >= 1) {
                 $package_price = $res['promo_price'];
             } else {
                 $package_price = $res['price'];
             }
         }
         $params = array('merchant_id' => $this->data['merchant_id'], 'fax_package_id' => $this->data['fax_package_id'], 'package_price' => $package_price, 'fax_limit' => $this->data['fax_limit'], 'status' => $this->data['status'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_type' => "manual");
         if ($this->insertData("{{fax_package_trans}}", $params)) {
             $this->details = Yii::app()->db->getLastInsertID();
             $this->code = 1;
             $this->msg = t("Successful");
         } else {
             $this->msg = t("ERROR. cannot insert data.");
         }
     } else {
         $params = array('fax_limit' => $this->data['fax_limit'], 'status' => $this->data['status'], 'ip_address' => $_SERVER['REMOTE_ADDR']);
         if ($this->updateData("{{fax_package_trans}}", $params, 'id', $this->data['id'])) {
             $this->code = 1;
             $this->msg = Yii::t("default", "Successful");
         } else {
             $this->msg = Yii::t("default", "ERROR: cannot update");
         }
     }
 }