Closed jrochkind closed 11 years ago
Ah wait, I see the problem, the :uri parameter to Card.new should not be the marketplace uri, but... the marketplace uri with "/cards" on the end? I'm probably supposed to get this some other way, not just hard-code it, hmm. I'm confused maybe.
Just use
Balanced::Marketplace.my_marketplace.create_card( .... )
In fact, the client is smart to figure out the uri by itself, if you want to continue down the Card.new
route: https://github.com/balanced/balanced-ruby/blob/master/examples/examples.rb#L52
However, I recommend using this method: https://github.com/balanced/balanced-ruby/blob/master/lib/balanced/resources/marketplace.rb#L179 instead.
Aha, thank you, both those methods seem good!
I'm glad I filed the ticket, as I would not have figured out either of those from the docs -- the API docs under "tokenize a card" only give the Card.new example, and give it with an explicit URL, I had no idea I didn't need the URL, or that that other method was available!
@jrochkind, it sounds like we actually need a reference for our clients (we seem to be missing that). I've prioritized it on our balanced/balanced-docs repository.
Yep, as a developer/client I'd agree with that. You have a couple of things that seem to be an API reference, but don't do a great job of doing so -- both https://www.balancedpayments.com/docs/api , and language-specific ones like the generated rdoc. But the rdoc is pretty bare-bones, and the docs/api seems to lead me in the wrong direction. Perhaps docs/api just needs more attention.
(But the actual API itself never fails to impress me with the strength of it's design, once I figure out how to use it the right way!)
In my actual app I'm going to use the JS API to tokenize the credit card, yes.
But in testing, it is convenient to be able to have pure ruby code automatically create a tokenized card URI that I can test with, using one of the fake test credit card numbers.
From the API docs, I thought I'd be able to do something like this:
The API docs say that should return something like:
Which would be great. Note the "uri" in there, just what I need.
But I can't figure out how to get that, it doesn't actually seem to be available. In fact, if I look at card.attributes after doing a
Card.new(...).save
, it seems to have the attributes of an account or a marketplace, not a card....And a whole bunch more. But no card_uri, just info about the marketplace as a whole.
Are the docs wrong? Am I missing something? Is there any way to tokenize a card from ruby, and get back the card uri?