wp-pay-gateways /
targetpay
| 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-2019 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; |
||||
|
0 ignored issues
–
show
|
|||||
| 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, |
||||
|
0 ignored issues
–
show
false of type false is incompatible with the type string expected by parameter $once of Pronamic\WordPress\Pay\G...\Client::check_status().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 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 ); |
||||
| 125 | $payment->set_consumer_account_number( $status->account_number ); |
||||
| 126 | $payment->set_consumer_city( $status->account_city ); |
||||
| 127 | } |
||||
| 128 | } |
||||
| 129 | } |
||||
| 130 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.