@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param Config $config Config. |
| 40 | 40 | */ |
| 41 | - public function __construct( Config $config ) { |
|
| 42 | - parent::__construct( $config ); |
|
| 41 | + public function __construct(Config $config) { |
|
| 42 | + parent::__construct($config); |
|
| 43 | 43 | |
| 44 | 44 | $this->supports = array( |
| 45 | 45 | 'payment_status_request', |
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | - $this->set_method( self::METHOD_HTTP_REDIRECT ); |
|
| 48 | + $this->set_method(self::METHOD_HTTP_REDIRECT); |
|
| 49 | 49 | |
| 50 | - $this->client = new Client( $config->merchant_id, $config->merchant_key ); |
|
| 51 | - $this->client->set_test_mode( self::MODE_TEST === $config->mode ); |
|
| 50 | + $this->client = new Client($config->merchant_id, $config->merchant_key); |
|
| 51 | + $this->client->set_test_mode(self::MODE_TEST === $config->mode); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $result = $this->client->get_directory(); |
| 63 | 63 | |
| 64 | - if ( $result ) { |
|
| 64 | + if ($result) { |
|
| 65 | 65 | $groups[] = array( |
| 66 | 66 | 'options' => $result, |
| 67 | 67 | ); |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param Payment $payment Payment. |
| 114 | 114 | */ |
| 115 | - public function start( Payment $payment ) { |
|
| 115 | + public function start(Payment $payment) { |
|
| 116 | 116 | // Order and purchase ID. |
| 117 | 117 | $order_id = $payment->get_order_id(); |
| 118 | - $purchase_id = strval( empty( $order_id ) ? $payment->get_id() : $order_id ); |
|
| 118 | + $purchase_id = strval(empty($order_id) ? $payment->get_id() : $order_id); |
|
| 119 | 119 | |
| 120 | 120 | // Maximum length for purchase ID is 16 characters, otherwise an error will occur: |
| 121 | 121 | // ideal_sisow_error - purchaseid too long (16). |
| 122 | - $purchase_id = substr( $purchase_id, 0, 16 ); |
|
| 122 | + $purchase_id = substr($purchase_id, 0, 16); |
|
| 123 | 123 | |
| 124 | 124 | // New transaction request. |
| 125 | 125 | $request = new TransactionRequest( |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $request->merge_parameters( |
| 131 | 131 | array( |
| 132 | - 'payment' => Methods::transform( $payment->get_method(), $payment->get_method() ), |
|
| 133 | - 'purchaseid' => substr( $purchase_id, 0, 16 ), |
|
| 132 | + 'payment' => Methods::transform($payment->get_method(), $payment->get_method()), |
|
| 133 | + 'purchaseid' => substr($purchase_id, 0, 16), |
|
| 134 | 134 | 'entrancecode' => $payment->get_entrance_code(), |
| 135 | 135 | 'amount' => $payment->get_amount()->get_cents(), |
| 136 | - 'description' => substr( $payment->get_description(), 0, 32 ), |
|
| 137 | - 'testmode' => ( self::MODE_TEST === $this->config->mode ) ? 'true' : 'false', |
|
| 136 | + 'description' => substr($payment->get_description(), 0, 32), |
|
| 137 | + 'testmode' => (self::MODE_TEST === $this->config->mode) ? 'true' : 'false', |
|
| 138 | 138 | 'returnurl' => $payment->get_return_url(), |
| 139 | 139 | 'cancelurl' => $payment->get_return_url(), |
| 140 | 140 | 'notifyurl' => $payment->get_return_url(), |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | // Payment method. |
| 149 | - $this->set_payment_method( null === $payment->get_method() ? PaymentMethods::IDEAL : $payment->get_method() ); |
|
| 149 | + $this->set_payment_method(null === $payment->get_method() ? PaymentMethods::IDEAL : $payment->get_method()); |
|
| 150 | 150 | |
| 151 | 151 | // Additional parameters for payment method. |
| 152 | - if ( PaymentMethods::IDEALQR === $payment->get_method() ) { |
|
| 153 | - $request->set_parameter( 'qrcode', 'true' ); |
|
| 152 | + if (PaymentMethods::IDEALQR === $payment->get_method()) { |
|
| 153 | + $request->set_parameter('qrcode', 'true'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Customer. |
| 157 | - if ( null !== $payment->get_customer() ) { |
|
| 157 | + if (null !== $payment->get_customer()) { |
|
| 158 | 158 | $customer = $payment->get_customer(); |
| 159 | 159 | |
| 160 | 160 | $request->merge_parameters( |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | ) |
| 166 | 166 | ); |
| 167 | 167 | |
| 168 | - if ( null !== $customer->get_birth_date() ) { |
|
| 169 | - $request->set_parameter( 'birth_date', $customer->get_birth_date()->format( 'ddmmYYYY' ) ); |
|
| 168 | + if (null !== $customer->get_birth_date()) { |
|
| 169 | + $request->set_parameter('birth_date', $customer->get_birth_date()->format('ddmmYYYY')); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Billing address. |
| 174 | - if ( null !== $payment->get_billing_address() ) { |
|
| 174 | + if (null !== $payment->get_billing_address()) { |
|
| 175 | 175 | $address = $payment->get_billing_address(); |
| 176 | 176 | |
| 177 | - if ( null !== $address->get_name() ) { |
|
| 177 | + if (null !== $address->get_name()) { |
|
| 178 | 178 | $name = $address->get_name(); |
| 179 | 179 | |
| 180 | 180 | $request->merge_parameters( |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Shipping address. |
| 205 | - if ( null !== $payment->get_shipping_address() ) { |
|
| 205 | + if (null !== $payment->get_shipping_address()) { |
|
| 206 | 206 | $address = $payment->get_shipping_address(); |
| 207 | 207 | |
| 208 | - if ( null !== $address->get_name() ) { |
|
| 208 | + if (null !== $address->get_name()) { |
|
| 209 | 209 | $name = $address->get_name(); |
| 210 | 210 | |
| 211 | 211 | $request->merge_parameters( |
@@ -232,22 +232,22 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Lines. |
| 235 | - if ( null !== $payment->get_lines() ) { |
|
| 235 | + if (null !== $payment->get_lines()) { |
|
| 236 | 236 | $lines = $payment->get_lines(); |
| 237 | 237 | |
| 238 | 238 | $x = 1; |
| 239 | 239 | |
| 240 | - foreach ( $lines as $line ) { |
|
| 241 | - $net_price = ( null === $line->get_unit_price() ) ? null : $line->get_unit_price()->get_cents(); |
|
| 242 | - $total = ( null === $line->get_total_amount() ) ? null : $line->get_total_amount()->get_cents(); |
|
| 243 | - $tax = ( null === $line->get_tax_amount() ) ? null : $line->get_tax_amount()->get_cents(); |
|
| 244 | - $net_total = ( $total - $tax ); |
|
| 240 | + foreach ($lines as $line) { |
|
| 241 | + $net_price = (null === $line->get_unit_price()) ? null : $line->get_unit_price()->get_cents(); |
|
| 242 | + $total = (null === $line->get_total_amount()) ? null : $line->get_total_amount()->get_cents(); |
|
| 243 | + $tax = (null === $line->get_tax_amount()) ? null : $line->get_tax_amount()->get_cents(); |
|
| 244 | + $net_total = ($total - $tax); |
|
| 245 | 245 | |
| 246 | 246 | $product_id = $line->get_id(); |
| 247 | 247 | |
| 248 | - if ( PaymentLineType::SHIPPING === $line->get_type() ) { |
|
| 248 | + if (PaymentLineType::SHIPPING === $line->get_type()) { |
|
| 249 | 249 | $product_id = 'shipping'; |
| 250 | - } elseif ( PaymentLineType::FEE === $line->get_type() ) { |
|
| 250 | + } elseif (PaymentLineType::FEE === $line->get_type()) { |
|
| 251 | 251 | $product_id = 'paymentfee'; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Create transaction. |
| 272 | - $result = $this->client->create_transaction( $request ); |
|
| 272 | + $result = $this->client->create_transaction($request); |
|
| 273 | 273 | |
| 274 | - if ( false !== $result ) { |
|
| 275 | - $payment->set_transaction_id( $result->id ); |
|
| 276 | - $payment->set_action_url( $result->issuer_url ); |
|
| 274 | + if (false !== $result) { |
|
| 275 | + $payment->set_transaction_id($result->id); |
|
| 276 | + $payment->set_action_url($result->issuer_url); |
|
| 277 | 277 | } else { |
| 278 | 278 | $this->error = $this->client->get_error(); |
| 279 | 279 | } |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @param Payment $payment Payment. |
| 286 | 286 | */ |
| 287 | - public function update_status( Payment $payment ) { |
|
| 287 | + public function update_status(Payment $payment) { |
|
| 288 | 288 | $request = new StatusRequest( |
| 289 | 289 | $payment->get_transaction_id(), |
| 290 | 290 | $this->config->merchant_id, |
| 291 | 291 | $this->config->shop_id |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | - $result = $this->client->get_status( $request ); |
|
| 294 | + $result = $this->client->get_status($request); |
|
| 295 | 295 | |
| 296 | - if ( false === $result ) { |
|
| 296 | + if (false === $result) { |
|
| 297 | 297 | $this->error = $this->client->get_error(); |
| 298 | 298 | |
| 299 | 299 | return; |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $transaction = $result; |
| 303 | 303 | |
| 304 | - $payment->set_status( $transaction->status ); |
|
| 305 | - $payment->set_consumer_name( $transaction->consumer_name ); |
|
| 306 | - $payment->set_consumer_account_number( $transaction->consumer_account ); |
|
| 307 | - $payment->set_consumer_city( $transaction->consumer_city ); |
|
| 304 | + $payment->set_status($transaction->status); |
|
| 305 | + $payment->set_consumer_name($transaction->consumer_name); |
|
| 306 | + $payment->set_consumer_account_number($transaction->consumer_account); |
|
| 307 | + $payment->set_consumer_city($transaction->consumer_city); |
|
| 308 | 308 | } |
| 309 | 309 | } |