From 25cdf6eda88f8e9a4f5d4e695c277e679bf6db13 Mon Sep 17 00:00:00 2001 From: "daan.rijpkema" Date: Fri, 8 Nov 2024 17:41:33 +0100 Subject: [PATCH 1/2] Add bancontact method --- src/Contexts/PaymentsContext.php | 14 +++++++++++++- src/Requests/PaymentBluemRequest.php | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Contexts/PaymentsContext.php b/src/Contexts/PaymentsContext.php index b7d2d12..b7358c6 100644 --- a/src/Contexts/PaymentsContext.php +++ b/src/Contexts/PaymentsContext.php @@ -19,13 +19,15 @@ class PaymentsContext extends BluemContext public const PAYMENT_METHOD_CREDITCARD = 'CreditCard'; public const PAYMENT_METHOD_SOFORT = 'Sofort'; public const PAYMENT_METHOD_CARTE_BANCAIRE = 'CarteBancaire'; + public const PAYMENT_METHOD_BANCONTACT = 'Bancontact'; public const PAYMENT_METHODS = [ self::PAYMENT_METHOD_IDEAL, self::PAYMENT_METHOD_PAYPAL, self::PAYMENT_METHOD_CREDITCARD, self::PAYMENT_METHOD_SOFORT, - self::PAYMENT_METHOD_CARTE_BANCAIRE + self::PAYMENT_METHOD_CARTE_BANCAIRE, + self::PAYMENT_METHOD_BANCONTACT, ]; public string $debtorWalletElementName = self::PAYMENT_METHOD_IDEAL; @@ -130,6 +132,11 @@ private function validateDetails(): array // // add upcoming validation here // } // + // if($this->isBancontact()) { + // // validate DebtorAccountName to be TokenLength70SimpleType with minOccurs="0" + // // validate DebtorAccount to be TokenLength70SimpleType with minOccurs="0" + // } + // return []; } @@ -162,4 +169,9 @@ public function isCarteBancaire(): bool { return $this->debtorWalletElementName === self::PAYMENT_METHOD_CARTE_BANCAIRE; } + + public function isBancontact(): bool + { + return $this->debtorWalletElementName === self::PAYMENT_METHOD_BANCONTACT; + } } diff --git a/src/Requests/PaymentBluemRequest.php b/src/Requests/PaymentBluemRequest.php index 535ae3d..3696536 100644 --- a/src/Requests/PaymentBluemRequest.php +++ b/src/Requests/PaymentBluemRequest.php @@ -260,6 +260,12 @@ public function setPaymentMethodToCarteBancaire(): self return $this; } + public function setPaymentMethodToBancontact(): self + { + $this->setPaymentMethod($this->context::PAYMENT_METHOD_BANCONTACT); + return $this; + } + /** * @param mixed $dueDateTime * @return string @@ -343,8 +349,11 @@ private function XmlWrapDebtorWalletForPaymentMethod(): string // if specific sofort body becomes required in the future; please add it here } elseif ($this->context->isCarteBancaire()) { // if specific carte bancaire body becomes required in the future; please add it here + } elseif ($this->context->isBancontact()) { + // if specific bancontact body becomes required in the future; please add it here } + $res .= "context->debtorWalletElementName}>" . PHP_EOL; return $res . ("" . PHP_EOL); } From 431013c963c7b230be30b5bef34db587fcf08ceb Mon Sep 17 00:00:00 2001 From: "daan.rijpkema" Date: Sun, 10 Nov 2024 13:19:21 +0100 Subject: [PATCH 2/2] Set debtor wallet to contain key of methods CARTE_BANCAIRE and BANCONTACT --- src/Contexts/PaymentsContext.php | 1 + src/Requests/PaymentBluemRequest.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Contexts/PaymentsContext.php b/src/Contexts/PaymentsContext.php index b7358c6..6a91dbf 100644 --- a/src/Contexts/PaymentsContext.php +++ b/src/Contexts/PaymentsContext.php @@ -42,6 +42,7 @@ class PaymentsContext extends BluemContext */ public function __construct() { + // @todo: make BICs method-specific parent::__construct( [ new BIC("ABNANL2A", "ABN AMRO"), diff --git a/src/Requests/PaymentBluemRequest.php b/src/Requests/PaymentBluemRequest.php index 3696536..bd74fdd 100644 --- a/src/Requests/PaymentBluemRequest.php +++ b/src/Requests/PaymentBluemRequest.php @@ -348,8 +348,10 @@ private function XmlWrapDebtorWalletForPaymentMethod(): string } elseif ($this->context->isSofort()) { // if specific sofort body becomes required in the future; please add it here } elseif ($this->context->isCarteBancaire()) { +// $res .= "CARTE_BANCAIRE"; // if specific carte bancaire body becomes required in the future; please add it here } elseif ($this->context->isBancontact()) { +// $res .= "BANCONTACT"; // if specific bancontact body becomes required in the future; please add it here } @@ -366,7 +368,7 @@ private function XmlWrapDebtorWalletForPaymentMethod(): string * @return void * @throws Exception */ - public function selectDebtorWallet($BIC) + public function selectDebtorWallet($BIC): void { if (! in_array($BIC, $this->context->getBICCodes())) {