-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCardSuccess.php
More file actions
55 lines (49 loc) · 1.85 KB
/
Copy pathCardSuccess.php
File metadata and controls
55 lines (49 loc) · 1.85 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
<?php
/**
* Paytrail for WooCommerce payment Card success controller class
*/
namespace Paytrail\WooCommercePaymentGateway\Controllers;
use Paytrail\SDK\Exception\HmacException;
use Paytrail\SDK\Exception\ValidationException;
use Paytrail\WooCommercePaymentGateway\Gateway;
class CardSuccess extends AbstractController {
protected function checkout() {
$gateway = new Gateway();
try {
$gateway->process_card_token();
wc_add_notice(__('Card was added successfully', 'paytrail-for-woocommerce'), 'success');
} catch (HmacException $e) {
wc_add_notice(__('Could not add card details', 'paytrail-for-woocommerce'), 'error');
} catch (ValidationException $e) {
wc_add_notice(__('Could not add card details', 'paytrail-for-woocommerce'), 'error');
}
wp_safe_redirect(wc_get_checkout_url());
exit;
}
protected function my_account() {
$gateway = new Gateway();
try {
$gateway->process_card_token();
wc_add_notice(__('Card was added successfully', 'paytrail-for-woocommerce'), 'success');
} catch (HmacException $e) {
wc_add_notice(__('Could not add card details', 'paytrail-for-woocommerce'), 'error');
} catch (ValidationException $e) {
wc_add_notice(__('Could not add card details', 'paytrail-for-woocommerce'), 'error');
}
wp_safe_redirect(wc_get_account_endpoint_url('payment-methods'));
exit;
}
protected function change_payment_method() {
$gateway = new Gateway();
try {
$gateway->process_card_token();
wc_add_notice(__('Card was added successfully', 'paytrail-for-woocommerce'), 'success');
} catch (HmacException $e) {
wc_add_notice(__('Could not add card details', 'paytrail-for-woocommerce'), 'error');
} catch (ValidationException $e) {
wc_add_notice(__('Could not add card details', 'paytrail-for-woocommerce'), 'error');
}
wp_safe_redirect(wc_get_account_endpoint_url('subscriptions'));
exit;
}
}