Completed
Push — develop ( 3e5c71...511324 )
by Remco
03:23
created

Gateway   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 24
dl 0
loc 62
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_output_html() 0 2 1
A __construct() 0 13 1
A start() 0 13 1
1
<?php
2
/**
3
 * Gateway
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Adyen
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
14
use Pronamic\WordPress\Pay\Core\PaymentMethods;
15
use Pronamic\WordPress\Pay\Payments\Payment;
16
17
/**
18
 * Gateway
19
 *
20
 * @author  Remco Tolsma
21
 * @version 2.0.0
22
 * @since   1.0.0
23
 * @link    https://github.com/adyenpayments/php/blob/master/generatepaymentform.php
24
 */
25
class Gateway extends Core_Gateway {
26
	/**
27
	 * Slug of this gateway
28
	 *
29
	 * @var string
30
	 */
31
	const SLUG = 'adyen';
32
33
	/////////////////////////////////////////////////
34
35
	/**
36
	 * Constructs and initializes an InternetKassa gateway
37
	 *
38
	 * @param Pronamic_WP_Pay_GatewayConfig $config
39
	 */
40
	public function __construct( Pronamic_WP_Pay_GatewayConfig $config ) {
0 ignored issues
show
Bug introduced by
The type Pronamic\WordPress\Pay\G...ic_WP_Pay_GatewayConfig was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
		parent::__construct( $config );
42
43
		$this->set_method( self::METHOD_HTML_FORM );
44
		$this->set_has_feedback( true );
0 ignored issues
show
Deprecated Code introduced by
The function Pronamic\WordPress\Pay\C...way::set_has_feedback() has been deprecated: 2.0.5 Not in use anymore. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

44
		/** @scrutinizer ignore-deprecated */ $this->set_has_feedback( true );

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...
45
		$this->set_amount_minimum( 0.01 );
0 ignored issues
show
Deprecated Code introduced by
The function Pronamic\WordPress\Pay\C...y::set_amount_minimum() has been deprecated: 2.0.5 Not in use anymore. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

45
		/** @scrutinizer ignore-deprecated */ $this->set_amount_minimum( 0.01 );

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...
46
		$this->set_slug( self::SLUG );
47
48
		$this->client = new Adyen();
0 ignored issues
show
Bug Best Practice introduced by
The property client does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
49
		$this->client->set_payment_server_url( $config->getPaymentServerUrl() );
50
		$this->client->set_skin_code( $config->get_buckaroo_skin_code() );
51
		$this->client->set_merchant_account( $config->get_buckaroo_merchant_account() );
52
		$this->client->set_shared_secret( $config->get_buckaroo_shared_secret() );
53
	}
54
55
	/////////////////////////////////////////////////
56
57
	/**
58
	 * Start
59
	 *
60
	 * @param Pronamic_Pay_Payment $payment
61
	 * @see Pronamic_WP_Pay_Gateway::start()
62
	 */
63
	public function start( Pronamic_Pay_Payment $payment ) {
0 ignored issues
show
Bug introduced by
The type Pronamic\WordPress\Pay\G...en\Pronamic_Pay_Payment was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
64
		$payment->set_transaction_id( md5( time() . $payment->get_order_id() ) );
65
		$payment->set_action_url( $this->client->get_payment_server_url() );
66
67
		$this->client->set_merchant_reference( $payment->get_order_id() );
68
		$this->client->set_payment_amount( $payment->get_amount() );
69
		$this->client->set_currency_code( $payment->get_currency() );
70
		$this->client->set_ship_before_date( new DateTime( '+5 days' ) );
0 ignored issues
show
Bug introduced by
The type Pronamic\WordPress\Pay\Gateways\Adyen\DateTime was not found. Did you mean DateTime? If so, make sure to prefix the type with \.
Loading history...
71
		$this->client->set_shopper_locale( $payment->get_locale() );
72
		$this->client->set_order_data( $payment->get_description() );
73
		$this->client->set_session_validity( new DateTime( '+1 hour' ) );
74
		$this->client->set_shopper_reference( $payment->get_email() );
75
		$this->client->set_shopper_email( $payment->get_email() );
76
	}
77
78
	/////////////////////////////////////////////////
79
80
	/**
81
	 * Get output HTML
82
	 *
83
	 * @see Pronamic_WP_Pay_Gateway::get_output_html()
84
	 */
85
	public function get_output_html() {
86
		return $this->client->get_html_fields();
87
	}
88
}
89