|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
|
4
|
|
|
|
|
5
|
|
|
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Title: Mollie integration |
|
9
|
|
|
* Description: |
|
10
|
|
|
* Copyright: Copyright (c) 2005 - 2018 |
|
11
|
|
|
* Company: Pronamic |
|
12
|
|
|
* |
|
13
|
|
|
* @author Remco Tolsma |
|
14
|
|
|
* @version 2.0.0 |
|
15
|
|
|
* @since 1.0.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class Integration extends AbstractIntegration { |
|
18
|
|
|
/** |
|
19
|
|
|
* Dashboard URL. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
public $dashboard_url = 'http://www.mollie.nl/beheer/'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Construct and intialize Mollie integration. |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct() { |
|
29
|
|
|
$this->id = 'mollie'; |
|
30
|
|
|
$this->name = 'Mollie'; |
|
31
|
|
|
$this->url = 'http://www.mollie.com/en/'; |
|
32
|
|
|
$this->product_url = __( 'https://www.mollie.com/en/pricing', 'pronamic_ideal' ); |
|
|
|
|
|
|
33
|
|
|
$this->provider = 'mollie'; |
|
34
|
|
|
|
|
35
|
|
|
// Actions |
|
36
|
|
|
$function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
37
|
|
|
|
|
38
|
|
|
if ( ! has_action( 'wp_loaded', $function ) ) { |
|
|
|
|
|
|
39
|
|
|
add_action( 'wp_loaded', $function ); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if ( is_admin() ) { |
|
|
|
|
|
|
43
|
|
|
$function = array( __CLASS__, 'user_profile' ); |
|
44
|
|
|
|
|
45
|
|
|
if ( ! has_action( 'show_user_profile', $function ) ) { |
|
46
|
|
|
add_action( 'show_user_profile', $function ); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if ( ! has_action( 'edit_user_profile', $function ) ) { |
|
50
|
|
|
add_action( 'edit_user_profile', $function ); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
add_filter( 'pronamic_payment_provider_url_mollie', array( $this, 'payment_provider_url' ), 10, 2 ); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function get_config_factory_class() { |
|
58
|
|
|
return __NAMESPACE__ . '\ConfigFactory'; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function get_settings_class() { |
|
62
|
|
|
return __NAMESPACE__ . '\Settings'; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get required settings for this integration. |
|
67
|
|
|
* |
|
68
|
|
|
* @see https://github.com/wp-premium/gravityforms/blob/1.9.16/includes/fields/class-gf-field-multiselect.php#L21-L42 |
|
69
|
|
|
* @since 1.1.3 |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
public function get_settings() { |
|
73
|
|
|
$settings = parent::get_settings(); |
|
74
|
|
|
|
|
75
|
|
|
$settings[] = 'mollie'; |
|
76
|
|
|
|
|
77
|
|
|
return $settings; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* User profile. |
|
82
|
|
|
* |
|
83
|
|
|
* @since 1.1.6 |
|
84
|
|
|
* @see https://github.com/WordPress/WordPress/blob/4.5.2/wp-admin/user-edit.php#L578-L600 |
|
85
|
|
|
*/ |
|
86
|
|
|
public static function user_profile( $user ) { |
|
87
|
|
|
include dirname( __FILE__ ) . '/../views/html-admin-user-profile.php'; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Payment provider URL. |
|
92
|
|
|
* |
|
93
|
|
|
* @param string $url |
|
94
|
|
|
* @param Payment $payment |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
|
|
public function payment_provider_url( $url, $payment ) { |
|
98
|
|
|
return sprintf( |
|
99
|
|
|
'https://www.mollie.com/dashboard/payments/%s', |
|
100
|
|
|
$payment->get_transaction_id() |
|
101
|
|
|
); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|