1 | <?php |
||||
2 | |||||
3 | namespace Pronamic\WordPress\Pay\Gateways\TargetPay; |
||||
4 | |||||
5 | use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway; |
||||
6 | use Pronamic\WordPress\Pay\Core\PaymentMethods; |
||||
7 | use Pronamic\WordPress\Pay\Payments\Payment; |
||||
8 | |||||
9 | /** |
||||
10 | * Title: TargetPay gateway |
||||
11 | * Description: |
||||
12 | * Copyright: 2005-2020 Pronamic |
||||
13 | * Company: Pronamic |
||||
14 | * |
||||
15 | * @author Remco Tolsma |
||||
16 | * @version 2.0.3 |
||||
17 | * @since 1.0.0 |
||||
18 | */ |
||||
19 | class Gateway extends Core_Gateway { |
||||
20 | /** |
||||
21 | * Client. |
||||
22 | * |
||||
23 | * @var Client |
||||
24 | */ |
||||
25 | protected $client; |
||||
26 | |||||
27 | /** |
||||
28 | * Constructs and initializes an TargetPay gateway |
||||
29 | * |
||||
30 | * @param Config $config Config. |
||||
31 | */ |
||||
32 | public function __construct( Config $config ) { |
||||
33 | parent::__construct( $config ); |
||||
34 | |||||
35 | $this->set_method( self::METHOD_HTTP_REDIRECT ); |
||||
36 | |||||
37 | // Supported features. |
||||
38 | $this->supports = array( |
||||
39 | 'payment_status_request', |
||||
40 | ); |
||||
41 | |||||
42 | // Client. |
||||
43 | $this->client = new Client(); |
||||
44 | } |
||||
45 | |||||
46 | /** |
||||
47 | * Get issuers |
||||
48 | * |
||||
49 | * @see Pronamic_WP_Pay_Gateway::get_issuers() |
||||
50 | */ |
||||
51 | public function get_issuers() { |
||||
52 | $groups = array(); |
||||
53 | |||||
54 | $result = $this->client->get_issuers(); |
||||
55 | |||||
56 | if ( $result ) { |
||||
57 | $groups[] = array( |
||||
58 | 'options' => $result, |
||||
59 | ); |
||||
60 | } |
||||
61 | |||||
62 | return $groups; |
||||
63 | } |
||||
64 | |||||
65 | /** |
||||
66 | * Get supported payment methods |
||||
67 | * |
||||
68 | * @see Pronamic_WP_Pay_Gateway::get_supported_payment_methods() |
||||
69 | */ |
||||
70 | public function get_supported_payment_methods() { |
||||
71 | return array( |
||||
72 | PaymentMethods::IDEAL, |
||||
73 | ); |
||||
74 | } |
||||
75 | |||||
76 | /** |
||||
77 | * Start |
||||
78 | * |
||||
79 | * @see Core_Gateway::start() |
||||
80 | * |
||||
81 | * @param Payment $payment Payment. |
||||
82 | */ |
||||
83 | public function start( Payment $payment ) { |
||||
84 | $parameters = new IDealStartParameters(); |
||||
85 | $parameters->rtlo = $this->config->layoutcode; |
||||
86 | $parameters->bank = $payment->get_issuer(); |
||||
87 | $parameters->description = $payment->get_description(); |
||||
88 | $parameters->amount = $payment->get_total_amount()->get_cents(); |
||||
89 | $parameters->return_url = $payment->get_return_url(); |
||||
90 | $parameters->report_url = $payment->get_return_url(); |
||||
91 | $parameters->cinfo_in_callback = 1; |
||||
92 | |||||
93 | $result = $this->client->start_transaction( $parameters ); |
||||
94 | |||||
95 | if ( $result ) { |
||||
96 | $payment->set_action_url( $result->url ); |
||||
97 | $payment->set_transaction_id( $result->transaction_id ); |
||||
98 | } |
||||
99 | } |
||||
100 | |||||
101 | /** |
||||
102 | * Update status of the specified payment |
||||
103 | * |
||||
104 | * @param Payment $payment Payment. |
||||
105 | */ |
||||
106 | public function update_status( Payment $payment ) { |
||||
107 | // Get transaction status. |
||||
108 | $status = $this->client->check_status( |
||||
109 | $this->config->layoutcode, |
||||
110 | $payment->get_transaction_id(), |
||||
111 | false, |
||||
112 | self::MODE_TEST === $this->config->mode |
||||
113 | ); |
||||
114 | |||||
115 | if ( ! $status ) { |
||||
116 | return; |
||||
117 | } |
||||
118 | |||||
119 | // Update payment status. |
||||
120 | $payment->set_status( Statuses::transform( $status->code ) ); |
||||
121 | |||||
122 | // Set payment consumer details. |
||||
123 | if ( Statuses::OK === $status->code ) { |
||||
124 | $payment->set_consumer_name( $status->account_name ); |
||||
0 ignored issues
–
show
|
|||||
125 | $payment->set_consumer_account_number( $status->account_number ); |
||||
0 ignored issues
–
show
The function
Pronamic\WordPress\Pay\P...nsumer_account_number() has been deprecated: 2.2.6 Use Payment::set_consumer_bank_details()->set_account_number() instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||
126 | $payment->set_consumer_city( $status->account_city ); |
||||
0 ignored issues
–
show
The function
Pronamic\WordPress\Pay\P...fo::set_consumer_city() has been deprecated: 2.2.6 Use Payment::set_consumer_bank_details()->set_city() instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||
127 | } |
||||
128 | } |
||||
129 | } |
||||
130 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.