| Conditions | 9 |
| Paths | 28 |
| Total Lines | 92 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 73 | public function start( Payment $payment ) { |
||
| 74 | $transaction_reference = $payment->get_meta( 'omnikassa_transaction_reference' ); |
||
| 75 | |||
| 76 | if ( empty( $transaction_reference ) ) { |
||
| 77 | $transaction_reference = md5( uniqid( '', true ) ); |
||
| 78 | |||
| 79 | $payment->set_meta( 'omnikassa_transaction_reference', $transaction_reference ); |
||
| 80 | } |
||
| 81 | |||
| 82 | $payment->set_transaction_id( $transaction_reference ); |
||
| 83 | $payment->set_action_url( $this->client->get_action_url() ); |
||
| 84 | |||
| 85 | $language = null; |
||
| 86 | |||
| 87 | if ( null !== $payment->get_customer() ) { |
||
| 88 | $language = $payment->get_customer()->get_language(); |
||
| 89 | } |
||
| 90 | |||
| 91 | $this->client->set_customer_language( LocaleHelper::transform( $language ) ); |
||
| 92 | $this->client->set_currency_numeric_code( $payment->get_total_amount()->get_currency()->get_numeric_code() ); |
||
| 93 | $this->client->set_order_id( $payment->format_string( $this->config->order_id ) ); |
||
| 94 | $this->client->set_normal_return_url( home_url( '/' ) ); |
||
|
|
|||
| 95 | $this->client->set_automatic_response_url( home_url( '/' ) ); |
||
| 96 | $this->client->set_amount( $payment->get_total_amount()->get_cents() ); |
||
| 97 | $this->client->set_transaction_reference( $transaction_reference ); |
||
| 98 | |||
| 99 | switch ( $payment->get_method() ) { |
||
| 100 | /* |
||
| 101 | * If this field is not supplied in the payment request, then |
||
| 102 | * by default the customer will be redirected to the Rabo |
||
| 103 | * OmniKassa payment page. On the payment page, the |
||
| 104 | * customer can choose from the payment methods |
||
| 105 | * offered by the Rabo OmniKassa. These are the payment |
||
| 106 | * methods: IDEAL, VISA, MASTERCARD, |
||
| 107 | * MAESTRO, V PAY and BCMC. |
||
| 108 | * |
||
| 109 | * Exception: the register services INCASSO (direct debit), |
||
| 110 | * ACCEPTGIRO (giro collection form) and REMBOURS |
||
| 111 | * (cash on delivery) are not displayed on the Rabo |
||
| 112 | * OmniKassa payment page by default. |
||
| 113 | * If you wish to offer these register services to the |
||
| 114 | * customer on the payment page, then you need to |
||
| 115 | * always populate the paymentMeanBrandList field with |
||
| 116 | * all the payment methods you wish to offer (provided |
||
| 117 | * these have been requested and activated): IDEAL, |
||
| 118 | * VISA, MASTERCARD, MAESTRO, VPAY, BCMC, |
||
| 119 | * INCASSO, ACCEPTGIRO, REMBOURS. |
||
| 120 | * |
||
| 121 | * If you let the customer choose the payment method |
||
| 122 | * while still in your webshop, then you must populate |
||
| 123 | * this field of the payment request with only the selected |
||
| 124 | * payment method. Populating this field with only one |
||
| 125 | * payment method will instruct the Rabo OmniKassa to |
||
| 126 | * redirect the customer directly to the payment page for |
||
| 127 | * this payment method. |
||
| 128 | */ |
||
| 129 | case PaymentMethods::BANCONTACT: |
||
| 130 | case PaymentMethods::MISTER_CASH: |
||
| 131 | $this->client->add_payment_mean_brand( Methods::BCMC ); |
||
| 132 | |||
| 133 | break; |
||
| 134 | case PaymentMethods::CREDIT_CARD: |
||
| 135 | $this->client->add_payment_mean_brand( Methods::MAESTRO ); |
||
| 136 | $this->client->add_payment_mean_brand( Methods::MASTERCARD ); |
||
| 137 | $this->client->add_payment_mean_brand( Methods::VISA ); |
||
| 138 | $this->client->add_payment_mean_brand( Methods::VPAY ); |
||
| 139 | |||
| 140 | break; |
||
| 141 | case PaymentMethods::DIRECT_DEBIT: |
||
| 142 | $this->client->add_payment_mean_brand( Methods::INCASSO ); |
||
| 143 | |||
| 144 | break; |
||
| 145 | case PaymentMethods::MAESTRO: |
||
| 146 | $this->client->add_payment_mean_brand( Methods::MAESTRO ); |
||
| 147 | |||
| 148 | break; |
||
| 149 | case PaymentMethods::IDEAL: |
||
| 150 | $this->client->add_payment_mean_brand( Methods::IDEAL ); |
||
| 151 | |||
| 152 | break; |
||
| 153 | default: |
||
| 154 | $this->client->add_payment_mean_brand( Methods::IDEAL ); |
||
| 155 | $this->client->add_payment_mean_brand( Methods::VISA ); |
||
| 156 | $this->client->add_payment_mean_brand( Methods::MASTERCARD ); |
||
| 157 | $this->client->add_payment_mean_brand( Methods::MAESTRO ); |
||
| 158 | $this->client->add_payment_mean_brand( Methods::VPAY ); |
||
| 159 | $this->client->add_payment_mean_brand( Methods::BCMC ); |
||
| 160 | $this->client->add_payment_mean_brand( Methods::INCASSO ); |
||
| 161 | $this->client->add_payment_mean_brand( Methods::ACCEPTGIRO ); |
||
| 162 | $this->client->add_payment_mean_brand( Methods::REMBOURS ); |
||
| 163 | |||
| 164 | break; |
||
| 165 | } |
||
| 237 |