当前位置: 首页>>代码示例>>PHP>>正文


PHP Payment::process方法代码示例

本文整理汇总了PHP中Payment::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::process方法的具体用法?PHP Payment::process怎么用?PHP Payment::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Payment的用法示例。


在下文中一共展示了Payment::process方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pay

 public function pay($method)
 {
     $payment = new Payment($method);
     if ($method == 'Paypal') {
         Session::instance()->delete('paypal_token');
         $order = new Order_Model($this->order->id);
         //$inv = uniqid('payPal_');
         $inv = $this->getTransID();
         $order->trans_id = $inv;
         $order->save();
         $attributes = array('AMT' => $this->total(), 'INVNUM' => $inv, 'SHIPTONAME' => $this->order->shipping->first_name . ' ' . $this->order->shipping->last_name, 'SHIPTOSTREET' => $this->order->shipping->address1, 'SHIPTOCITY' => $this->order->shipping->city, 'SHIPTOCOUNTRYCODE' => $this->order->shipping->country, 'SHIPTOSTATE' => $this->order->shipping->state, 'SHIPTOZIP' => $this->order->shipping->zip);
         //$this->payment->GETDETAILS = FALSE;
     } else {
         if (!valid::credit_card($this->order->payment->card->card_num)) {
             throw new Exception('Invalid credit card data');
         }
         $attributes = array('card_num' => $this->order->payment->card->card_num, 'exp_date' => $this->order->payment->card->exp_date, 'amount' => $this->total(), 'ship_to_first_name' => $this->order->shipping->first_name, 'ship_to_last_name' => $this->order->shipping->last_name, 'ship_to_address' => $this->order->shipping->address1, 'ship_to_city' => $this->order->shipping->city, 'ship_to_state' => $this->order->shipping->state, 'ship_to_zip' => $this->order->shipping->zip, 'ship_to_country' => $this->order->shipping->country, 'first_name' => $this->order->billing->first_name, 'last_name' => $this->order->billing->last_name, 'address' => $this->order->billing->address1, 'city' => $this->order->billing->city, 'state' => $this->order->billing->state, 'zip' => $this->order->billing->zip, 'country' => $this->order->billing->country);
     }
     $payment->set_fields($attributes);
     $this->order->finance_state = 'CHARGING';
     if ($payment->process()) {
         $this->order->finance_state = 'CHARGED';
         $this->order->status = 2;
         //$this->order->save();
         return true;
     } else {
         $this->order->finance_state = 'DENIED';
         $this->order->status = 3;
         //$this->order->save();
         throw new Exception('Payment operation failed (' . $payment->getLastError() . ')');
     }
 }
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:32,代码来源:Order.php

示例2: order_status

    public function order_status()
    {
        //-----------------------------------------------\\
        // This is the LAST checkout page where the      \\
        // payment is placed using Authorize.net and     \\
        // then lets the user know the payment status    \\
        //-----------------------------------------------\\
        $db = new Database();
        $this->template->content = new View('order_status');
        // Load Captcha library, you can supply the name of the config group you would like to use.
        //$captcha = new Captcha;
        // Ban bots (that accept session cookies) after 50 invalid responses.
        // Be careful not to ban real people though! Set the threshold high enough.
        //if ($captcha->invalid_count() > 49)
        //	exit('Bye! Stupid bot.');
        $this->template->metaDescription = $this->description;
        $this->template->metaKeywords = $this->keywords;
        $this->template->metaTitle = $this->title;
        // You can assign anything variable to a view by using standard OOP
        // methods. In my welcome view, the $title variable will be assigned
        // the value I give it here.
        $this->template->title = $this->title;
        // Captcha::valid() is a static method that can be used as a Validation rule also.
        //if (Captcha::valid($this->input->post('captcha_response'))) {
        //	echo '<p style="color:green">Good answer!</p>';
        //} else {
        //	$this->template->content->status = 3;
        //	$this->template->content->trans_status = "Your Captcha response was incorrect";
        //	exit();
        //}
        $order = ORM::factory('order')->where('id', $_POST['orderid'])->where('user_id', User_Model::logged_user()->id)->find();
        $order->shipping_total = $_POST["shippingtotal"];
        $order->save();
        $order->refreshTotals();
        $ccnum = isset($_POST["cnumber"]) ? $_POST["cnumber"] : '';
        $nameoncard = isset($_POST["cname"]) ? $_POST["cname"] : '';
        $cardexp = isset($_POST["expiration"]) ? $_POST["expiration"] : '';
        $cardcode = isset($_POST["verification"]) ? $_POST["verification"] : '';
        $this->template->content->order = $order;
        $billing_info = $order->user->user_billing_info;
        $shipping_info = $order->user->user_shipping_info;
        $cardfname = $billing_info->firstname;
        $cardlname = $billing_info->lastname;
        $this->template->content->shippingName = $shipping_info->firstname . ' ' . $shipping_info->lastname;
        $this->template->content->shippingAddress = trim($shipping_info->address1 . ' ' . $shipping_info->address2);
        $this->template->content->shippingCity = $shipping_info->city . ', ' . $shipping_info->state . ', ' . $shipping_info->country . ' ' . $shipping_info->zip;
        $this->template->content->billingName = $cardfname . ' ' . $cardlname;
        $this->template->content->billingAddress = trim($billing_info->address1 . ' ' . $billing_info->address2);
        $this->template->content->billingCity = $billing_info->city . ', ' . $billing_info->state . ', ' . $billing_info->country . ' ' . $billing_info->zip;
        $shippingInfo = $shipping_info->firstname . ' ' . $shipping_info->lastname . '<br/>';
        $shippingInfo .= trim($shipping_info->address1 . ' ' . $shipping_info->address2) . '<br />';
        $shippingInfo .= $shipping_info->city . ', ' . $shipping_info->state . ' ' . $shipping_info->zip . '<br />';
        $shippingInfo .= $shipping_info->country;
        $billingInfo = $cardfname . ' ' . $cardlname . '<br/>';
        $billingInfo .= trim($billing_info->address1 . ' ' . $billing_info->address2) . '<br />';
        $billingInfo .= $billing_info->city . ', ' . $billing_info->state . ' ' . $billing_info->zip . '<br />';
        $billingInfo .= $billing_info->country;
        $dateTime = date('Y-m-d H:i:s');
        $additionalFees = 0;
        $description = '';
        foreach ($order->orders_baskets as $ob) {
            $additionalFees += $ob->second_side_fee;
            $product_name = $ob->product->name;
            if ($ob->packaging_id != 0) {
                $product_name .= ' - ' . $ob->packaging->name;
            }
            $description .= $ob->qty . ' x ' . $product_name . ' = ' . money_format('%.2n', $ob->subtotal) . '<br/>';
        }
        if ($additionalFees != 0) {
            $description .= 'Additional Fees: ' . money_format('%.2n', $additionalFees) . '<br/>';
        }
        if (!empty($order->comment)) {
            $description .= 'Comment:' . $order->comment . '<br/>';
        }
        $total_text = 'Subtotal: ' . money_format('%.2n', $order->subtotal) . '<br/>';
        $total_text .= 'Shipping:' . money_format('%.2n', $order->shipping_total) . '<br/>';
        $total_text .= 'Total: ' . money_format('%.2n', $order->order_total);
        switch ($_POST['payment_method']) {
            case 'credit_card':
                $payment = new Payment('Authorize');
                $attributes = array('card_num' => $ccnum, 'exp_date' => $cardexp, 'card_code' => $cardcode, 'amount' => number_format($order->order_total, 2, '.', ''), 'ship_to_first_name' => $shipping_info->firstname, 'ship_to_last_name' => $shipping_info->lastname, 'ship_to_address' => trim($shipping_info->address1 . ' ' . $shipping_info->address2), 'ship_to_city' => $shipping_info->city, 'ship_to_state' => $shipping_info->state, 'ship_to_zip' => $shipping_info->zip, 'first_name' => $cardfname, 'last_name' => $cardlname, 'address' => trim($billing_info->address1 . ' ' . $billing_info->address2), 'city' => $billing_info->city, 'state' => $billing_info->state, 'zip' => $billing_info->zip, 'phone' => $billing_info->phone1, 'x_test_request' => 'FALSE');
                $payment->set_fields($attributes);
                if ($payment->process()) {
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    // if the payment was SUCCESSFUL
                    $this->template->content->trans_status = $payment->get_response();
                    $this->template->content->status = 1;
                    $transaction_id = $payment->get_transaction_id();
                    $paymentstatus = 3;
                    $orderstatus = 2;
                } else {
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    // if the payment FAILED
                    $this->template->content->status = 3;
                    $this->template->content->trans_status = $payment->get_response();
                    $orderstatus = 3;
                    $paymentstatus = 1;
                }
                break;
                //			case 'paypal':
//.........这里部分代码省略.........
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:101,代码来源:shopping_cart.php

示例3: action_process

 /**
  * Processes the shopping cart with the payment processor, saves the user's
  * cart, clears it and redirects to a success method.
  *
  * @return null
  */
 public function action_process()
 {
     $order = Auth::instance()->get_user()->cart();
     $user_post = arr::get($_POST, 'user', array());
     $user = arr::get($_POST, 'user', Auth::instance()->get_user());
     if (!is_object($user)) {
         $temp = $user;
         $user = AutoModeler_ORM::factory('user');
         $user->set_fields($temp);
     }
     $address = AutoModeler_ORM::factory('vendo_address');
     $address->set_fields(arr::get($_POST, 'address', array()));
     // Build the contact model
     $contact = new Model_Contact();
     $contact->set_fields(array('email' => $user->email, 'first_name' => $user->first_name, 'last_name' => $user->last_name));
     // Build the credit card model
     $credit_card_post = arr::get($_POST, 'payment');
     $credit_card = new Model_Credit_Card(arr::get($credit_card_post, 'card_number'), arr::get($credit_card_post, 'months') . arr::get($credit_card_post, 'years'), arr::get($credit_card_post, 'card_code'), $contact, $address);
     $errors = array();
     // Check for a new user registration, and make a user if so
     if ($this->should_create_account($user)) {
         $status = $this->process_new_account($user, $user_post, $address);
         if (!$status) {
             return;
         }
         $contact->save();
         $order->user_id = $user->id;
     } else {
         $user_address = $user->address->as_array();
         unset($user_address['id']);
         if ($user_address != $address and TRUE === $address->is_valid()) {
             $address->save();
             $user->address_id = $address->id;
         } elseif (TRUE !== $address->is_valid()) {
             $errors += $address->errors('form_errors');
         } else {
             $address = $user->address;
         }
         $contact->address_id = $address->id;
         if (TRUE !== $contact->is_valid()) {
             $errors += $contact->errors('form_errors');
         }
         if (Auth::instance()->logged_in()) {
             $order->user_id = $user->id;
         }
     }
     // Verify the credit card is valid
     if (TRUE !== ($cc_errors = $credit_card->validate())) {
         $errors += $cc_errors;
     }
     if ($errors) {
         // If we've failed, and we aren't registering a new user, delete
         // the address
         if (!$user->id) {
             $address->delete();
         }
         $this->request->response = new View_Checkout_Index();
         $this->request->response->set(array('user' => $user->as_array(), 'address' => $address->as_array(), 'cart' => Auth::instance()->get_user()->cart(), 'credit_card' => $credit_card));
         $errors = (string) View::factory('form_errors')->set(array('errors' => $errors));
         $this->request->response->errors = $errors;
         return;
     }
     $order->credit_card = $credit_card;
     // Process the credit card
     try {
         $status = Payment::process($order);
         if (1 != $status->response_code) {
             throw new Payment_Exception('Problem processing your payment.');
         }
         // Persist the order
         $contact->save();
         $order->contact_id = $contact->id;
         $order->address_id = $address->id;
         $order->save();
         Auth::instance()->get_user()->cart(new Model_Order());
         // Show success message!
         $this->request->response = new View_Checkout_Process();
     } catch (Payment_Exception $e) {
         // If we've failed, and we aren't registering a new user, delete
         // the address
         if (!$user->id) {
             $address->delete();
         }
         $this->request->response = new View_Checkout_Index();
         $this->request->response->set(array('user' => $user->as_array(), 'address' => $address->as_array(), 'cart' => Auth::instance()->get_user()->cart(), 'credit_card' => $credit_card));
         $errors = (string) View::factory('form_errors')->set(array('errors' => array('general' => $e->getMessage())));
         $this->request->response->errors = $errors;
         return;
     }
 }
开发者ID:vendo,项目名称:application,代码行数:96,代码来源:checkout.php

示例4: process

 public function process($values)
 {
     $order = parent::process($values);
 }
开发者ID:anas,项目名称:feedstore,代码行数:4,代码来源:Cheque.php


注:本文中的Payment::process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。