Skip to content

Commit bb267aa

Browse files
authored
Merge pull request #16 from pronamic/15-add-trustly-payment-method
Add Trustly payment method.
2 parents d076320 + abd4266 commit bb267aa

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"phpmd/phpmd": "^2.7",
5555
"phpstan/phpstan": "^1.11",
5656
"pronamic/pronamic-cli": "^1.0",
57-
"pronamic/wp-coding-standards": "^1.3",
57+
"pronamic/wp-coding-standards": "^2.4",
5858
"roots/wordpress": "^6.0",
5959
"szepeviktor/phpstan-wordpress": "^1.3",
6060
"vimeo/psalm": "^5.25",

src/Gateway.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function __construct( Config $config ) {
6363
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::MASTERCARD ) );
6464
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::PAYPAL ) );
6565
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::SOFORT ) );
66+
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::TRUSTLY ) );
6667
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::V_PAY ) );
6768
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::VISA ) );
6869
}
@@ -475,6 +476,36 @@ public function start( Payment $payment ) {
475476

476477
break;
477478
/**
479+
* Payment method Trustly.
480+
*
481+
* @link https://dev.buckaroo.nl/PaymentMethods/Description/trustly#pay
482+
*/
483+
case Core_PaymentMethods::TRUSTLY:
484+
$data->Services->ServiceList[] = (object) [
485+
'Action' => 'Pay',
486+
'Name' => 'Trustly',
487+
'Parameters' => [
488+
(object) [
489+
'Name' => 'CustomerFirstName',
490+
'Value' => $customer?->get_name()?->get_first_name(),
491+
],
492+
(object) [
493+
'Name' => 'CustomerLastName',
494+
'Value' => $customer?->get_name()?->get_last_name(),
495+
],
496+
(object) [
497+
'Name' => 'CustomerCountryCode',
498+
'Value' => $payment->get_billing_address()?->get_country()?->get_code(),
499+
],
500+
(object) [
501+
'Name' => 'consumeremail',
502+
'Value' => $customer?->get_email(),
503+
],
504+
],
505+
];
506+
507+
break;
508+
/**
478509
* Payment method V PAY.
479510
*
480511
* @link https://dev.buckaroo.nl/PaymentMethods/Description/creditcards#top

0 commit comments

Comments
 (0)