class-wc-payments-email-failed-authentication-retry.php
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Admin email about payment retry failed due to authentication
*
* Email sent to admins when an attempt to automatically process a subscription renewal payment has failed
* with the `authentication_needed` error, and a retry rule has been applied to retry the payment in the future.
*
* @extends WC_Email_Failed_Order
* @package WooCommerce\Payments
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* An email sent to the admin when payment fails to go through due to authentication_required error.
*/
class WC_Payments_Email_Failed_Authentication_Retry extends WC_Email_Failed_Order {
/**
* Constructor
*/
public function __construct() {
$this->id = 'failed_authentication_requested';
$this->title = __( 'Payment authentication requested email', 'woocommerce-payments' );
$this->description = __( 'Payment authentication requested emails are sent to chosen recipient(s) when an attempt to automatically process a subscription renewal payment fails because the transaction requires an SCA verification, the customer is requested to authenticate the payment, and a retry rule has been applied to notify the customer again within a certain time period.', 'woocommerce-payments' );
$this->heading = __( 'Automatic renewal payment failed due to authentication required', 'woocommerce-payments' );
$this->subject = __( '[{site_title}] Automatic payment failed for {order_number}. Customer asked to authenticate payment and will be notified again {retry_time}', 'woocommerce-payments' );
$this->template_html = 'failed-renewal-authentication-requested.php';
$this->template_plain = 'plain/failed-renewal-authentication-requested.php';
$this->template_base = __DIR__ . '/emails/';
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
// We want all the parent's methods, with none of its properties, so call its parent's constructor, rather than my parent constructor.
WC_Email::__construct();
}
/**
* Get the default e-mail subject.
*
* @return string
*/
public function get_default_subject() {
return $this->subject;
}
/**
* Get the default e-mail heading.
*
* @return string
*/
public function get_default_heading() {
return $this->heading;
}
/**
* Trigger.
*
* @param int $order_id The order ID.
* @param WC_Order|null $order Order object.
*/
public function trigger( $order_id, $order = null ) {
$this->object = $order;
$this->find['retry-time'] = '{retry_time}';
if ( class_exists( 'WCS_Retry_Manager' ) && function_exists( 'wcs_get_human_time_diff' ) ) {
$this->retry = WCS_Retry_Manager::store()->get_last_retry_for_order( wcs_get_objects_property( $order, 'id' ) );
$this->replace['retry-time'] = wcs_get_human_time_diff( $this->retry->get_time() );
} else {
WC_Stripe_Logger::log( 'WCS_Retry_Manager class or does not exist. Not able to send admin email about customer notification for authentication required for renewal payment.' );
return;
}
$this->find['order-number'] = '{order_number}';
$this->replace['order-number'] = $this->object->get_order_number();
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
return;
}
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
/**
* Get content html.
*
* @return string
*/
public function get_content_html() {
return wc_get_template_html(
$this->template_html,
[
'order' => $this->object,
'retry' => $this->retry,
'email_heading' => $this->get_heading(),
'sent_to_admin' => true,
'plain_text' => false,
'email' => $this,
],
'',
$this->template_base
);
}
/**
* Get content plain.
*
* @return string
*/
public function get_content_plain() {
return wc_get_template_html(
$this->template_plain,
[
'order' => $this->object,
'retry' => $this->retry,
'email_heading' => $this->get_heading(),
'sent_to_admin' => true,
'plain_text' => true,
'email' => $this,
],
'',
$this->template_base
);
}
}