bluem-development/bluem-php

PaymentReference is generated with an invalid value

Opened this issue · 2 comments

$this->paymentReference = "$this->debtorReference$this->transactionID";

DebtorReference has to be maximal 35 characters long
TransactionID has to be alphanumeric and maximal 64 characters long and is set by the library by the first 28 characters of DebtorReference plus YYYYMMDD
PaymentReference has to be alphanumeric and maximal 35 characters long

So, given this example:
DebtorReference = "Website order 12345678";
The library is removing all the non-alphanumeric values from the DebtorReference (#20) (why?).

TransactionID will be "Websiteorder1234567820220906";
PaymentReference will be "Websiteorder12345678Websiteorder1234567820220906";

The PaymentReference is a combination of a max 35 long string and a max 36 long string, but can only be 35 chars long and will throw a validation error from the API.

Expected behaviour is that PaymentReference can be set by the implementation (and will be validated) or otherwise will be a valid generated value which meets the API requirements.

Hi Bart,
In release 2.1.4.1 you can now set the PaymentReference as the last parameter when creating a PaymentRequest. Example:

    $request = $bluem_object->CreatePaymentRequest(
        $description,
        $debtorReference,
        $amount,
        $dueDateTime,
        $currency,
        $entranceCode,
        $debtorReturnURL,
        $paymentReference
    );

Moreover, the sanitization has been moved from the DebtorReference (now only substring to 35chars) but added to the TransactionID.
If a PaymentReference is set by the application, the library does not use the fallback of a concatenated string.

When no PaymentReference is provided, DebtorReference and TransactionID are used as PaymentReference.
DebtorReference may contain whitespaces, PaymentReference don't.
Because of that, the PaymentReference should be sanitized. That's currentlty missing.

When I provide DebtorReference 'Payment 123' and no PaymentReference, I'll get an exception about the space.
When I provide DebtorReference with 35 characters and no PaymentReference, I'll get an exception about the length.