update_status() public method

Updates status of order immediately. Order must exist.
public update_status ( $new_status, $note = '', $manual = false ) : boolean
return boolean success
Exemplo n.º 1
1
 /**
  * Update a order status
  *
  * @return void
  */
 function change_order_status()
 {
     check_ajax_referer('dokan_change_status');
     $order_id = intval($_POST['order_id']);
     $order_status = $_POST['order_status'];
     $order = new WC_Order($order_id);
     $order->update_status($order_status);
     $statuses = wc_get_order_statuses();
     $status_label = isset($statuses[$order_status]) ? $statuses[$order_status] : $order_status;
     $status_class = dokan_get_order_status_class($order_status);
     echo '<label class="dokan-label dokan-label-' . $status_class . '">' . $status_label . '</label>';
     exit;
 }
 public function update_order_detail($order_id, $data)
 {
     global $wpdb, $woocommerce, $pwa;
     $non_received = $wpdb->get_results("select * from {$wpdb->postmeta} where meta_key = '_non_received' and post_id = {$order_id} ");
     if (empty($non_received)) {
         $pwacheckkout = new Pwacheckout();
         if ($pwacheckkout->get_option('iopn_dump') == 'yes') {
             $dir = $pwacheckkout->get_option('iopn_dump_url');
             if (!file_exists($dir) && !is_dir($dir)) {
                 mkdir($dir, 0777);
             }
             $filename = $dir . $order_id . '_iopn_non';
             $myfile = fopen($filename, "w");
             fwrite($myfile, $data);
             fclose($myfile);
         }
         add_post_meta($order_id, '_non_received', '1');
         if (UPDATE_ODER_FROM == 'xmlcart') {
             $this->update_cart_by_xml($order_id, $data);
         } else {
             $this->update_cart_by_woocart($order_id, $data);
         }
     }
     $order = new WC_Order($order_id);
     $order->update_status('cancelled');
     // Acknowledge the order in seller central using MWS FEED API
     $pwa->pwa_cancel_feed($order_id);
     header('HTTP/1.1 200 OK');
     exit;
 }
Exemplo n.º 3
0
function custom_woocommerce_auto_complete_order( $order_id ) {
	global $woocommerce;

	if ( !$order_id )
		return;
	$order = new WC_Order( $order_id );
	$order->update_status( 'completed' );
}
 public function jabulani($order_id)
 {
     $order = new WC_Order($order_id);
     $j = get_post_meta($order_id, '_payment_method');
     if ($j[0] == 'pagseguro') {
         if ($order->status == 'pending') {
             $order->update_status('on-hold');
         }
     }
 }
Exemplo n.º 5
0
 public function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $order->update_status('pending');
     // Reduce stock levels
     $order->reduce_order_stock();
     // Remove cart
     $woocommerce->cart->empty_cart();
     return array('result' => 'success', 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('woocommerce_pay_page_id')))));
 }
 /**
  * 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);
 }
 /**
  * Process the payment and return the result
  *
  * @param int $order_id
  * @return array
  */
 public function process_payment($order_id)
 {
     $order = new WC_Order($order_id);
     // Mark as on-hold (we're awaiting the cheque)
     $order->update_status('on-hold', __('Awaiting cheque payment', 'woocommerce'));
     // Reduce stock levels
     $order->reduce_order_stock();
     // Remove cart
     WC()->cart->empty_cart();
     // Return thankyou redirect
     return array('result' => 'success', 'redirect' => $this->get_return_url($order));
 }
 public function handle_request($url, $args, $parameters, $order_id, $item_id)
 {
     // multipart request
     try {
         $args = $this->create_multipart_request($parameters, $args);
         $links = $this->do_request($url, $args);
         $this->add_downloadlinks($links, $item_id);
     } catch (Exception $e) {
         $order = new WC_Order($order_id);
         $order->update_status('wc-booxtream-error', $e->getMessage());
     }
 }
Exemplo n.º 9
0
 public function updateStatus($to, $desc)
 {
     // $order = new \WC_Order( $this->_actual_model_id );
     // $order->update_status( $to );
     // Right now, we don't want the overhead of the WooCom
     // events that are triggered with a status update.
     Helpers::debug("Order::updateStatus to " . var_export($to, true));
     $order = new \WC_Order($this->_actual_model_id);
     Helpers::debug("Using WOOCOM to update status");
     $order->update_status($to);
     //$this->updateTerm('status','shop_order_status',$to);
 }
function wpuw_custom_woocommerce_auto_complete_order($order_id)
{
    if (!$order_id) {
        return;
    }
    $order = new WC_Order($order_id);
    if (count($order->get_items()) > 0) {
        foreach ($order->get_items() as $item) {
            if (has_term('credit', 'product_cat', $item['product_id'])) {
                $order->update_status('completed');
            }
        }
    }
}
Exemplo n.º 11
0
 /**
  * Process the payment and return the result
  *
  * @access public
  * @param int $order_id
  * @return array
  */
 function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     // Mark as on-hold (we're awaiting the cheque)
     $order->update_status('on-hold', __('Payment to be made upon delivery.', 'woocommerce'));
     // Reduce stock levels
     $order->reduce_order_stock();
     // Remove cart
     $woocommerce->cart->empty_cart();
     // Empty awaiting payment session
     unset($_SESSION['order_awaiting_payment']);
     // Return thankyou redirect
     return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks')))));
 }
Exemplo n.º 12
0
 function successful_request($posted)
 {
     //print_r($posted);
     global $woocommerce;
     $order_id_key = $posted['customerReference'];
     $order_id_key = explode("-", $order_id_key);
     $order_id = $order_id_key[0];
     $order_key = $order_id_key[1];
     $responseCode = $posted['responseCode'];
     $responseText = $posted['responseText'];
     $txnreference = $posted['txnreference'];
     $order = new WC_Order($order_id);
     if ($order->order_key !== $order_key) {
         echo 'Error: Order Key does not match invoice.';
         exit;
     }
     if ($order->get_total() != $posted['amount']) {
         echo 'Error: Amount not match.';
         $order->update_status('on-hold', sprintf(__('Validation error: BrainTree amounts do not match (%s).', 'woocommerce'), $posted['amount']));
         exit;
     }
     // if TXN is approved
     if ($responseCode == "00" || $responseCode == "08" || $responseCode == "77") {
         // Payment completed
         $order->add_order_note(__('payment completed', 'woocommerce'));
         // Mark order complete
         $order->payment_complete();
         // Empty cart and clear session
         $woocommerce->cart->empty_cart();
         // Redirect to thank you URL
         wp_redirect($this->get_return_url($order));
         exit;
     } else {
         // Change the status to pending / unpaid
         $order->update_status('pending', __('Payment declined', 'woothemes'));
         // Add a note with the IPG details on it
         $order->add_order_note(__('Braintree payment Failed - TransactionReference: ' . $txnreference . " - ResponseCode: " . $responseCode, 'woocommerce'));
         // FAILURE NOTE
         // Add error for the customer when we return back to the cart
         $woocommerce->add_error(__('TRANSACTION DECLINED: ', 'woothemes') . $posted['responseText'] . "<br/>Reference: " . $txnreference);
         // Redirect back to the last step in the checkout process
         wp_redirect($woocommerce->cart->get_checkout_url());
         exit;
     }
 }
 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;
 }
Exemplo n.º 14
0
 function check_ipn_response()
 {
     global $woocommerce;
     $posted = $_POST['payment'];
     $hash = sha1(md5($posted . $this->merchant_password));
     if (isset($_POST['payment']) && $hash === $_POST['signature']) {
         $items = explode("&", $_POST['payment']);
         $ar = array();
         foreach ($items as $it) {
             $key = "";
             $value = "";
             list($key, $value) = explode("=", $it, 2);
             $payment_items[$key] = $value;
         }
         $order = new WC_Order($payment_items['order']);
         $order->update_status('processing', __('Платеж успешно оплачен', 'woocommerce'));
         $order->add_order_note(__('Клиент успешно оплатил заказ', 'woocommerce'));
         $woocommerce->cart->empty_cart();
     } else {
         wp_die('IPN Request Failure');
     }
 }
 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']);
     }
 }
Exemplo n.º 16
0
 public function handle_callback()
 {
     $inputData = file_get_contents('php://input');
     $payResponse = json_decode($inputData);
     $security = 1;
     // callback password
     //            if (($callbackPass = $this->callback) != NULL) {
     //                $paymentHeaders = getallheaders();
     //                $digest         = $paymentHeaders["Bpsignature"];
     //
     //                $hashMsg     = $inputData . $callbackPass;
     //                $checkDigest = hash('sha256', $hashMsg);
     //
     //                if (strcmp($digest, $checkDigest) == 0) {
     //                    $security = 1;
     //                } else {
     //                    $security = 0;
     //                }
     //            }
     // payment status
     $paymentStatus = $payResponse->status;
     // order id
     $preOrderId = json_decode($payResponse->reference);
     $orderId = $preOrderId->order_number;
     // confirmation process
     $order = new WC_Order($orderId);
     if ($security) {
         if ($paymentStatus != NULL) {
             error_log($paymentStatus);
             switch ($paymentStatus) {
                 case 'confirmed':
                     $order->update_status('processing', __('MNP Payment processing', 'mnp'));
                     break;
                 case 'pending':
                     $order->update_status('pending', __('MNP Payment pending', 'mnp'));
                     break;
                 case 'received':
                     $order->update_status('pending', __('MNP Payment received but still pending', 'mnp'));
                     break;
                 case 'insufficient_amount':
                     $order->update_status('failed', __('MNP Payment failed. Insufficient amount', 'mnp'));
                     break;
                 case 'invalid':
                     $order->update_status('cancelled', __('MNP Payment failed. Invalid', 'mnp'));
                     break;
                 case 'timeout':
                     $order->update_status('cancelled', __('MNP Payment failed. Timeout', 'mnp'));
                     break;
                 case 'refund':
                     $order->update_status('refunded', __('MNP Payment refunded', 'mnp'));
                     break;
                 case 'paid_after_timeout':
                     $order->update_status('failed', __('MNP Payment failed. Paid after timeout', 'mnp'));
                     break;
             }
         }
     }
 }
 /**
  * Process the payment and return the result
  *
  * @param int $order_id
  * @return array
  */
 public function process_payment($order_id)
 {
     $order = new WC_Order($order_id);
     // Mark as processing (payment won't be taken until delivery)
     $order->update_status('processing', __('Payment to be made upon delivery.', 'woocommerce'));
     // Reduce stock levels
     $order->reduce_order_stock();
     // Remove cart
     WC()->cart->empty_cart();
     // Return thankyou redirect
     return array('result' => 'success', 'redirect' => $this->get_return_url($order));
 }
 /**
  * function to trigger complete payment for renewal if it's paid by smart coupons
  *
  * @param WC_Order $renewal_order
  * @param WC_Order $original_order
  * @param int $product_id
  * @param string $new_order_role
  */
 public function sc_renewal_complete_payment($renewal_order = null, $original_order = null, $product_id = 0, $new_order_role = null)
 {
     if (empty($renewal_order->id)) {
         return;
     }
     $is_renewal_paid_by_smart_coupon = get_post_meta($renewal_order->id, '_renewal_paid_by_smart_coupon', true);
     if (!empty($is_renewal_paid_by_smart_coupon) && $is_renewal_paid_by_smart_coupon == 'yes') {
         $renewal_order->update_status('processing', __('Order paid by store credit.', self::$text_domain));
     }
 }
Exemplo n.º 19
0
{
    $redirect = $_SERVER["REQUEST_URI"];
    return $redirect;
    exit;
}

/**********************************************************************************/
/* REDIRIGIR A LA MISMA PAGINA DESPUES DE LA COTIZACION EXITOSA  */
/**********************************************************************************/

add_action( 'woocommerce_thankyou', function( $order_id ){
    $order = new WC_Order( $order_id );

    if ( $order->status != 'failed' ) { 

        $order->update_status( 'processing');

        wp_redirect( home_url('cart/order-received/?order='. $order_id) );
    }
});

/*add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' ); 
function wc_custom_redirect_after_purchase() {
    global $wp;
    
    if ( !empty( $wp->query_vars['order-received'] ) ) {
        $order_id = absint( $wp->query_vars['order-received'] );
        $url_cart = home_url( 'cart/order-received/?order='. $order_id );
        wp_redirect( $url_cart );
        exit;
    }
 /**
  * Update order status.
  *
  * @param array $posted PagSeguro post data.
  */
 public function update_order_status($posted)
 {
     if (isset($posted->reference)) {
         $order_id = (int) str_replace($this->invoice_prefix, '', $posted->reference);
         $order = new WC_Order($order_id);
         // Checks whether the invoice number matches the order.
         // If true processes the payment.
         if ($order->id === $order_id) {
             if ('yes' == $this->debug) {
                 $this->log->add($this->id, 'PagSeguro payment status for order ' . $order->get_order_number() . ' is: ' . intval($posted->status));
             }
             // Order details.
             $order_details = array('type' => '', 'method' => '', 'installments' => '', 'link' => '');
             if (isset($posted->code)) {
                 update_post_meta($order->id, __('PagSeguro Transaction ID', 'woocommerce-pagseguro'), (string) $posted->code);
             }
             if (isset($posted->sender->email)) {
                 update_post_meta($order->id, __('Payer email', 'woocommerce-pagseguro'), (string) $posted->sender->email);
             }
             if (isset($posted->sender->name)) {
                 update_post_meta($order->id, __('Payer name', 'woocommerce-pagseguro'), (string) $posted->sender->name);
             }
             if (isset($posted->paymentMethod->type)) {
                 $order_details['type'] = intval($posted->paymentMethod->type);
                 update_post_meta($order->id, __('Payment type', 'woocommerce-pagseguro'), $this->api->get_payment_name_by_type($order_details['type']));
             }
             if (isset($posted->paymentMethod->code)) {
                 $order_details['method'] = $this->api->get_payment_method_name(intval($posted->paymentMethod->code));
                 update_post_meta($order->id, __('Payment method', 'woocommerce-pagseguro'), $order_details['method']);
             }
             if (isset($posted->installmentCount)) {
                 $order_details['installments'] = (string) $posted->installmentCount;
                 update_post_meta($order->id, __('Installments', 'woocommerce-pagseguro'), $order_details['installments']);
             }
             if (isset($posted->paymentLink)) {
                 $order_details['link'] = (string) $posted->paymentLink;
                 update_post_meta($order->id, __('Payment url', 'woocommerce-pagseguro'), $order_details['link']);
             }
             // Save/update payment information for transparente checkout.
             if ('transparent' == $this->method) {
                 update_post_meta($order->id, '_wc_pagseguro_payment_data', $order_details);
             }
             switch (intval($posted->status)) {
                 case 1:
                     $order->update_status('on-hold', __('PagSeguro: The buyer initiated the transaction, but so far the PagSeguro not received any payment information.', 'woocommerce-pagseguro'));
                     break;
                 case 2:
                     $order->update_status('on-hold', __('PagSeguro: Payment under review.', 'woocommerce-pagseguro'));
                     break;
                 case 3:
                     $order->add_order_note(__('PagSeguro: Payment approved.', 'woocommerce-pagseguro'));
                     // For WooCommerce 2.2 or later.
                     add_post_meta($order->id, '_transaction_id', (string) $posted->code, true);
                     // Changing the order for processing and reduces the stock.
                     $order->payment_complete();
                     break;
                 case 4:
                     $order->add_order_note(__('PagSeguro: Payment completed and credited to your account.', 'woocommerce-pagseguro'));
                     break;
                 case 5:
                     $order->update_status('on-hold', __('PagSeguro: Payment came into dispute.', 'woocommerce-pagseguro'));
                     $this->send_email(sprintf(__('Payment for order %s came into dispute', 'woocommerce-pagseguro'), $order->get_order_number()), __('Payment in dispute', 'woocommerce-pagseguro'), sprintf(__('Order %s has been marked as on-hold, because the payment came into dispute in PagSeguro.', 'woocommerce-pagseguro'), $order->get_order_number()));
                     break;
                 case 6:
                     $order->update_status('refunded', __('PagSeguro: Payment refunded.', 'woocommerce-pagseguro'));
                     $this->send_email(sprintf(__('Payment for order %s refunded', 'woocommerce-pagseguro'), $order->get_order_number()), __('Payment refunded', 'woocommerce-pagseguro'), sprintf(__('Order %s has been marked as refunded by PagSeguro.', 'woocommerce-pagseguro'), $order->get_order_number()));
                     break;
                 case 7:
                     $order->update_status('cancelled', __('PagSeguro: Payment canceled.', 'woocommerce-pagseguro'));
                     break;
                 default:
                     // No action xD.
                     break;
             }
         } else {
             if ('yes' == $this->debug) {
                 $this->log->add($this->id, 'Error: Order Key does not match with PagSeguro reference.');
             }
         }
     }
 }
 /**
  * Called when a sign up fails during the payment processing step.
  *
  * @param $order WC_Order | int The order or ID of the order for which subscriptions should be marked as failed.
  * @since 1.0
  */
 public static function failed_subscription_sign_ups_for_order($order)
 {
     if (!is_object($order)) {
         $order = new WC_Order($order);
     }
     // Set subscription status to failed and log failure
     $order->update_status('failed', __('Subscription sign up failed.', WC_Subscriptions::$text_domain));
     self::mark_not_paying_customer($order);
     // Update subscription in User's account
     self::update_users_subscriptions_for_order($order, 'failed');
     do_action('failed_subscription_sign_ups_for_order', $order);
 }
 /**
  * Process the subscription
  *
  * Saves the card, if needed, and activates the subscription. This is called when the subscription is first purchased
  *
  * @param int $order_id
  *
  * @return array
  *
  * @since 0.6.0
  */
 public function process_subscription($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $user_id = get_current_user_id();
     $profile_id = $this->profiles_enabled ? $this->saved_cards->get_user_profile_id($user_id) : false;
     $token = isset($_POST['card_connect_token']) ? wc_clean($_POST['card_connect_token']) : false;
     $card_name = isset($_POST['card_connect-card-name']) ? wc_clean($_POST['card_connect-card-name']) : false;
     $store_new_card = isset($_POST['card_connect-save-card']) ? wc_clean($_POST['card_connect-save-card']) : false;
     $saved_card_id = isset($_POST['card_connect-cards']) ? wc_clean($_POST['card_connect-cards']) : false;
     $card_alias = isset($_POST['card_connect-new-card-alias']) ? wc_clean($_POST['card_connect-new-card-alias']) : false;
     if (!$token && !$saved_card_id) {
         wc_add_notice(__('Payment error: ', 'woothemes') . 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'error');
         return;
     }
     $request = array('merchid' => $this->api_credentials['mid'], 'cvv2' => wc_clean($_POST['card_connect-card-cvc']), 'amount' => $order->order_total * 100, 'currency' => "USD", 'orderid' => sprintf(__('%s - Order #%s', 'woocommerce'), esc_html(get_bloginfo('name', 'display')), $order->get_order_number()), 'name' => $card_name ? $card_name : trim($order->billing_first_name . ' ' . $order->billing_last_name), 'street' => $order->billing_address_1, 'city' => $order->billing_city, 'region' => $order->billing_state, 'country' => $order->billing_country, 'postal' => $order->billing_postcode, 'capture' => $this->mode === 'capture' ? 'Y' : 'N');
     if ($saved_card_id) {
         // Payment is using a stored card, no token or account number to pass
         $request['profile'] = "{$profile_id}/{$saved_card_id}";
     } else {
         // Either a basic purchase or adding a new card. Either way, include the expiration date
         $request['expiry'] = preg_replace('/[^\\d]/i', '', wc_clean($_POST['card_connect-card-expiry']));
         // Adding an additional card to an existing profile -- This requires a separate API call, handled in `add_account_to_profile`
         if ($profile_id) {
             $request['profile'] = $profile_id;
             // The `token` key isn't used by the Auth/Capture service however it's ignored if it's passed as `account` when updating profiles
             $request['token'] = $token;
             // Get the new card's account id, remove the token key
             $new_account_id = $this->saved_cards->add_account_to_profile($user_id, $card_alias, $request);
             unset($request['token']);
             // Overwrite the profile field with the `profile/acctid` format required by the Auth/Capture service
             $request['profile'] = "{$profile_id}/{$new_account_id}";
             // Adding a new card, no existing profile
         } else {
             $request['profile'] = 'Y';
             $request['account'] = $token;
         }
     }
     //Authorizes transaction to be processed
     if (!is_null($this->get_cc_client())) {
         $response = $this->get_cc_client()->authorizeTransaction($request);
     } else {
         wc_add_notice(__('Payment error: ', 'woothemes') . 'CardConnect is not configured! ', 'error');
         $order->add_order_note('CardConnect is not configured!');
         return;
     }
     // 'A' response is for accepted
     if ('A' === $response['respstat']) {
         // Need to verify customer data before marking complete
         $order_verification = $this->verify_customer_data($response);
         if (!$order_verification['is_valid']) {
             $request = array('merchid' => $this->api_credentials['mid'], 'currency' => 'USD', 'retref' => $response['retref']);
             if (!is_null($this->get_cc_client())) {
                 $void_response = $this->get_cc_client()->voidTransaction($request);
             } else {
                 wc_add_notice(__('Payment error: ', 'woothemes') . 'CardConnect is not configured! ', 'error');
                 $order->add_order_note('CardConnect is not configured!');
                 return;
             }
             if ($void_response['authcode'] === 'REVERS') {
                 $order->update_status('failed', __('Payment Failed', 'cardconnect-payment-gateway'));
                 foreach ($order_verification['errors'] as $error) {
                     $order->add_order_note(sprintf(__($error, 'woocommerce')));
                     wc_add_notice(__('Payment error: ', 'woothemes') . $error, 'error');
                 }
                 return;
             }
         }
         // Mark order complete and begin completion process
         $order->payment_complete($response['retref']);
         update_post_meta($order_id, '_transaction_id', $response['retref']);
         // Reduce stock levels
         $order->reduce_order_stock();
         // Remove cart
         $woocommerce->cart->empty_cart();
         $order->add_order_note(sprintf(__('CardConnect payment approved (ID: %s, Authcode: %s)', 'woocommerce'), $response['retref'], $response['authcode']));
         // First time this customer has saved a card, pull the response fields and store in user meta
         if (!$saved_card_id && !$profile_id) {
             $this->saved_cards->set_user_profile_id($user_id, $response['profileid']);
             $this->saved_cards->save_user_card($user_id, array($response['acctid'] => $card_alias));
         }
         // Activate the subscription
         WC_Subscriptions_Manager::activate_subscriptions_for_order($order);
         // Return thankyou redirect
         return array('result' => 'success', 'redirect' => $this->get_return_url($order));
     } else {
         if ('C' === $response['respstat']) {
             wc_add_notice(__('Payment error: ', 'woothemes') . 'Order Declined : ' . $response['resptext'], 'error');
             $order->add_order_note(sprintf(__('CardConnect declined transaction. Response: %s', 'woocommerce'), $response['resptext']));
         } else {
             wc_add_notice(__('Payment error: ', 'woothemes') . 'An error prevented this transaction from completing. Please confirm your information and try again.', 'error');
             $order->add_order_note(sprintf(__('CardConnect failed transaction. Response: %s', 'woocommerce'), $response['resptext']));
         }
     }
     $order->update_status('failed', __('Payment Failed', 'cardconnect-payment-gateway'));
     return;
 }
	/**
	* process the payment and return the result
	* @param int $order_id
	* @return array
	*/
	public function process_payment($order_id) {
		global $woocommerce;

		$order = new WC_Order($order_id);
		$ccfields = $this->getCardFields();

		$isLiveSite = ($this->eway_sandbox != 'yes');

		if ($this->eway_stored == 'yes')
			$eway = new EwayPaymentsStoredPayment($this->eway_customerid, $isLiveSite);
		else
			$eway = new EwayPaymentsPayment($this->eway_customerid, $isLiveSite);

		$eway->invoiceDescription		= get_bloginfo('name');
		$eway->invoiceReference			= $order->get_order_number();						// customer invoice reference
		$eway->transactionNumber		= $order_id;										// transaction reference
		$eway->cardHoldersName			= $ccfields['eway_card_name'];
		$eway->cardNumber				= strtr($ccfields['eway_card_number'], array(' ' => '', '-' => ''));
		$eway->cardExpiryMonth			= $ccfields['eway_expiry_month'];
		$eway->cardExpiryYear			= $ccfields['eway_expiry_year'];
		$eway->cardVerificationNumber	= $ccfields['eway_cvn'];
		$eway->firstName				= $order->billing_first_name;
		$eway->lastName					= $order->billing_last_name;
		$eway->emailAddress				= $order->billing_email;
		$eway->postcode					= $order->billing_postcode;

		// for Beagle (free) security
		if ($this->eway_beagle == 'yes') {
			$eway->customerCountryCode = $order->billing_country;
		}

		// convert WooCommerce country code into country name
		$billing_country = $order->billing_country;
		if (isset($woocommerce->countries->countries[$billing_country])) {
			$billing_country = $woocommerce->countries->countries[$billing_country];
		}

		// aggregate street, city, state, country into a single string
		$parts = array (
			$order->billing_address_1,
			$order->billing_address_2,
			$order->billing_city,
			$order->billing_state,
			$billing_country,
		);
		$eway->address = implode(', ', array_filter($parts, 'strlen'));

		// use cardholder name for last name if no customer name entered
		if (empty($eway->firstName) && empty($eway->lastName)) {
			$eway->lastName				= $eway->cardHoldersName;
		}

		// allow plugins/themes to modify invoice description and reference, and set option fields
		$eway->invoiceDescription		= apply_filters('woocommerce_eway_invoice_desc', $eway->invoiceDescription, $order_id);
		$eway->invoiceReference			= apply_filters('woocommerce_eway_invoice_ref', $eway->invoiceReference, $order_id);
		$eway->option1					= apply_filters('woocommerce_eway_option1', '', $order_id);
		$eway->option2					= apply_filters('woocommerce_eway_option2', '', $order_id);
		$eway->option3					= apply_filters('woocommerce_eway_option3', '', $order_id);

		// if live, pass through amount exactly, but if using test site, round up to whole dollars or eWAY will fail
		$total = $order->order_total;
		$eway->amount					= $isLiveSite ? $total : ceil($total);

		try {
			$response = $eway->processPayment();

			if ($response->status) {
				// transaction was successful, so record details and complete payment
				update_post_meta($order_id, 'Transaction ID', $response->transactionNumber);
				if (!empty($response->authCode)) {
					update_post_meta($order_id, 'Authcode', $response->authCode);
				}
				if (!empty($response->beagleScore)) {
					update_post_meta($order_id, 'Beagle score', $response->beagleScore);
				}

				if ($this->eway_stored == 'yes') {
					// payment hasn't happened yet, so record status as 'on-hold' and reduce stock in anticipation
					$order->reduce_order_stock();
					$order->update_status('on-hold', 'Awaiting stored payment');
					unset($_SESSION['order_awaiting_payment']);
				}
				else {
					$order->payment_complete();
				}
				$woocommerce->cart->empty_cart();

				$result = array(
					'result' => 'success',
					'redirect' => $this->get_return_url($order),
				);
			}
			else {
				// transaction was unsuccessful, so record transaction number and the error
				$order->update_status('failed', nl2br(esc_html($response->error)));
				wc_add_notice(nl2br(esc_html($response->error)), 'error');
				$result = array('result' => 'failure');
			}
		}
		catch (EwayPaymentsException $e) {
			// an exception occured, so record the error
			$order->update_status('failed', nl2br(esc_html($e->getMessage())));
			wc_add_notice(nl2br(esc_html($e->getMessage())), 'error');
			$result = array('result' => 'failure');
		}

		return $result;
	}
 public function meta_box_save($post_id)
 {
     if (!isset($_POST['wc_bookings_details_meta_box_nonce']) || !wp_verify_nonce($_POST['wc_bookings_details_meta_box_nonce'], 'wc_bookings_details_meta_box')) {
         return $post_id;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     if (!in_array($_POST['post_type'], $this->post_types)) {
         return $post_id;
     }
     global $wpdb;
     // Save simple fields
     $booking_order_id = absint($_POST['_booking_order_id']);
     $booking_status = wc_clean($_POST['_booking_status']);
     $customer_id = absint($_POST['_booking_customer_id']);
     $product_id = wc_clean($_POST['product_or_resource_id']);
     $parent_id = absint($_POST['_booking_parent_id']);
     $all_day = isset($_POST['_booking_all_day']) ? '1' : '0';
     // Update post_parent and status via query to prevent endless loops
     $wpdb->update($wpdb->posts, array('post_parent' => $booking_order_id), array('ID' => $post_id));
     $wpdb->update($wpdb->posts, array('post_status' => $booking_status), array('ID' => $post_id));
     // Cancel order on save
     if ('cancelled' == $booking_status) {
         $order = new WC_Order($booking_order_id);
         $order->update_status('cancelled');
     }
     // Save product and resource
     if (strstr($product_id, '=>')) {
         list($product_id, $resource_id) = explode('=>', $product_id);
     } else {
         $resource_id = 0;
     }
     update_post_meta($post_id, '_booking_resource_id', $resource_id);
     update_post_meta($post_id, '_booking_product_id', $product_id);
     // Update meta
     update_post_meta($post_id, '_booking_customer_id', $customer_id);
     update_post_meta($post_id, '_booking_parent_id', $parent_id);
     update_post_meta($post_id, '_booking_all_day', $all_day);
     // Persons
     $persons = get_post_meta($post_id, '_booking_persons', true);
     if (!empty($persons)) {
         $booking_persons = array();
         foreach (array_keys($persons) as $person_id) {
             $booking_persons[$person_id] = absint($_POST['_booking_person_' . $person_id]);
         }
         update_post_meta($post_id, '_booking_persons', $booking_persons);
     }
     // Update date
     if (empty($_POST['booking_date'])) {
         $date = current_time('timestamp');
     } else {
         $date = strtotime($_POST['booking_date'] . ' ' . (int) $_POST['booking_date_hour'] . ':' . (int) $_POST['booking_date_minute'] . ':00');
     }
     $date = date_i18n('Y-m-d H:i:s', $date);
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date($date), $post_id));
     // Do date and time magic and save them in one field
     $start_date = explode('-', wc_clean($_POST['booking_start_date']));
     $end_date = explode('-', wc_clean($_POST['booking_end_date']));
     $start_time = explode(':', wc_clean($_POST['booking_start_time']));
     $end_time = explode(':', wc_clean($_POST['booking_end_time']));
     $start = mktime($start_time[0], $start_time[1], 0, $start_date[1], $start_date[2], $start_date[0]);
     $end = mktime($end_time[0], $end_time[1], 0, $end_date[1], $end_date[2], $end_date[0]);
     update_post_meta($post_id, '_booking_start', date('YmdHis', $start));
     update_post_meta($post_id, '_booking_end', date('YmdHis', $end));
     do_action('woocommerce_booking_process_meta', $post_id);
 }
Exemplo n.º 25
0
 function _requests($_notification)
 {
     global $woocommerce;
     $order = new WC_Order($_notification->order_id);
     if ($_notification->status == 'COMPLETE') {
         $order->payment_complete();
         $woocommerce->cart->empty_cart();
     } elseif ($_notification->status == 'PENDING') {
         $order->update_status('on-hold');
     } elseif ($_notification->status == 'FAIL') {
         $order->update_status('failed');
     }
     exit;
 }
 public function process_payment($order_id)
 {
     try {
         global $woocommerce;
         $customer_order = new WC_Order($order_id);
         PayU_Middleware::$api_key = $this->api_key;
         PayU_Middleware::$api_login = $this->api_login;
         PayU_Middleware::$merchant_id = $this->merchant_id;
         PayU_Middleware::$account_id = $this->account_id;
         PayU_Middleware::$test_mode = $this->environment == 'yes';
         $payerName = $customer_order->billing_first_name . ' ' . $customer_order->billing_last_name;
         $method = $_POST["GP_PayU_offline_Gateway-offlinemethod"];
         $res = PayU_Middleware::do_payment($order_id, $this->payment_description . $order_id, $customer_order->order_total, $customer_order->billing_email, $payerName, '123', '', '', '', $method, true);
         if ($res['code'] == 'SUCCESS' && $res['state'] == "PENDING") {
             if ($this->mark_order == 'yes') {
                 $woocommerce->cart->empty_cart();
                 $customer_order->update_status('pending');
             }
             return array('result' => 'success', 'redirect' => $this->thankyou_page_url . '?order_id=' . $order_id . '&receipt_url=' . $res['payment_url']);
         }
     } catch (PayUException $e) {
         do_action('gp_error_occurred', $e);
     } catch (Exception $e) {
         do_action('gp_error_occurred', $e);
     }
 }
 public function process_payment($order_id)
 {
     try {
         global $woocommerce;
         $customer_order = new WC_Order($order_id);
         PayU_Middleware::$api_key = $this->api_key;
         PayU_Middleware::$api_login = $this->api_login;
         PayU_Middleware::$merchant_id = $this->merchant_id;
         PayU_Middleware::$account_id = $this->account_id;
         PayU_Middleware::$test_mode = $this->environment == 'yes';
         $cardNumber = str_replace(array(' ', ''), '', $_POST['GP_PayU_online_Gateway-card-number']);
         $expirationArray = explode('/', $_POST['GP_PayU_online_Gateway-card-expiry']);
         $expirationDate = '20' . $expirationArray[1] . '/' . $expirationArray[0];
         $expirationDate = str_replace(' ', '', $expirationDate);
         $payerName = $customer_order->billing_first_name . ' ' . $customer_order->billing_last_name;
         $cvv = $_POST['GP_PayU_online_Gateway-card-cvc'];
         $res = PayU_Middleware::do_payment($order_id, $this->payment_description . $order_id, $customer_order->order_total, $customer_order->billing_email, $payerName, '111', $cardNumber, $cvv, $expirationDate, '', false);
         if (isset($res['code']) == true && isset($res['state']) == true && $res['code'] == 'SUCCESS' && $res['state'] == "APPROVED") {
             do_action('gp_order_online_completed_successfully', $res);
             if ($this->mark_order == 'yes') {
                 $woocommerce->cart->empty_cart();
                 $customer_order->payment_complete();
                 $customer_order->update_status('completed');
             }
             return array('result' => 'success', 'redirect' => $this->thankyou_page_url . '?order_id=' . $order_id);
         } else {
             do_action('gp_order_online_completed_failed', $res);
         }
     } catch (PayUException $e) {
         do_action('gp_error_occurred', $e);
     } catch (Exception $e) {
         do_action('gp_error_occurred', $e);
     }
 }
 function triveneto_response_interface($template)
 {
     global $wp_query;
     // If the 'triveneto_response_interface' query var isn't appended to the URL,
     // don't do anything and return default
     if (!isset($wp_query->query['triveneto_response_interface'])) {
         return $template;
     }
     // .. otherwise,
     if ($wp_query->query['triveneto_response_interface'] == '1') {
         // Load basics
         require_once 'wp/wp-load.php';
         require_once plugin_dir_path(__FILE__) . '/classes/PgConsTriv.php';
         // Check if we have the $_POST vars
         if (!isset($_POST) || empty($_POST)) {
             // if not ... nothing to see here
             header('Location:' . get_home_url());
         }
         // Log the $_POST vars received
         $postvars = print_r($_POST, true);
         PgConsTriv::triveneto_log('[PostVars] ' . $postvars);
         // Log Errors if any
         if (isset($_POST['Error']) && isset($_POST['ErrorText'])) {
             // Get vars
             $Error = $_POST['Error'];
             $ErrorText = $_POST['ErrorText'];
             // record to log
             PgConsTriv::triveneto_log('Detected error: ' . $Error . ' => ' . $ErrorText);
         }
         // Process the order
         if (isset($_POST['trackid'])) {
             // Get vars
             $trackid = intval($_POST['trackid']);
             // Create the Order object
             $order = new WC_Order($trackid);
             // Mark as 'Processing'
             $order->update_status('processing', __('Received successful TrivenetoBassilichi payment', 'woocommerce_gateway_tvb'));
             // log
             PgConsTriv::triveneto_log('Received successful TrivenetoBassilichi payment');
             // Order successful URL
             $url = $order->get_checkout_order_received_url();
             // Command the redirection to the ThankYou page
             echo "REDIRECT=" . $url;
         }
         exit;
     }
     return $template;
 }
 function inicis_escrow_request_denyconfirm($posted)
 {
     global $inicis_payment;
     if (empty($_POST['dcnf_name']) && empty($_POST['tid']) && empty($_POST['mid'])) {
         return false;
     }
     require $inicis_payment->plugin_path() . "/lib/inipay50/INILib.php";
     $iniescrow = new INIpay50();
     $iniescrow->SetField("inipayhome", $this->settings['libfolder']);
     // 이니페이 홈디렉터리(상점수정 필요)
     $iniescrow->SetField("tid", $_POST['tid']);
     // 거래아이디
     $iniescrow->SetField("mid", $_POST['mid']);
     // 상점아이디
     $iniescrow->SetField("admin", "1111");
     // 키패스워드(상점아이디에 따라 변경)
     $iniescrow->SetField("type", "escrow");
     // 고정 (절대 수정 불가)
     $iniescrow->SetField("escrowtype", "dcnf");
     // 고정 (절대 수정 불가)
     $iniescrow->SetField("dcnf_name", $_POST['dcnf_name']);
     $iniescrow->SetField("debug", "true");
     // 로그모드("true"로 설정하면 상세한 로그가 생성됨)
     $iniescrow->startAction();
     $tid = $iniescrow->GetResult("tid");
     // 거래번호
     $resultCode = $iniescrow->GetResult("ResultCode");
     // 결과코드 ("00"이면 지불 성공)
     $resultMsg = $iniescrow->GetResult("ResultMsg");
     // 결과내용 (지불결과에 대한 설명)
     $resultDate = $iniescrow->GetResult("DCNF_Date");
     // 처리 날짜
     $resultTime = $iniescrow->GetResult("DCNF_Time");
     // 처리 시각
     $postid = $_POST['postid'];
     $orderinfo = new WC_Order($_POST['postid']);
     if ($resultCode == '00') {
         $tmp_settings = get_option('woocommerce_' . $this->id . '_settings', TRUE);
         $refunded_status = $tmp_settings['order_status_after_refund'];
         $orderinfo->update_status($refunded_status);
         //취소처리완료 상태로 변경
         update_post_meta($_POST['post_id'], '`_inicis_escrow_order_cancelled`', TRUE);
         $orderinfo->add_order_note(sprintf(__('에스크로 구매거절을 %s님께서 <font color=blue><strong>확인</strong></font>하였습니다. 에스크로 환불처리 완료하였습니다. 거래번호 : %s, 결과코드 : %s, 처리날짜 : %s, 처리시각 : %s', 'inicis_payment'), $_POST['dcnf_name'], $_POST['tid'], $resultCode, $resultDate, $resultTime));
     } else {
         $orderinfo->add_order_note(sprintf(__('에스크로 구매거절을 %s님께서 <font color=blue><strong>확인실패</strong></font>하였습니다. 에스크로 환불처리를 실패하였습니다. 에러메시지를 확인하세요! 거래번호 : %s, 결과코드 : %s, 에러메시지 : %s, 처리날짜 : %s, 처리시각 : %s', 'inicis_payment'), $_POST['dcnf_name'], $_POST['tid'], $resultCode, mb_convert_encoding($resultMsg, "UTF-8", "EUC-KR"), $resultDate, $resultTime));
         die;
     }
 }
Exemplo n.º 30
-2
/**
 * Mark an order as processing
 *
 * @access public
 * @return void
 */
function woocommerce_mark_order_processing()
{
    if (!is_admin()) {
        die;
    }
    if (!current_user_can('edit_shop_orders')) {
        wp_die(__('You do not have sufficient permissions to access this page.', 'woocommerce'));
    }
    if (!check_admin_referer('woocommerce-mark-order-processing')) {
        wp_die(__('You have taken too long. Please go back and retry.', 'woocommerce'));
    }
    $order_id = isset($_GET['order_id']) && (int) $_GET['order_id'] ? (int) $_GET['order_id'] : '';
    if (!$order_id) {
        die;
    }
    $order = new WC_Order($order_id);
    $order->update_status('processing');
    wp_safe_redirect(wp_get_referer());
}