buckaroo-it/BuckarooSDK_PHP

BA-493 Debtor's Address HouseNumberSuffix parameter is not sent with CreateSubscription call

boldhedgehog opened this issue · 2 comments

Good morning,

When CreateSubscription call is performed, the Address/HouseNumberSuffix is not sent, because the Address model has only $houseNumberAdditional parameter.

It's not mapped to HouseNumberSuffix (which is expected https://docs.buckaroo.io/docs/creditmanagement-requests#request ), because there is no Address Adapter, like e.g. \Buckaroo\PaymentMethods\Afterpay\Afterpay has for the Address.

This should be fixed by creating an AddressAdapter class:

<?php

namespace Buckaroo\PaymentMethods\Subscriptions\Service\ParameterKeys;

use Buckaroo\Models\Adapters\ServiceParametersKeysAdapter;

class AddressAdapter extends ServiceParametersKeysAdapter
{
    protected array $keys = [
        'houseNumberAdditional' => 'HouseNumberSuffix',
    ];
}

and changing \Buckaroo\PaymentMethods\Subscriptions\Models\Subscription:

<?php
// ....
/**
     * @var AddressAdapter
     */
    protected AddressAdapter $address;
//....
public function address($address = null)
    {
        if (is_array($address))
        {
            $this->address = new AddressAdapter(new Address($address));
        }

        return $this->address;
    }

This patch file was applied to version 1.14.0, and the changes fixed the issue.

diff --git a/src/PaymentMethods/Subscriptions/Models/Subscription.php b/src/PaymentMethods/Subscriptions/Models/Subscription.php
--- a/src/PaymentMethods/Subscriptions/Models/Subscription.php
+++ b/src/PaymentMethods/Subscriptions/Models/Subscription.php
@@ -29,6 +29,7 @@
 use Buckaroo\Models\Person;
 use Buckaroo\Models\Phone;
 use Buckaroo\Models\ServiceParameter;
+use Buckaroo\PaymentMethods\Subscriptions\Service\ParameterKeys\AddressAdapter;
 use Buckaroo\PaymentMethods\Subscriptions\Service\ParameterKeys\CompanyAdapter;

 class Subscription extends ServiceParameter
@@ -96,9 +97,9 @@
      */
     protected Phone $phone;
     /**
-     * @var Address
+     * @var AddressAdapter
      */
-    protected Address $address;
+    protected AddressAdapter $address;
     /**
      * @var Person
      */
@@ -253,7 +254,7 @@
     {
         if (is_array($address))
         {
-            $this->address = new Address($address);
+            $this->address = new AddressAdapter(new Address($address));
         }

         return $this->address;

===================================================================
diff --git a/dev/null b/src/PaymentMethods/Subscriptions/Service/ParameterKeys/AddressAdapter.php
--- a//dev/null	2024-09-02 10:07:42.646000117 +0200
+++ b/src/PaymentMethods/Subscriptions/Service/ParameterKeys/AddressAdapter.php	2024-09-02 12:01:23.653006143 +0200
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the MIT License
+ * It is available through the world-wide-web at this URL:
+ * https://tldrlegal.com/license/mit-license
+ * If you are unable to obtain it through the world-wide-web, please send an email
+ * to support@buckaroo.nl so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade this module to newer
+ * versions in the future. If you wish to customize this module for your
+ * needs please contact support@buckaroo.nl for more information.
+ *
+ * @copyright Copyright (c) Buckaroo B.V.
+ * @license   https://tldrlegal.com/license/mit-license
+ */
+
+namespace Buckaroo\PaymentMethods\Subscriptions\Service\ParameterKeys;
+
+use Buckaroo\Models\Adapters\ServiceParametersKeysAdapter;
+
+class AddressAdapter extends ServiceParametersKeysAdapter
+{
+    protected array $keys = [
+        'houseNumberAdditional' => 'HouseNumberSuffix',
+    ];
+}

image

#187 Merged