renaming createTransaction and createOrCommitTransaction
Closed this issue · 4 comments
When POSTing to form a new transaction, the result is not yet a finalized transaction, it's more like a preview, normally used to obtain confirmation from the end-user, and valid for the duration of params.ttl
.
This same endpoint accepts a query string parameter &commit=1
, in which case, the transaction is created and committed in a single step server-side, no two calls necessary. I'd suggest changing createOrCommitTransaction
to merely add &commit=1
to the URL.
I would suggest renaming:
createTransaction
-->prepareTransaction
createOrCommitTransaction
-->createTransaction
So, you'd get the following options:
- to create a transaction in a single step, one would call
createTransaction()
- to create a transaction in two steps, call
prepareTransaction()
and thencommitTransaction()
Thoughts?
Thankyou, makes sense and I will add the improvement. I wasn't aware of the commit param, I can't see it in the API docs but would be good if it was there.
Sorry Jorge, The commit param isn't working for me. I have the following request body:
denomination[currency]=GBP&denomination[amount]=0.01&destination=03fc2a40-340f-4350-bd0a-31aed9a52b55&message=test&commit=1
POSTing to
https://api-sandbox.uphold.com/v0/me/cards/bf07a5a7-ccd9-434d-8a19-497ef65f924e/transactions
It creates and returns the transaction but it still has a status of "pending" instead of the expected "completed", I can then use the transactions id to commit as usual with the second step which we're trying to avoid by using commit=1.
This param should go into the URL, as a query string. The thinking here is that only data goes in the request body, and "behavior modifiers" such as this go in the query string, eg:
https://api-sandbox.uphold.com/v0/me/cards/bf07a5a7-ccd9-434d-8a19-497ef65f924e/transactions?commit=1
You should also see that normally this returns an HTTP code 202, but with commit
it should return a 200.
Thanks for clarifying that one, managed to get it working.