bunq / sdk_php

PHP SDK for bunq API
MIT License
84 stars 55 forks source link

DraftPayment create fails with superfluous field-errors #101

Closed BabyDino closed 6 years ago

BabyDino commented 6 years ago

Steps to reproduce:

// Create pointer
$alias = new Pointer('IBAN', $iban);
$alias->setName($name);

// Create draft payment entry
$draftPaymentEntry = new DraftPaymentEntry(
    new Amount($amount, 'EUR'),
    $alias,
    "Description of draft payment"
);

// Set merchant reference
$draftPaymentEntry->setMerchantReference("Merch-ref-bla");

// Create a payment map.
$draftPaymentMap = [
    DraftPayment::FIELD_ENTRIES => [
        $draftPaymentEntry
    ],
    DraftPayment::FIELD_NUMBER_OF_REQUIRED_ACCEPTS => 1 
];

// Create a new payment and retrieve it's id.
$draftPaymentId = DraftPayment::create($apiContext, $draftPaymentMap, BUNQ_USER_ID, BUNQ_TICKETS_ACCOUNT);

What should happen:

Return of the Payment ID

What happens:

HTTP Response Code: 400
Superfluous field "allow_bunqto".
Superfluous field "id".
Superfluous field "alias".
Superfluous field "type".

SDK version and environment

Response id

OGKevin commented 6 years ago

Ahh, @BabyDino this is due to the following:

https://github.com/bunq/sdk_php/blob/39fd6bf95f858383caad13dc4e3ae03177f09b4b/src/Model/Generated/Object/DraftPaymentEntry.php#L9 is only supposed to be used for responses and not when making requests.

See https://github.com/bunq/sdk_php/issues/63#issuecomment-341970231 In a future refactor this will be picked up.

Closing this issue for now as this is not a bug, but feel free to comment.