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

Cannot list draft payments for monetary account #46

Closed
robinkanters opened this issue Dec 6, 2017 · 15 comments
Closed

Cannot list draft payments for monetary account #46

robinkanters opened this issue Dec 6, 2017 · 15 comments
Assignees
Milestone

Comments

@robinkanters
Copy link

robinkanters commented Dec 6, 2017

Steps to reproduce:

  1. Make a draft payment for monetary account X
  2. List draft payments for monetary account X

What should happen:

  1. Draft payments are retrieved and deserialized into DraftPayment instances

What happens:

  1. Gson Error is thrown

Logs

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected NULL but was NUMBER at path $.object.Payment.geolocation.latitude
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:63)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
        at com.google.gson.Gson.fromJson(Gson.java:887)
        at com.google.gson.Gson.fromJson(Gson.java:952)
        at com.google.gson.Gson.fromJson(Gson.java:925)
        at com.bunq.sdk.model.core.BunqModel.fromJsonList(BunqModel.java:104)
        at com.bunq.sdk.model.generated.endpoint.DraftPayment.list(DraftPayment.java:151)
        at com.bunq.sdk.model.generated.endpoint.DraftPayment.list(DraftPayment.java:141)
        at com.bunq.sdk.model.generated.endpoint.DraftPayment.list(DraftPayment.java:137)
@OGKevin
Copy link
Contributor

OGKevin commented Dec 6, 2017

Hey @robinkanters,

Thanks for reporting. I have a felling this has to do with 1 or multiple payments inside the LIST where
$.object.Payment.geolocation.latitude is actually populated with data while the deserialiser expects nothing. Which doesn't make sense to me yet 🤔 Ill see if i can reproduce and find a fix 👍.

@OGKevin OGKevin self-assigned this Dec 6, 2017
@OGKevin OGKevin added this to the 0.12.5 milestone Dec 6, 2017
@robinkanters
Copy link
Author

@OGKevin that sounds correct, that is what the error says haha!

@OGKevin
Copy link
Contributor

OGKevin commented Dec 6, 2017

@robinkanters btw, how did you make the draft payment ? Via API or inside the bunq app ? Save's me some time finding out how to get $.object.Payment.geolocation.latitude populated with data 😁

@robinkanters
Copy link
Author

@OGKevin via the api

@robinkanters
Copy link
Author

robinkanters commented Dec 6, 2017

@OGKevin it's just this, nothing special

return DraftPayment.create(apiContext, mapOf(
        "status" to "PENDING",
        "entries" to listOf(mapOf(
                "amount" to Amount(paymentOrder.amount.toString(), paymentOrder.currency),
                "counterparty_alias" to makePointer(paymentOrder.to, paymentOrder.name),
                "description" to paymentOrder.description,
                "merchant_reference" to paymentOrder.uniqueKey
        )),
        "number_of_required_accepts" to 1
), userId, from).value

@OGKevin
Copy link
Contributor

OGKevin commented Dec 6, 2017

@robinkanters I could not reproduce with the following snippet:

    List<DraftPaymentEntry> entries = new ArrayList<>();
    entries.add(new DraftPaymentEntry(
        new Amount("0.01", "EUR"),
        new MonetaryAccountReference(counterPartyAliasOther),
        "Test"
    ));

    HashMap<String, Object> requestMap = new HashMap<>();
    requestMap.put(DraftPayment.FIELD_NUMBER_OF_REQUIRED_ACCEPTS, 1);
    requestMap.put(DraftPayment.FIELD_STATUS, "PENDING");
    requestMap.put(DraftPayment.FIELD_ENTRIES, entries);

    int draftPaymentId = DraftPayment.create(getApiContext(), requestMap, userId, monetaryAccountId).getValue();
    DraftPayment.list(getApiContext(), userId, monetaryAccountId);
    DraftPayment.get(getApiContext(), userId, monetaryAccountId, draftPaymentId);

🤔 Later today ill try reproducing with a manually made json with the field $.object.Payment.geolocation.latitude populated and deserialise the object then.

@robinkanters
Copy link
Author

@OGKevin maybe it's choking on another payment on my MA, don't know how to figure out which though

@robinkanters
Copy link
Author

robinkanters commented Dec 6, 2017

@OGKevin try accepting the draft payment (in the app) and then listing them for that MA.

It seems to choke on the geolocation on the linked payment instance for some reason. (edit: duh, that's what the error says haha)

If you want to dive into the database, it's payment id removed for draft payment id removed.

Edit: removed ids for privacy reasons.

@robinkanters
Copy link
Author

robinkanters commented Dec 6, 2017

I found a workaround for my personal situation, but it still seems like an important issue to me.

never mind, that also doesn't work

@OGKevin
Copy link
Contributor

OGKevin commented Dec 6, 2017

@robinkanters I think that might be it indeed.

I removed the payment ids for privacy reasons. I did write them down so I’ll have a look indeed 👍.

Once I’ve found a way to reproduce, I should be able to fix it and provide a test so that it doesn’t come back later on 😄. I’ll try your accept in bunq app suggestion as well, if this doesn’t work neither then I’ll try with a manual made raw json.

@robinkanters
Copy link
Author

robinkanters commented Dec 6, 2017

I removed the payment ids for privacy reasons

who cares 😉 wouldn't have posted them if I'd have been concerned about that

@robinkanters
Copy link
Author

robinkanters commented Dec 6, 2017

manual made raw json

yeah so I'm building the request data with a java Map (not by setting properties on a DraftPayment instance), so that might be different from what you're doing. try my snippet 👍

oh wait that is actually what you're doing. no idea what the difference is then

@OGKevin
Copy link
Contributor

OGKevin commented Dec 6, 2017

@robinkanters reproduced 👍.

Ill plan to fix this in 0.12.5.

@robinkanters
Copy link
Author

@OGKevin no doubt you noticed, but just for completeness: this also happens for listing Payments 😉

@OGKevin
Copy link
Contributor

OGKevin commented Dec 31, 2017

@robinkanters yes your indeed correct! It was due to a silly miss type 🤦‍♂️

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