blob: 074f80ea5e8df77822e5ebc0d804df315157b6d5 [file] [log] [blame]
swissChilif0cbdc32023-01-05 17:21:38 -05001<?php
2if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4}
5
6/**
7 * OXXO Payment Method class extending UPE base class
8 */
9class WC_Stripe_UPE_Payment_Method_Oxxo extends WC_Stripe_UPE_Payment_Method {
10
11 const STRIPE_ID = 'oxxo';
12
13 const LPM_GATEWAY_CLASS = WC_Gateway_Stripe_Oxxo::class;
14
15 /**
16 * Constructor for OXXO payment method
17 *
18 * @since 5.8.0
19 */
20 public function __construct() {
21 parent::__construct();
22 $this->stripe_id = self::STRIPE_ID;
23 $this->can_refund = false;
24 $this->title = 'Pay with OXXO';
25 $this->is_reusable = false;
26 $this->supported_currencies = [ 'MXN' ];
27 $this->supported_countries = [ 'MX' ];
28 $this->label = __( 'OXXO', 'woocommerce-gateway-stripe' );
29 $this->description = __(
30 'OXXO is a Mexican chain of convenience stores that allows customers to pay bills and online purchases in-store with cash.',
31 'woocommerce-gateway-stripe'
32 );
33
34 add_filter( 'wc_stripe_allowed_payment_processing_statuses', [ $this, 'add_allowed_payment_processing_statuses' ], 10, 2 );
35 }
36
37 /**
38 * Adds on-hold as accepted status during webhook handling on orders paid with OXXO
39 *
40 * @param $allowed_statuses
41 * @param $order
42 *
43 * @return mixed
44 */
45 public function add_allowed_payment_processing_statuses( $allowed_statuses, $order ) {
46 if ( 'oxxo' === $order->get_meta( '_stripe_upe_payment_type' ) && ! in_array( 'on-hold', $allowed_statuses ) ) {
47 $allowed_statuses[] = 'on-hold';
48 }
49
50 return $allowed_statuses;
51 }
52}