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
Reduce simplest use case from two API calls to one #492
Comments
|
@steveklabnik how would this work in the ruby api? # presumably done by some Rails app config
require 'balanced'
Balanced.configure('ak-test-3ndxkwi2d8Gb4E15emwEbwLkEE3K4naM')
# ... some code..
card = Balanced::Card.debit(
:href => request_href,
:amount => 5000,
:description => 'Some descriptive text for the debit in the dashboard',
:appears_on_statement_as => 'Statement text'
)Right? That means we should modify https://github.com/balanced/balanced-api/blob/cukes/fixtures/_models/token.json#L4 to return a 'card.debits' href right? |
|
If we allow passing a source param for the root import balanced
balanced.configure('xxx')
card_uri = '/cards/XXXX'
debit = balanced.Debit(source=card_uri, amount=100).save()Currently the root debit method expects an untokenized card payload. This change would mean we don't need to update the spec etc. |
|
I feel that using the api client, you can write this as: And therefore from a visual perspective of the code it is not that bad if you really want to debit a card in a single pass, then you can do: |
|
@mjallday no - since you have to know to append a |
|
@matthewfl latency. |
|
@mjallday the idea in rev1, was we were going to try and avoid having multiple routes for preforming actions. if latency is an issue, you can just add '/debits' to the url and perform a post manually |
|
@matthewfl @mjallday in this case, for some reason, we are asking our customers to KNOW our URI structure. I disagree with this. |
|
@mahmoudimus I agree with this statement (about our url structure), however I feel as if our api should be fast enough where the double request issue is not issue. |
This is not important, especially for a convenience method like this. |
|
It is a marketing issue. Even if our API is fast enough, that's not a solution.— On Thu, Jan 23, 2014 at 11:50 AM, Matthew Francis-Landau
|
|
@steveklabnik then we might as well add a method to all api clients that construct the url internally and preform a post request. This accomplishes having the api be clean and allowing people to preform the debit in a single action |
|
@matthewfl that will mean people need to know about this if they want to write their own client. |
|
Why does this "dirty" up the API, @matthewfl ? We're just adding a link that comes back (which is cheap). Any construction is a smell to me. [Edit] Clarifying "this" |
|
When we wrote the first spec for this version of the api, we decided to leave out this feature as we looked at all the different ways to preform the same action in rev0 and decided we wanted to simplify it and minimize the size of the interface. In my mind, I feel that doing |
|
@matthewfl that's not true. In this case, it's about features. If there is no way of asking our API to charge a card w/o verifying its state, that's upsetting. Why are you FORCING me to get the card first even if I don't care? |
|
afaik, the basically I am +1 for making the making the api "faster" by allowing more direct, but I am -1 for increasing the size of the interface of the clients/api. This means that doing |
|
@matthewfl you should assume that we are not in charge of client libraries. You should be under the impression that you don't know how they're implemented as an API maintainer. Forcing consumers to work around the API via client hacks puts a burden of keeping up to date on our endpoints (antipattern no. 1). It also opens up a vector of workarounds for the API -- asking consumers to work around our unfriendliness towards mobile or bandwidth constrained clients. |
|
|
Right, this seems to be splitting into two things: what it does at the HTTP layer, and how we implement it in our own client libraries. I'm really mostly concerned about the HTTP case. |
|
Whoops, my bad about closing this issue. Hit the wrong button :( |
|
I was writing this before the distinction was made between HTTP layer/client library layer. Posting anyways in case anyone finds it useful. +1 for having an open debate on Github. Very cool. In most of the Twilio client libraries we lazily load the objects. So, something like client.account.accounts.get(id)just updates the URI internally, meaning no HTTP requests are made until an action or property on that object is accessed. So, this would actually fire a POST and no GETs. account = client.accounts.get(id)
account.update(friendly_name="new friendly name")Not sure if this would work in your case or not, just adding another perspective. |
|
@steveklabnik I agree that there are two issues here, in my mind the HTTP case can be covered by appending @dougblack thanks for your input, I was trying to suggest something similar above. |
|
So. When looking at the API, we do support this directly, but with the card number: Basically, what I would like is for this endpoint to also accept a token: That's it. It's not some kind of super significant massive change. |
|
@steveklabnik is there some reason why accepting tokens is less taboo then just adding |
|
Yes. We are trying to educate people against manually constructing URLs. Saying "we're hypermedia! Except in this one case, then you add a URL to something" doesn't make sense. Secondarily, the only way you can get a card href is if you've made an API request to create the card. So it's only available in the two-call scenario. |
|
I didn't know that Balanced.js returns a URI as well as the token. So yes, in that case, passing the token or the href is fine. |
|
@steveklabnik - @mahmoud's response to that (which is the same as what I originally suggested I think) was:
essentially, how do you discover that the debits endpoint exists? in the python client it's hard coded, i'm guessing maybe that's not kosher? |
|
I mean by passing it in as a
We basically would be moving from one known endpoint to two. I'm both pretty confident that maintaining |
|
@steveklabnik another thing is that we can send back a bookmarks schema based on the revision to seed the resources on configurations. require 'balanced'
balanced.configure('.....')
# any further operation will get a side-loaded list of URL maps to seed the resource endpoints, solving the issue of /debits being hardcoded.
Balanced::Customer.find( ... ) # side loads all URL map first for caching |
|
@matthewfl @steveklabnik what's the status with this? |
|
I need to write a spec.— On Fri, Jan 24, 2014 at 7:10 PM, Mahmoud Abdelkader
|
|
@steveklabnik is this issue this valid? |
|
Wondering where this stands in the case that you would like to use the result of the postal code or cvv checks to decide whether or not to charge the card? I know it's straightforward to tokenize a card on the client and then immediately charge that card on the server using |
|
@zachsnow There is an equivalent option for balanced -- we can make AVS/CVV failures hard failures for your marketplace. Contact support@balancedpayments.com to enable this. |
|
@msherry thank you so much for this information! If this isn't documented anywhere I'd highly recommend you do so in a very visible place (I didn't see it anyway, not sayin' much). |
TL;DR: Stripe offers the ability to charge a card in one step:
https://stripe.com/docs/tutorials/charges
We require two:
I'd like to make us only require one, if someone wants to simply charge a card for a one-off purchase.
The text was updated successfully, but these errors were encountered: