Add update status note for capture denied

This commit is contained in:
dinamiko 2022-07-20 11:37:28 +02:00
parent 51001c388e
commit e1cd7d5ad1
3 changed files with 16 additions and 9 deletions

View file

@ -5,8 +5,8 @@ document.addEventListener(
if(data.payer_action && data.payer_action !== '') {
const width = screen.width / 2;
const height = screen.height / 2;
const left = (screen.width / 2) - (width / 2);
const top = (screen.height / 2) - (height / 2);
const left = width - (width / 2);
const top = height - (height / 2);
window.open(
data.payer_action,
'_blank',

View file

@ -113,14 +113,16 @@ class OXXO {
);
add_filter(
'woocommerce_available_payment_gateways',
function( $available_gateways ) {
if ( array_key_exists( OXXOGateway::ID, $available_gateways ) ) {
$available_gateways[ OXXOGateway::ID ]->order_button_text = __( 'Pay with OXXO', 'woocommerce-paypal-payments' );
'ppcp_payment_capture_reversed_webhook_update_status_note',
function( $note, $wc_order, $event_type ) {
if ( $wc_order->get_payment_method() === OXXOGateway::ID && $event_type === 'PAYMENT.CAPTURE.DENIED' ) {
$note = __( 'OXXO voucher has expired or the buyer didn\'t complete the payment successfully.', 'woocommerce-paypal-payments' );
}
return $available_gateways;
}
return $note;
},
10,
2
);
}

View file

@ -112,12 +112,17 @@ class PaymentCaptureReversed implements RequestHandler {
return rest_ensure_response( $response );
}
/**
* Allows adding an update status note.
*/
$note = apply_filters( 'ppcp_payment_capture_reversed_webhook_update_status_note', '', $wc_order, $request['event_type'] );
/**
* The WooCommerce order.
*
* @var \WC_Order $wc_order
*/
$response['success'] = (bool) $wc_order->update_status( 'cancelled' );
$response['success'] = (bool) $wc_order->update_status( 'cancelled', $note );
$message = $response['success'] ? sprintf(
// translators: %1$s is the order id.