mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Do not render custom oxxo button in checkout
This commit is contained in:
parent
752d327188
commit
d1c4850c4d
4 changed files with 64 additions and 9 deletions
|
@ -84,9 +84,8 @@ class CheckoutBootstap {
|
|||
const currentPaymentMethod = getCurrentPaymentMethod();
|
||||
const isPaypal = currentPaymentMethod === PaymentMethods.PAYPAL;
|
||||
const isCard = currentPaymentMethod === PaymentMethods.CARDS;
|
||||
const isOXXO = currentPaymentMethod === PaymentMethods.OXXO;
|
||||
const isSavedCard = isCard && isSavedCardSelected();
|
||||
const isNotOurGateway = !isPaypal && !isCard && !isOXXO;
|
||||
const isNotOurGateway = !isPaypal && !isCard;
|
||||
const isFreeTrial = PayPalCommerceGateway.is_free_trial_cart;
|
||||
const hasVaultedPaypal = PayPalCommerceGateway.vaulted_paypal_email !== '';
|
||||
|
||||
|
@ -95,7 +94,6 @@ class CheckoutBootstap {
|
|||
setVisible(this.gateway.button.wrapper, isPaypal && !(isFreeTrial && hasVaultedPaypal));
|
||||
setVisible(this.gateway.messages.wrapper, isPaypal && !isFreeTrial);
|
||||
setVisible(this.gateway.hosted_fields.wrapper, isCard && !isSavedCard);
|
||||
setVisible('#ppcp-oxxo', isOXXO && !isSavedCard && !isPaypal);
|
||||
|
||||
if (isPaypal && !isFreeTrial) {
|
||||
this.messages.render();
|
||||
|
|
|
@ -78,11 +78,20 @@ class OXXO {
|
|||
array( $this, 'register_assets' )
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_review_order_after_payment',
|
||||
function () {
|
||||
echo '<button style="display:none" class="button" id="ppcp-oxxo">Pago en OXXO</button>';
|
||||
add_filter(
|
||||
'woocommerce_thankyou_order_received_text',
|
||||
function( string $message, WC_Order $order ) {
|
||||
$payer_action = $order->get_meta( 'ppcp_oxxo_payer_action' ) ?? '';
|
||||
|
||||
$button = '';
|
||||
if ( $payer_action ) {
|
||||
$button = '<p><a id="ppcp-oxxo-payer-action" class="button" href="' . $payer_action . '" target="_blank">See OXXO Voucher/Ticket</a></p>';
|
||||
}
|
||||
|
||||
return $message . ' ' . $button;
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,6 @@ class OXXOGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
public function process_payment( $order_id ) {
|
||||
$wc_order = wc_get_order( $order_id );
|
||||
$wc_order->update_status( 'on-hold', __( 'Awaiting OXXO payment.', 'woocommerce-paypal-payments' ) );
|
||||
$purchase_unit = $this->purchase_unit_factory->from_wc_order( $wc_order );
|
||||
$payer_action = '';
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ use WP_REST_Response;
|
|||
*/
|
||||
class PaymentCapturePending implements RequestHandler {
|
||||
|
||||
use PrefixTrait;
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*
|
||||
|
@ -74,6 +76,53 @@ class PaymentCapturePending implements RequestHandler {
|
|||
|
||||
$this->logger->info( (string) wc_print_r( $resource, true ) );
|
||||
|
||||
$order_id = isset( $request['resource']['custom_id'] )
|
||||
? $this->sanitize_custom_id( $request['resource']['custom_id'] )
|
||||
: 0;
|
||||
|
||||
if ( ! $order_id ) {
|
||||
$message = sprintf(
|
||||
// translators: %s is the PayPal webhook Id.
|
||||
__(
|
||||
'No order for webhook event %s was found.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
isset( $request['id'] ) ? $request['id'] : ''
|
||||
);
|
||||
$this->logger->log(
|
||||
'warning',
|
||||
$message,
|
||||
array(
|
||||
'request' => $request,
|
||||
)
|
||||
);
|
||||
$response['message'] = $message;
|
||||
return rest_ensure_response( $response );
|
||||
}
|
||||
|
||||
$wc_order = wc_get_order( $order_id );
|
||||
if ( ! is_a( $wc_order, \WC_Order::class ) ) {
|
||||
$message = sprintf(
|
||||
// translators: %s is the PayPal refund Id.
|
||||
__( 'Order for PayPal refund %s not found.', 'woocommerce-paypal-payments' ),
|
||||
isset( $request['resource']['id'] ) ? $request['resource']['id'] : ''
|
||||
);
|
||||
$this->logger->log(
|
||||
'warning',
|
||||
$message,
|
||||
array(
|
||||
'request' => $request,
|
||||
)
|
||||
);
|
||||
$response['message'] = $message;
|
||||
return rest_ensure_response( $response );
|
||||
}
|
||||
|
||||
if ( $wc_order->get_status() === 'pending' ) {
|
||||
$wc_order->update_status('on-hold', __('Payment initiation was successful, and is waiting for the buyer to complete the payment.', 'woocommerce-paypal-payments'));
|
||||
|
||||
}
|
||||
|
||||
$response['success'] = true;
|
||||
return new WP_REST_Response( $response );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue