Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a DraftPayment that has been ACCEPTED results in an error #63

Closed
tomcoonen opened this issue Oct 30, 2017 · 6 comments
Closed

Comments

@tomcoonen
Copy link

PHP: 7.1
SDK Version: 0.12.1
Error: bunq\Exception\BunqException: Found model "BunqModel" which is not defined. in /vendor/bunq/sdk_php/src/Util/ModelUtil.php:60

As soon as you try to get a DraftPayment that has the status 'ACCEPTED', this DraftPayment will have the 'object' attribute set.
In the Endpoint/DraftPayment.php file is stated:

    /**
     * The Payment or PaymentBatch. This will only be present after the
     * DraftPayment has been accepted.
     *
     * @var BunqModel
     */
    protected $object;

The current code in ModelUtil.php doesn't allow for this since BunqModel is not a subclass of itself.

    /**
     * @param string $className
     *
     * @return bool
     */
    private static function isClassSubClassOfBunqModel(string $className): bool
    {
        return class_exists($className) && is_subclass_of($className, BunqModel::class);
    }

Quickly searching the code I think the Schedule / ScheduleInstance has the same error?

@OGKevin
Copy link
Contributor

OGKevin commented Oct 30, 2017

Interesting, thanks for the bug report we'll take a look and report back once we have a fix 👍🏾.

@OGKevin
Copy link
Contributor

OGKevin commented Nov 5, 2017

@tomcoonen out of curiosity, how are you populating DraftPayment::FIELD_ENTRIES field ? Not sure if I found a bug or if i'm missing something😅

@tomcoonen
Copy link
Author

@OGKevin I don't have any trouble making DraftPayments, modified production example:

foreach($payments as $payment) {
    $pointer = new Pointer('IBAN', $payment->recipient_bank_iban);
    $pointer->setName($payment->recipient_name);

    $bunq_payments[] = [
        Payment::FIELD_AMOUNT => new Amount((string) ($payment->total_amount/100), $payment->currency),
        Payment::FIELD_COUNTERPARTY_ALIAS => $pointer,
        Payment::FIELD_DESCRIPTION => $payment->description,
    ];
}
       

$payment_map = [
    DraftPayment::FIELD_ENTRIES => $bunq_payments,
    DraftPayment::FIELD_NUMBER_OF_REQUIRED_ACCEPTS => 1,
];

The $payment_map I drop into DraftPayment::create() as second parameter.

@OGKevin
Copy link
Contributor

OGKevin commented Nov 6, 2017

Ahhh clever, I was using

class DraftPaymentEntry extends BunqModel

😅 Which is not ment to be used for making request apparently but only for responses. Might be nice to use this class for making requests as well 👍. Will add this to my todo list for the near future.

@tomcoonen
Copy link
Author

Yeah this package can get some improvements indeed, but first let's get it working ;)

@OGKevin
Copy link
Contributor

OGKevin commented Nov 8, 2017

FYI @tomcoonen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants