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

Can I create an order client side and submit a debit + order together w/o having to create an order from the server first? #691

Closed
patrickcusack opened this issue Sep 9, 2014 · 10 comments

Comments

@patrickcusack
Copy link

https://botbot.me/freenode/balanced/2014-09-09/?msg=21323501&page=1

@mjallday mjallday changed the title "Can I create an order client side and submit a debit + order together w/o having to create an order from the server first?" Can I create an order client side and submit a debit + order together w/o having to create an order from the server first? Sep 9, 2014
@mjallday
Copy link
Contributor

mjallday commented Sep 9, 2014

If it's created client side that would mean that potentially anyone could create an Order/Debit on your system since currently we require an API key to create resources via the API (apart from cards).

It's not immediately apparent to me how you can allow the client to control creation of resources on the API securely.

Cards are created independently of any marketplace and you perform authenticated requests to claim them so they are controlled in that manner.

What's the use case that prompted this request?

@mahmoudimus
Copy link
Contributor

@mjallday I believe @patrickcusack meant from a client library first.

@mjallday
Copy link
Contributor

mjallday commented Sep 9, 2014

Do you mean creating a debit and an order in a single API call?

@mahmoudimus
Copy link
Contributor

Yep, which avoids a roundtrip of 1st creating the order. This is more
important on mobile applications.

On Tue, Sep 9, 2014 at 12:18 PM, Marshall Jones [email protected]
wrote:

Do you mean creating a debit and an order in a single API call?


Reply to this email directly or view it on GitHub
#691 (comment)
.

@mjallday
Copy link
Contributor

mjallday commented Sep 9, 2014

The Order can be created ahead of time rather than when the user clicks on the "pay" button.

If the user has already tokenized the card then all the marketplace needs to do is create the hold while the user waits. Everything else can occur asynchronously.

We could write a best-practice guide for mobile integrations which could help people understand the best approach methods for writing a responsive app for these situations.

I've seen many concerns about latency while doing several calls inline to an API, not doing them inline is an easy solution but may not be obvious unless you have domain expertise.

@patrickcusack
Copy link
Author

At this point I am looking at making 4 api calls to submit a debit were I to do it inline. So you recommend that I have pre-cached order ready, which i use in my reference to my debit. Then do an asynchronous customer and marketplace credit?

@patrickcusack
Copy link
Author

"We could write a best-practice guide for mobile integrations which could help people understand the best approach methods for writing a responsive app for these situations."
This would be a good addition to the documentation.

@mjallday
Copy link
Contributor

mjallday commented Sep 9, 2014

you recommend that I have pre-cached order ready, which i use in my reference to my debit. Then do an asynchronous customer and marketplace credit?

I think that's the best approach. If I were about to integrate a mobile payment solution I'd try and make sure that the amount of time the user is waiting for a response is minimised.

Since the only call that can fail once the user has tokenized a card is the creation of a hold then that's the only call I'd make the user wait for. Once the hold has succeeded you are guaranteed that you can capture it and create a debit from it (and an Order).

I'd do the flow like:

  • tokenize card (sync while user waits)
  • prompt for confirmation of order
  • user clicks submit/authorize button
  • card.hold(amount) (sync while user waits)
  • if the previous call failed then prompt user for another card
  • if the call succeeded then show them a success screen and in the background capture the hold to create a debit and the order.

You could create the Order ahead of time but since there's no way to currently delete an Order you could end up with unused Orders hanging about if the user abandons the purchase half way through.

This would be a good addition to the documentation.

We have created an issue to follow up on this - balanced/balanced-docs#447

@patrickcusack let us know if you have more questions or comments about how we can improve on this answer.

@mjallday mjallday closed this as completed Sep 9, 2014
@patrickcusack
Copy link
Author

Why even do the hold if the you could debit the card and get the same instant feedback as you would the hold?

@mjallday
Copy link
Contributor

that's a fair comment, you then have to have created the Order ahead of time. if you're OK with potentially creating Orders and having them abandoned it's no issue.

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

No branches or pull requests

3 participants