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


PHP WC_Order::payment_complete方法代码示例

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


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

示例1: process_payment

 public function process_payment($order_id)
 {
     global $woocommerce;
     $me = wp_get_current_user();
     $order = new WC_Order($order_id);
     if ($me->ID == 0) {
         $woocommerce->add_error(__('Payment error:', 'woothemes') . __('You must be logged in to use this payment method', 'wc_account_funds'));
         return;
     }
     $funds = get_user_meta($me->ID, 'account_funds', true);
     if (!$funds) {
         $funds = 0;
     }
     if ($funds < $order->order_total) {
         $woocommerce->add_error(__('Payment error:', 'woothemes') . __('Insufficient account balance', 'wc_account_funds'));
         return;
     }
     // Payment complete
     $order->payment_complete();
     // deduct amount from account funds
     $new_funds = $funds - $order->order_total;
     update_user_meta($me->ID, 'account_funds', $new_funds);
     // Remove cart
     $woocommerce->cart->empty_cart();
     // Return thank you page redirect
     if (method_exists($order, 'get_checkout_order_received_url')) {
         return array('result' => 'success', 'redirect' => $order->get_checkout_order_received_url());
     } else {
         return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))));
     }
 }
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:31,代码来源:Bigboss-WooCommerce-deposit-funds-getaways.php

示例2: check_ipn_response

 public function check_ipn_response()
 {
     if (sizeOf($_POST) == 0) {
         header("HTTP/1.1 500 EMPTY_POST ");
         return false;
     }
     if (!isset($_POST['transaction_id']) || !isset($_POST['reference_id'])) {
         header("HTTP/1.1 500 BAD_PARAMETERS");
         return false;
     }
     $transaction_id = filter_var($_POST['transaction_id'], FILTER_SANITIZE_STRING);
     $url = 'https://www.bitpagos.net/api/v1/transaction/' . $transaction_id . '/?api_key=' . $this->get_option('api_key') . '&format=json';
     $cbp = curl_init($url);
     curl_setopt($cbp, CURLOPT_RETURNTRANSFER, TRUE);
     $response_curl = curl_exec($cbp);
     curl_close($cbp);
     $response = json_decode($response_curl);
     $order_id = (int) $_POST['reference_id'];
     if ($order_id != $response->reference_id) {
         die('Wrong reference id');
     }
     if ($response->status == 'PA' || $response->status == 'CO') {
         global $woocommerce;
         $order = new WC_Order($order_id);
         $order->update_status('completed');
         $order->payment_complete();
         file_put_contents('/tmp/ipn.log', print_r($order, TRUE));
         header("HTTP/1.1 200 OK");
     }
 }
开发者ID:bonini81,项目名称:bitpagos-woocommerce,代码行数:30,代码来源:index.php

示例3: completeOrder

 /**
  * Complete a WooCommerce order
  */
 public function completeOrder(WC_Order $order, $payment_hash)
 {
     $status = PayPro_WC_Plugin::$settings->paymentCompleteStatus();
     if (empty($status)) {
         $status = 'wc-processing';
     }
     $order->update_status($status, sprintf(__('PayPro payment succeeded (%s)', 'paypro-gateways-woocommerce'), $payment_hash));
     $order->reduce_order_stock();
     $order->payment_complete();
     $this->removeOrderPaymentHashes($order->id);
 }
开发者ID:paypronl,项目名称:woocommerce-payments-plugin,代码行数:14,代码来源:woocommerce.php

示例4: check_ipn_response

 public function check_ipn_response()
 {
     $sha1_hash = $_POST['sha1_hash'];
     $string = array($_POST['notification_type'], $_POST['operation_id'], $_POST['amount'], $_POST['currency'], $_POST['datetime'], $_POST['sender'], $_POST['codepro'], $this->notification_secret, $_POST['label']);
     $sha1_string = sha1(implode('&', $string));
     if ($sha1_hash == $sha1_string) {
         $order = new WC_Order($_POST['label']);
         $order->payment_complete();
         exit;
     } else {
         wp_die();
     }
 }
开发者ID:maximzasorin,项目名称:woocommerce-yandex-money-gateway,代码行数:13,代码来源:woocommerce-yandex-money.php

示例5: webhook_handler

 public function webhook_handler()
 {
     header('HTTP/1.1 200 OK');
     $obj = file_get_contents('php://input');
     $json = json_decode($obj);
     if ($json->type == 'charge.succeeded') {
         $order_id = $json->transaction->order_id;
         $payment_date = date("Y-m-d", $json->event_date);
         $order = new WC_Order($order_id);
         update_post_meta($order->id, 'openpay_payment_date', $payment_date);
         $order->payment_complete();
         $order->add_order_note(sprintf("Payment completed."));
     }
 }
开发者ID:open-pay,项目名称:openpay-woocommerce,代码行数:14,代码来源:openpay_stores_gateway.php

示例6: process_payment

 public function process_payment($order_id)
 {
     // get order object
     $order = new WC_Order($order_id);
     // update pos_cash data
     $tendered = isset($_POST['pos-cash-tendered']) ? wc_format_decimal($_POST['pos-cash-tendered']) : 0;
     $change = isset($_POST['pos-cash-change']) ? wc_format_decimal($_POST['pos-cash-change']) : 0;
     update_post_meta($order_id, '_pos_cash_amount_tendered', $tendered);
     update_post_meta($order_id, '_pos_cash_change', $change);
     // payment complete
     $order->payment_complete();
     // Return thankyou redirect
     return array('result' => 'success');
 }
开发者ID:habibmasuro,项目名称:WooCommerce-POS,代码行数:14,代码来源:class-wc-pos-cash.php

示例7: webhook_handler

 /**
  * Updates the status of the order.
  * Webhook needs to be added to Conekta account tusitio.com/wc-api/WC_Conekta_Cash_Gateway
  */
 public function webhook_handler()
 {
     header('HTTP/1.1 200 OK');
     $body = @file_get_contents('php://input');
     $event = json_decode($body);
     $charge = $event->data->object;
     $order_id = $charge->reference_id;
     $paid_at = date("Y-m-d", $charge->paid_at);
     $order = new WC_Order($order_id);
     if (strpos($event->type, "charge.paid") !== false) {
         update_post_meta($order->id, 'conekta-paid-at', $paid_at);
         $order->payment_complete();
         $order->add_order_note(sprintf("Payment completed in Oxxo and notification of payment received"));
     }
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:19,代码来源:conekta_cash_gateway.php

示例8: mijireh_notification

 /**
  * mijireh_notification function.
  *
  * @access public
  * @return void
  */
 public function mijireh_notification()
 {
     global $woocommerce;
     $this->init_mijireh();
     try {
         $mj_order = new Mijireh_Order(esc_attr($_GET['order_number']));
         $wc_order_id = $mj_order->get_meta_value('wc_order_id');
         $wc_order = new WC_Order(absint($wc_order_id));
         // Mark order complete
         $wc_order->payment_complete();
         // Empty cart and clear session
         $woocommerce->cart->empty_cart();
         wp_redirect($this->get_return_url($wc_order));
         exit;
     } catch (Mijireh_Exception $e) {
         $woocommerce->add_error(__('Mijireh error:', 'woocommerce') . $e->getMessage());
     }
 }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:24,代码来源:class-wc-gateway-mijireh.php

示例9: confirm_url_callback

 public function confirm_url_callback()
 {
     $transaction_id = $_GET['transactionId'];
     $results = get_posts(array('post_type' => 'shop_order', 'meta_query' => array(array('key' => '_hpd_linepay_transactionId', 'value' => $transaction_id))));
     if (!$results) {
         http_response_code(404);
         exit;
     }
     $order_data = $results[0];
     $order_id = $order_data->ID;
     $order = new WC_Order($order_id);
     $response_data = $this->client->confirm($transaction_id, $order->get_total(), get_woocommerce_currency());
     if ($response_data->returnCode != '0000') {
         $order->update_status('failed', sprintf(__('Error return code: %1$s, message: %2$s', 'wc-payment-gateway-line-pay'), $response_data->returnCode, $response_data->returnMessage));
     } else {
         $order->payment_complete();
     }
     wp_redirect($order->get_checkout_order_received_url());
     exit;
 }
开发者ID:neltseng,项目名称:wc-payment-gateway-line-pay,代码行数:20,代码来源:class-hpd-linepay-gateway.php

示例10: process_payment

 public function process_payment($order_id)
 {
     // get order object
     $order = new WC_Order($order_id);
     $tendered = isset($_REQUEST['pos-cash-tendered']) ? wc_format_decimal($_REQUEST['pos-cash-tendered']) : 0;
     $tendered = abs((double) $tendered);
     $total = isset($_REQUEST['total']) ? $_REQUEST['total'] : 0;
     $total = abs((double) $total);
     if ($tendered !== 0) {
         // calculate change
         $change = $tendered - $total;
         // add order meta
         update_post_meta($order_id, '_pos_cash_amount_tendered', $tendered);
         update_post_meta($order_id, '_pos_cash_change', $change);
     }
     // payment complete
     $order->payment_complete();
     // Return thankyou redirect
     return array('result' => 'success');
 }
开发者ID:bostondv,项目名称:WooCommerce-POS,代码行数:20,代码来源:class-wc-pos-cash.php

示例11: SCMerchantClient

 function check_spectrocoin_callback()
 {
     global $woocommerce;
     $ipn = $_REQUEST;
     // Exit now if the $_POST was empty.
     if (empty($ipn)) {
         echo 'Invalid request!';
         return;
     }
     $scMerchantClient = new SCMerchantClient(SC_API_URL, $this->get_option('merchant_id'), $this->get_option('project_id'), $this->get_option('private_key'));
     $callback = $scMerchantClient->parseCreateOrderCallback($ipn);
     if ($callback != null && $scMerchantClient->validateCreateOrderCallback($callback)) {
         switch ($callback->getStatus()) {
             case OrderStatusEnum::$New:
             case OrderStatusEnum::$Pending:
                 break;
             case OrderStatusEnum::$Expired:
             case OrderStatusEnum::$Failed:
                 break;
             case OrderStatusEnum::$Test:
             case OrderStatusEnum::$Paid:
                 $order_number = (int) $ipn['invoice_id'];
                 $order = new WC_Order(absint($order_number));
                 $order->add_order_note(__('Callback payment completed', 'woocomerce'));
                 $order->payment_complete();
                 $order->reduce_order_stock();
                 break;
             default:
                 echo 'Unknown order status: ' . $callback->getStatus();
                 break;
         }
         $woocommerce->cart->empty_cart();
         echo '*ok*';
     } else {
         echo 'Invalid callback!';
     }
     exit;
 }
开发者ID:alcharkov,项目名称:spectrocoin-payment-gateway-for-woocommerce,代码行数:38,代码来源:index.php

示例12: coinsimple_callback

 /**
  * Notification callback.
  *
  * @param void
  * @return void
  */
 public function coinsimple_callback()
 {
     // obtain body
     @ob_clean();
     $body = file_get_contents('php://input');
     $data = json_decode($body);
     $business = new \CoinSimple\Business($this->get_option("business_id"), $this->get_option('api_key'));
     if (!$business->validateHash($data->hash, $data->timestamp)) {
         $this->debug(__METHOD__, 'invalid callback hash');
         return;
     }
     $order = new WC_Order($data->custom->order_id);
     if (!isset($order->id)) {
         // orderId invalid, try alternate find
         $orderId = wc_get_order_id_by_order_key($data->custom->order_key);
         $order = new WC_Order($orderId);
     }
     if ($order->order_key !== $data->custom->order_key) {
         $this->debug(__METHOD__, 'invalid order key');
         return;
     }
     $order->payment_complete();
 }
开发者ID:kedamaian,项目名称:coinsimple-woocommerce,代码行数:29,代码来源:wc_coinsimple.php

示例13: mijireh_notification

 /**
  * mijireh_notification function.
  *
  * @access public
  * @return void
  */
 public function mijireh_notification()
 {
     if (isset($_GET['order_number'])) {
         $this->init_mijireh();
         try {
             $mj_order = new Mijireh_Order(esc_attr($_GET['order_number']));
             $wc_order_id = $mj_order->get_meta_value('wc_order_id');
             $wc_order = new WC_Order(absint($wc_order_id));
             // Mark order complete
             $wc_order->payment_complete();
             // Empty cart and clear session
             WC()->cart->empty_cart();
             wp_redirect($this->get_return_url($wc_order));
             exit;
         } catch (Mijireh_Exception $e) {
             wc_add_notice(__('Mijireh error:', 'woocommerce') . $e->getMessage(), 'error');
         }
     } elseif (isset($_POST['page_id'])) {
         if (isset($_POST['access_key']) && $_POST['access_key'] == $this->access_key) {
             wp_update_post(array('ID' => $_POST['page_id'], 'post_status' => 'private'));
         }
     }
 }
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:29,代码来源:class-wc-gateway-mijireh.php

示例14: process_payment

 public function process_payment($order_id)
 {
     global $woocommerce;
     $customer_order = new WC_Order($order_id);
     $environment = $this->environment == "yes" ? 'TRUE' : 'FALSE';
     $environment_url = "FALSE" == $environment ? 'https://secure.authorize.net/gateway/transact.dll' : 'https://test.authorize.net/gateway/transact.dll';
     $payload = array("x_tran_key" => $this->trans_key, "x_login" => $this->api_login, "x_version" => "3.1", "x_amount" => $customer_order->order_total, "x_card_num" => str_replace(array(' ', '-'), '', $_POST['GP_authorize_gateway-card-number']), "x_card_code" => isset($_POST['GP_authorize_gateway-card-cvc']) ? $_POST['GP_authorize_gateway-card-cvc'] : '', "x_exp_date" => str_replace(array('/', ' '), '', $_POST['GP_authorize_gateway-card-expiry']), "x_type" => 'AUTH_CAPTURE', "x_invoice_num" => str_replace("#", "", $customer_order->get_order_number()), "x_test_request" => $environment, "x_delim_char" => '|', "x_encap_char" => '', "x_delim_data" => "TRUE", "x_relay_response" => "FALSE", "x_method" => "CC", "x_first_name" => $customer_order->billing_first_name, "x_last_name" => $customer_order->billing_last_name, "x_address" => $customer_order->billing_address_1, "x_city" => $customer_order->billing_city, "x_state" => $customer_order->billing_state, "x_zip" => $customer_order->billing_postcode, "x_country" => $customer_order->billing_country, "x_phone" => $customer_order->billing_phone, "x_email" => $customer_order->billing_email, "x_ship_to_first_name" => $customer_order->shipping_first_name, "x_ship_to_last_name" => $customer_order->shipping_last_name, "x_ship_to_company" => $customer_order->shipping_company, "x_ship_to_address" => $customer_order->shipping_address_1, "x_ship_to_city" => $customer_order->shipping_city, "x_ship_to_country" => $customer_order->shipping_country, "x_ship_to_state" => $customer_order->shipping_state, "x_ship_to_zip" => $customer_order->shipping_postcode, "x_cust_id" => $customer_order->user_id, "x_customer_ip" => $_SERVER['REMOTE_ADDR']);
     $response = wp_remote_post($environment_url, array('method' => 'POST', 'body' => http_build_query($payload), 'timeout' => 90, 'sslverify' => false));
     if (is_wp_error($response)) {
         do_action('gp_order_online_completed_failed', $response);
     }
     if (empty($response['body'])) {
         do_action('gp_order_online_completed_failed', $response);
     }
     $response_body = wp_remote_retrieve_body($response);
     // Parse the response into something we can read
     foreach (preg_split("/\r?\n/", $response_body) as $line) {
         $resp = explode("|", $line);
     }
     // Get the values we need
     $r['response_code'] = $resp[0];
     $r['response_sub_code'] = $resp[1];
     $r['response_reason_code'] = $resp[2];
     $r['response_reason_text'] = $resp[3];
     if ($r['response_code'] == 1 || $r['response_code'] == 4) {
         $customer_order->add_order_note(__('Authorize.net payment completed.', 'GP_authorize_gateway'));
         if ($this->mark_order == 'yes') {
             $woocommerce->cart->empty_cart();
             $customer_order->payment_complete();
             $customer_order->update_status('completed');
         }
         do_action('gp_order_online_completed_successfully', $response);
         return array('result' => 'success', 'redirect' => $this->get_return_url($customer_order));
     } else {
         do_action('gp_error_occurred', $r['response_reason_text']);
     }
 }
开发者ID:GammaPartners,项目名称:WooCommerce-Payment-Gateways,代码行数:37,代码来源:authorizenet.php

示例15: isset

 /**
  * Process the payment
  */
 function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $card_type = isset($_POST['eway_card_type']) ? woocommerce_clean($_POST['eway_card_type']) : '';
     $card_number = isset($_POST['eway_card_number']) ? woocommerce_clean($_POST['eway_card_number']) : '';
     $cardholder_name = isset($_POST['eway_card_holdername']) ? woocommerce_clean($_POST['eway_card_holdername']) : '';
     $card_csc = isset($_POST['eway_card_csc']) ? woocommerce_clean($_POST['eway_card_csc']) : '';
     $card_exp_month = isset($_POST['eway_card_expiration_month']) ? woocommerce_clean($_POST['eway_card_expiration_month']) : '';
     $card_exp_year = isset($_POST['eway_card_expiration_year']) ? woocommerce_clean($_POST['eway_card_expiration_year']) : '';
     // Format card expiration data
     $card_exp_month = (int) $card_exp_month;
     if ($card_exp_month < 10) {
         $card_exp_month = '0' . $card_exp_month;
     }
     $card_exp_year = (int) $card_exp_year;
     $card_exp_year += 2000;
     $card_exp = $card_exp_month . $card_exp_year;
     // Format card number
     $card_number = str_replace(array(' ', '-'), '', $card_number);
     // Send request to eway
     try {
         $url = $this->antifraud == "yes" ? $this->antifraudurl : $this->testmode == 'yes' ? $this->testurl : $this->liveurl;
         $post_data = array('ewayCustomerID' => $this->customer_id, 'ewayTotalAmount' => $order->order_total * 100, 'ewayCardNumber' => $card_number, 'ewayCardExpiryMonth' => $card_exp_month, 'ewayCardExpiryYear' => $card_exp_year, 'ewayCVN' => $card_csc, 'ewayTrxnNumber' => '', 'ewayCustomerInvoiceDescription' => '', 'ewayCustomerInvoiceRef' => '', 'ewayOption1' => '', 'ewayOption2' => '', 'ewayOption3' => '', 'ewayCustomerFirstName' => $order->billing_first_name, 'ewayCustomerLastName' => $order->billing_last_name, 'ewayCustomerEmail' => $order->billing_email, 'ewayCardHoldersName' => $cardholder_name, 'ewayCustomerAddress' => $order->billing_address_1 . ' ' . $order->billing_address_2 . ' ' . $order->billing_city . ' ' . $order->billing_state . ' ' . $order->billing_country, 'ewayCustomerPostcode' => $order->billing_postcode);
         if ($this->antifraud == "yes") {
             $post_data['ewayCustomerIPAddress'] = $this->get_user_ip();
             $post_data['ewayCustomerBillingCountry'] = $this->get_country_code();
         }
         $xmlRequest = "<ewaygateway>";
         foreach ($post_data as $key => $value) {
             $xmlRequest .= "<{$key}>{$value}</{$key}>";
         }
         $xmlRequest .= "</ewaygateway>";
         $response = wp_remote_post($url, array('method' => 'POST', 'body' => $xmlRequest, 'timeout' => 70, 'sslverify' => true));
         if (is_wp_error($response)) {
             throw new Exception(__('There was a problem connecting to the payment gateway.', 'woothemes'));
         }
         if (empty($response['body'])) {
             throw new Exception(__('Empty eWAY response.', 'woothemes'));
         }
         $parsed_response = $response['body'];
         $parsed_response = $this->parseResponse($parsed_response);
         switch (strtolower($parsed_response['EWAYTRXNSTATUS'])) {
             case 'true':
                 // Add order note
                 $order->add_order_note(sprintf(__('eWAY payment completed', 'woothemes')));
                 // Payment complete
                 $order->payment_complete();
                 // Remove cart
                 $woocommerce->cart->empty_cart();
                 // Empty awaiting payment session
                 unset($_SESSION['order_awaiting_payment']);
                 // Return thank you page redirect
                 return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))));
                 break;
             case 'false':
                 // Payment failed :(
                 $order->add_order_note(sprintf(__('eWAY payment failed (Correlation ID: %s). Payment was rejected due to an error: ', 'woothemes'), $parsed_response['EWAYAUTHCODE']) . '"' . $parsed_response['EWAYTRXNERROR'] . '"');
                 $woocommerce->add_error(__('Payment error:', 'woothemes') . $parsed_response['EWAYTRXNERROR']);
                 return;
                 break;
             default:
                 // Payment failed :(
                 $order->add_order_note(sprintf(__('eWAY payment failed (Correlation ID: %s). Payment was rejected due to an error: ', 'woothemes'), $parsed_response['CORRELATIONID']) . '"' . $error_message . '"');
                 $woocommerce->add_error(__('Payment error:', 'woothemes') . $parsed_response['EWAYTRXNERROR']);
                 return;
                 break;
         }
     } catch (Exception $e) {
         $woocommerce->add_error(__('Connection error:', 'woothemes') . ': "' . $e->getMessage() . '"');
         return;
     }
 }
开发者ID:pmariopereira,项目名称:peter-sassy,代码行数:76,代码来源:gateway-eway.php


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