PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / classes / order-status / payment-failed.php

payment-failed.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/classes/order-status/payment-failed.php

69 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Classes\OrderStatus;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use StoreEngine\Classes\Exceptions\StoreEngineInvalidArgumentException;
10 use StoreEngine\Classes\OrderContext;
11 use StoreEngine\Interfaces\OrderStatus;
12
13 class PaymentFailed implements OrderStatus {
14 const STATUS = 'payment_failed';
15
16 public function proceed_to_next_status( OrderContext $context, string $trigger = '' ) {
17 switch ( $trigger ) {
18 case 'hold_order':
19 $context->set_order_status( new OnHold() );
20 break;
21 case 'process_order':
22 $context->set_order_status( new Processing() );
23 break;
24 case 'confirm_payment':
25 $context->set_order_status( new PaymentConfirmed() );
26 break;
27 case 'cancel_payment':
28 $context->set_order_status( new Cancelled() );
29 break;
30 default:
31 throw new StoreEngineInvalidArgumentException(
32 sprintf(
33 /* translators: %1$s. Requested status transition, %2$s. Current Status */
34 esc_html__( 'Invalid trigger (%1$s) for next status from %2$s', 'storeengine' ),
35 esc_html( self::STATUS ),
36 esc_html( $trigger )
37 ),
38 'invalid-trigger'
39 );
40 }
41 }
42
43 public function get_status(): string {
44 return self::STATUS;
45 }
46
47 public function get_status_title(): string {
48 return __( 'Payment Failed', 'storeengine' );
49 }
50
51 public function get_possible_next_statuses(): array {
52 return [
53 PaymentConfirmed::STATUS,
54 Cancelled::STATUS,
55 OnHold::STATUS,
56 Processing::STATUS,
57 ];
58 }
59
60 public function get_possible_triggers(): array {
61 return [
62 'confirm_payment',
63 'cancel_payment',
64 'hold_order',
65 'process_order',
66 ];
67 }
68 }
69