Skip to content

Commit cd02399

Browse files
authored
Merge pull request #39 from pronamic/38-countrycode-is-now-a-mandatory-configuration-property-set-it-during-the-adyencheckout-initialization
Since Adyen Web v6 the `countryCode` is a mandatory configuration property
2 parents de40bca + f978cb2 commit cd02399

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

js/dist/checkout-drop-in.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => '60ba2b4d744e7a134224');
1+
<?php return array('dependencies' => array(), 'version' => '97fa7bb71b20b207f779');

src/Config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ class Config extends GatewayConfig implements JsonSerializable {
5959
*/
6060
public $client_key;
6161

62+
/**
63+
* Country code.
64+
*
65+
* @var string
66+
*/
67+
public $country_code = '';
68+
6269
/**
6370
* Get API key.
6471
*
@@ -99,6 +106,7 @@ public function jsonSerialize(): object {
99106
'merchant_account' => (string) $this->merchant_account,
100107
'api_key' => (string) $this->api_key,
101108
'client_key' => (string) $this->client_key,
109+
'country_code' => (string) $this->country_code,
102110
];
103111
}
104112
}

src/Gateway.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ public function payment_redirect( Payment $payment ) {
334334
],
335335
'clientKey' => $this->config->client_key,
336336
'amount' => AmountTransformer::transform( $payment->get_total_amount() )->get_json(),
337+
/**
338+
* Country code.
339+
*
340+
* Since Adyen Web v6 the `countryCode` is a mandatory configuration property.
341+
*
342+
* @link https://docs.adyen.com/online-payments/upgrade-your-integration/migrate-to-web-v6
343+
*/
344+
'countryCode' => Util::get_country_code( $payment ) ?? $this->config->country_code,
337345
];
338346

339347
$checkout_configuration = (object) $checkout_configuration;

src/Integration.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ public function get_settings_fields() {
424424
},
425425
];
426426

427+
// Country code.
428+
$fields[] = [
429+
'section' => 'general',
430+
'meta_key' => '_pronamic_gateway_adyen_country_code',
431+
'title' => \__( 'Country code', 'pronamic_ideal' ),
432+
'type' => 'text',
433+
'classes' => [ 'regular-text', 'code' ],
434+
'tooltip' => \__( 'Country code used when it cannot be derived from the customer details.', 'pronamic_ideal' ),
435+
'required' => true,
436+
];
437+
427438
// Return fields.
428439
return $fields;
429440
}
@@ -457,6 +468,7 @@ public function get_config( $post_id ) {
457468
$config->merchant_account = $this->get_meta( $post_id, 'adyen_merchant_account' );
458469
$config->client_key = $this->get_meta( $post_id, 'adyen_client_key' );
459470
$config->merchant_order_reference = $this->get_meta( $post_id, 'adyen_merchant_order_reference' );
471+
$config->country_code = $this->get_meta( $post_id, 'adyen_country_code' );
460472

461473
return $config;
462474
}

0 commit comments

Comments
 (0)