From 8e794e951eb60c53c37f9a5a0ff3ac36c75f5bc1 Mon Sep 17 00:00:00 2001 From: BushraAsif Date: Tue, 4 Oct 2022 15:25:46 +0500 Subject: [PATCH 1/4] Add support for new 'Agreements Engine' parameters --- src/AbstractApi.php | 11 ++++ src/Api/Ecommerce/PaymentRequest.php | 14 ++++- src/Api/Payments/CardWalletAuthorize.php | 1 + src/Api/Payments/Credit.php | 2 +- src/Api/Payments/InvoiceReservation.php | 2 +- src/Api/Payments/ReservationOfFixedAmount.php | 1 + src/Traits/AgreementTrait.php | 55 +++++++++++++++++++ 7 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 src/Traits/AgreementTrait.php diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 9bcf540..5c70f6d 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -217,6 +217,7 @@ protected function doConfigureOptions() $resolver = new OptionsResolver(); $this->configureOptions($resolver); $this->setTransactionResolver($resolver); + $this->setAgreementResolver($resolver); $this->setOrderLinesResolver($resolver); $this->setAmountResolver($resolver); $this->setTerminalResolver($resolver); @@ -395,6 +396,16 @@ protected function setTransactionResolver(OptionsResolver $resolver) { } + /** + * Resolve agreement info option + * + * @param OptionsResolver $resolver + * + * @return void + */ + protected function setAgreementResolver(OptionsResolver $resolver) + { + } /** * Resolve orderlines * diff --git a/src/Api/Ecommerce/PaymentRequest.php b/src/Api/Ecommerce/PaymentRequest.php index 4b026ec..cf42d03 100644 --- a/src/Api/Ecommerce/PaymentRequest.php +++ b/src/Api/Ecommerce/PaymentRequest.php @@ -46,7 +46,7 @@ class PaymentRequest extends AbstractApi use Traits\TransactionInfoTrait; use Traits\CustomerInfoTrait; use Traits\OrderlinesTrait; - + use Traits\AgreementTrait; /** * The language of the payment form * @@ -74,7 +74,18 @@ public function setType($type) return $this; } + + /** + * @param string $agreement + * + * @return $this + */ + public function setAgreement($agreement) + { + $this->unresolvedOptions['agreement'] = $agreement; + return $this; + } /** * Use the credit_card_token from a previous payment to allow your customer to buy with the same credit card again * @@ -258,6 +269,7 @@ protected function configureOptions(OptionsResolver $resolver) 'language', 'transaction_info', 'type', + 'agreement', 'ccToken', 'sale_reconciliation_identifier', 'sale_invoice_number', diff --git a/src/Api/Payments/CardWalletAuthorize.php b/src/Api/Payments/CardWalletAuthorize.php index 2cdb7d0..76e4e4e 100644 --- a/src/Api/Payments/CardWalletAuthorize.php +++ b/src/Api/Payments/CardWalletAuthorize.php @@ -269,6 +269,7 @@ protected function configureOptions(OptionsResolver $resolver) 'customer_info', 'config', 'transaction_info', + 'agreement', 'sales_tax', 'cookie', 'ccToken', diff --git a/src/Api/Payments/Credit.php b/src/Api/Payments/Credit.php index abe2d15..4e8f310 100644 --- a/src/Api/Payments/Credit.php +++ b/src/Api/Payments/Credit.php @@ -101,7 +101,7 @@ protected function configureOptions(OptionsResolver $resolver) $resolver->setRequired(['terminal', 'shop_orderid', 'amount', 'currency']); $resolver->setDefined([ - 'transaction_info', 'payment_source', 'credit_card_token', + 'transaction_info', 'agreement', 'payment_source', 'credit_card_token', 'cardnum', 'emonth', 'eyear', 'cvc' ]); diff --git a/src/Api/Payments/InvoiceReservation.php b/src/Api/Payments/InvoiceReservation.php index f05f5d2..e7c0f8c 100644 --- a/src/Api/Payments/InvoiceReservation.php +++ b/src/Api/Payments/InvoiceReservation.php @@ -124,7 +124,7 @@ protected function configureOptions(OptionsResolver $resolver) $resolver->setDefined([ 'accountNumber', 'bankCode', 'fraud_service', 'customer_info', 'orderLines', - 'transaction_info' + 'transaction_info', 'agreement' ]); $resolver->setAllowedTypes('accountNumber', 'string'); $resolver->setAllowedTypes('bankCode', 'string'); diff --git a/src/Api/Payments/ReservationOfFixedAmount.php b/src/Api/Payments/ReservationOfFixedAmount.php index 873b173..18e5762 100644 --- a/src/Api/Payments/ReservationOfFixedAmount.php +++ b/src/Api/Payments/ReservationOfFixedAmount.php @@ -195,6 +195,7 @@ protected function configureOptions(OptionsResolver $resolver) 'cvc', 'credit_card_token', 'transaction_info', + 'agreement', 'fraud_service', 'surcharge', 'customer_info', diff --git a/src/Traits/AgreementTrait.php b/src/Traits/AgreementTrait.php new file mode 100644 index 0000000..7f45b31 --- /dev/null +++ b/src/Traits/AgreementTrait.php @@ -0,0 +1,55 @@ + $agreement + * + * @return $this + */ + public function setAgreement(array $agreement) + { + $this->unresolvedOptions['agreement'] = $agreement; + return $this; + } + + /** + * Resolve agreement info option + * + * @param OptionsResolver $resolver + * + * @return void + */ + public function setAgreementResolver(OptionsResolver $resolver) + { + $resolver->setAllowedTypes('agreement', 'array'); + } +} \ No newline at end of file From 9beb447c9e50db3be4c9dae3c2df4d4e25fb2d48 Mon Sep 17 00:00:00 2001 From: BushraAsif Date: Tue, 4 Oct 2022 15:29:58 +0500 Subject: [PATCH 2/4] Update release notes --- CHANGELOG.md | 4 ++++ src/AbstractApi.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba15b78..015cbec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.7] - 2022-09-04 +### Fixes +- Add support for new 'Agreements Engine' parameters + ## [3.2.6] - 2022-08-22 ### Fixes - Add Api authentication classes diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 5c70f6d..ba2460f 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -52,7 +52,7 @@ abstract class AbstractApi /** * PHP API version */ - const PHP_API_VERSION = '3.2.6'; + const PHP_API_VERSION = '3.2.7'; /** * Event dispatcher From d4e2042be193e120b8f00f79f80583fb1ed113fe Mon Sep 17 00:00:00 2001 From: BushraAsif Date: Wed, 5 Oct 2022 15:48:02 +0500 Subject: [PATCH 3/4] Remove agreement parameters from Applepay and invoice resolver --- CHANGELOG.md | 4 ++-- src/Api/Payments/CardWalletAuthorize.php | 1 - src/Api/Payments/InvoiceReservation.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 015cbec..b75a4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [3.2.7] - 2022-09-04 -### Fixes +## [3.2.7] - 2022-10-04 +### Added - Add support for new 'Agreements Engine' parameters ## [3.2.6] - 2022-08-22 diff --git a/src/Api/Payments/CardWalletAuthorize.php b/src/Api/Payments/CardWalletAuthorize.php index 76e4e4e..2cdb7d0 100644 --- a/src/Api/Payments/CardWalletAuthorize.php +++ b/src/Api/Payments/CardWalletAuthorize.php @@ -269,7 +269,6 @@ protected function configureOptions(OptionsResolver $resolver) 'customer_info', 'config', 'transaction_info', - 'agreement', 'sales_tax', 'cookie', 'ccToken', diff --git a/src/Api/Payments/InvoiceReservation.php b/src/Api/Payments/InvoiceReservation.php index e7c0f8c..f05f5d2 100644 --- a/src/Api/Payments/InvoiceReservation.php +++ b/src/Api/Payments/InvoiceReservation.php @@ -124,7 +124,7 @@ protected function configureOptions(OptionsResolver $resolver) $resolver->setDefined([ 'accountNumber', 'bankCode', 'fraud_service', 'customer_info', 'orderLines', - 'transaction_info', 'agreement' + 'transaction_info' ]); $resolver->setAllowedTypes('accountNumber', 'string'); $resolver->setAllowedTypes('bankCode', 'string'); From 84aca8c4a26c84eb999f1a25f2cbcf56544afcf1 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Thu, 20 Oct 2022 15:59:41 +0500 Subject: [PATCH 4/4] Fix phpcs-fixer issues --- src/Traits/AgreementTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Traits/AgreementTrait.php b/src/Traits/AgreementTrait.php index 7f45b31..811a4b5 100644 --- a/src/Traits/AgreementTrait.php +++ b/src/Traits/AgreementTrait.php @@ -1,4 +1,5 @@ setAllowedTypes('agreement', 'array'); } -} \ No newline at end of file +}