Toont alle 4 resultaten
be shipped/captured.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order already completed at Mollie, can not be shipped/captured.' ); return; } if ( $mollie_order->isPaid() || $mollie_order->isAuthorized() ) { Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->orders->get( $mollie_order_id )->shipAll(); $order->add_order_note( 'Order successfully updated to shipped at Mollie, capture of funds underway.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order successfully updated to shipped at Mollie, capture of funds underway.' ); return; } $order->add_order_note( 'Order not paid or authorized at Mollie yet, can not be shipped.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order not paid or authorized at Mollie yet, can not be shipped.' ); } catch ( Mollie\Api\Exceptions\ApiException $e ) { Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Processing shipment & capture failed, error: ' . $e->getMessage() ); } return; } /** * Cancel an order at Mollie. * */ public static function cancelOrderAtMollie( $order_id ) { $order = wc_get_order( $order_id ); // Does WooCommerce order contain a Mollie payment? if ( strstr( $order->get_payment_method(), 'mollie_wc_gateway_') == FALSE ) { return; } // To disable automatic canceling of the Mollie order when a WooCommerce order status is updated to canceled, // store an option 'mollie-payments-for-woocommerce_disableCancelOrderAtMollie' with value 1 if ( get_option(Mollie_WC_Plugin::PLUGIN_ID . '_' . 'disableCancelOrderAtMollie', '0' ) == '1' ) { return; } Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Try to process cancelled order at Mollie.' ); $mollie_order_id = ( $mollie_order_id = $order->get_meta( '_mollie_order_id', true ) ) ? $mollie_order_id : false; if ( $mollie_order_id == false ) { $order->add_order_note( 'Order contains Mollie payment method, but not a valid Mollie Order ID. Canceling order failed.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order contains Mollie payment method, but not a valid Mollie Order ID. Canceling order failed.' ); return; } // Is test mode enabled? $test_mode = mollieWooCommerceIsTestModeEnabled(); try { // Get the order from the Mollie API $mollie_order = Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->orders->get( $mollie_order_id ); // Check that order is not already canceled at Mollie if ( $mollie_order->isCanceled() ) { $order->add_order_note( 'Order already canceled at Mollie, can not be canceled again.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order already canceled at Mollie, can not be canceled again.' ); return; } // Check that order has the correct status to be canceled if ( $mollie_order->isCreated() || $mollie_order->isAuthorized() || $mollie_order->isShipping() ) { Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->orders->get( $mollie_order_id )->cancel(); $order->add_order_note( 'Order also cancelled at Mollie.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order cancelled in WooCommerce, also cancelled at Mollie.' ); return; } $order->add_order_note( 'Order could not be canceled at Mollie, because order status is ' . $mollie_order->status . '.' ); Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Order could not be canceled at Mollie, because order status is ' . $mollie_order->status . '.' ); } catch ( Mollie\Api\Exceptions\ApiException $e ) { Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Updating order to canceled at Mollie failed, error: ' . $e->getMessage() ); } return; } /** * Don't show SEPA Direct Debit in WooCommerce Checkout */ public static function disableSEPAInCheckout( $available_gateways ) { if ( is_checkout() ) { unset( $available_gateways['mollie_wc_gateway_directdebit'] ); } return $available_gateways; } /** * Don't show old MisterCash in WooCommerce Checkout */ public static function disableMisterCashInCheckout( $available_gateways ) { if ( is_checkout() ) { unset( $available_gateways['mollie_wc_gateway_mistercash'] ); } return $available_gateways; } /** * Don't show Mollie Payment Methods in WooCommerce Account > Subscriptions */ public static function disableMollieOnPaymentMethodChange( $available_gateways ) { // Can't use $wp->request or is_wc_endpoint_url() to check if this code only runs on /subscriptions and /view-subscriptions, // because slugs/endpoints can be translated (with WPML) and other plugins. // So disabling on is_account_page (if not checkout, bug in WC) and $_GET['change_payment_method'] for now. // Only disable payment methods if WooCommerce Subscriptions is installed if ( class_exists( 'WC_Subscription' ) ) { // Do not disable if account page is also checkout (workaround for bug in WC), do disable on change payment method page (param) if ( ( ! is_checkout() && is_account_page() ) || ! empty( $_GET['change_payment_method'] ) ) { foreach ( $available_gateways as $key => $value ) { if ( strpos( $key, 'mollie_' ) !== false ) { unset( $available_gateways[ $key ] ); } } } } return $available_gateways; } /** * If an order is paid with another payment method (gateway) after a first payment was * placed with Mollie, set a flag, so status updates (like expired) aren't processed by * Mollie Payments for WooCommerce. */ public static function setOrderPaidByOtherGateway( $order_id ) { $order = wc_get_order( $order_id ); $mollie_payment_id = $order->get_meta( '_mollie_payment_id', $single = true ); $order_payment_method = $order->get_payment_method(); if ( $mollie_payment_id !== '' && ( strpos( $order_payment_method, 'mollie' ) === false ) ) { $order->update_meta_data( '_mollie_paid_by_other_gateway', '1' ); $order->save(); } return true; } private static function extractRemoteItemsIds(array $data) { if (empty($data['lines'])) { return []; } return implode(',', wp_list_pluck($data['lines'], 'id')); } }
Toont alle 4 resultaten