spreedly / spreedly-gem Goto Github PK
View Code? Open in Web Editor NEWA convenient Ruby wrapper for the Spreedly API.
License: MIT License
A convenient Ruby wrapper for the Spreedly API.
License: MIT License
Hi
I just find that the latest release version of the gem 1.3.2 do not include return_url.
At the other hand from project home page I can download as archive file version 1.3.1-16 which include return_url
Could you please release new gem (under 1.3.2) which will include return_url
Thanks
Tsvetelin
I've found 3 fields are not being parsed in authorization response:
I'm using the master branch.
Could you guys please help me?
This gem is parsing nil attributes as empty strings and this caused unexpected errors in our application. I'm worried the same might happen to yours. Either way, this can probably be fixed.
Responses from GET core.spreedly.com/v1/payment_methods/YBEtVpJvKWed2bkitmP0MFS7OOc.{format}
using JSON and XML apis. Then using gem.
Notice how gem response is the only one not having nil
values.
XML:
<payment_method>
<token>YBEtVpJvKWed2bkitmP0MFS7OOc</token>
<created_at type="dateTime">2019-08-06T17:41:41Z</created_at>
<updated_at type="dateTime">2019-08-06T17:42:38Z</updated_at>
<email nil="true"/>
<data nil="true"/>
<storage_state>retained</storage_state>
<test type="boolean">true</test>
<metadata nil="true"/>
<callback_url nil="true"/>
<last_four_digits>0005</last_four_digits>
<first_six_digits>378282</first_six_digits>
<card_type>american_express</card_type>
<first_name>LUIS</first_name>
<last_name>SUAREZ</last_name>
<month type="integer">8</month>
<year type="integer">2024</year>
<address1 nil="true"/>
<address2 nil="true"/>
<city nil="true"/>
<state nil="true"/>
<zip>12345</zip>
<country nil="true"/>
<phone_number nil="true"/>
<company nil="true"/>
<full_name>LUIS SUAREZ</full_name>
<eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
<shipping_address1 nil="true"/>
<shipping_address2 nil="true"/>
<shipping_city nil="true"/>
<shipping_state nil="true"/>
<shipping_zip nil="true"/>
<shipping_country nil="true"/>
<shipping_phone_number nil="true"/>
<payment_method_type>credit_card</payment_method_type>
<errors>
</errors>
<verification_value></verification_value>
<number>XXXX-XXXX-XXXX-0005</number>
<fingerprint>5430cba1b3ca00de0e5297e3291686d259f6</fingerprint>
</payment_method>
JSON
{
"payment_method": {
"token": "YBEtVpJvKWed2bkitmP0MFS7OOc",
"created_at": "2019-08-06T17:41:41Z",
"updated_at": "2019-08-06T17:42:38Z",
"email": null,
"data": null,
"storage_state": "retained",
"test": true,
"metadata": null,
"callback_url": null,
"last_four_digits": "0005",
"first_six_digits": "378282",
"card_type": "american_express",
"first_name": "LUIS",
"last_name": "SUAREZ",
"month": 8,
"year": 2024,
"address1": null,
"address2": null,
"city": null,
"state": null,
"zip": "12345",
"country": null,
"phone_number": null,
"company": null,
"full_name": "LUIS SUAREZ",
"eligible_for_card_updater": true,
"shipping_address1": null,
"shipping_address2": null,
"shipping_city": null,
"shipping_state": null,
"shipping_zip": null,
"shipping_country": null,
"shipping_phone_number": null,
"payment_method_type": "credit_card",
"errors": [],
"fingerprint": "5430cba1b3ca00de0e5297e3291686d259f6",
"verification_value": "",
"number": "XXXX-XXXX-XXXX-0005"
}
}
and gem:
[14] pry(main)> SPREEDLY.find_payment_method('YBEtVpJvKWed2bkitmP0MFS7OOc')
#<Spreedly::CreditCard:0x007f9655ddd158
@address1="",
@address2="",
@card_type="american_express",
@city="",
@company="",
@country="",
@created_at="2019-08-06T17:41:41Z",
@data="",
@eligible_for_card_updater="true",
@email="",
@errors=[],
@fingerprint="5430cba1b3ca00de0e5297e3291686d259f6",
@first_name="LUIS",
@first_six_digits="378282",
@full_name="LUIS SUAREZ",
@last_four_digits="0005",
@last_name="SUAREZ",
@month="8",
@number="XXXX-XXXX-XXXX-0005",
@phone_number="",
@state="",
@storage_state="retained",
@token="YBEtVpJvKWed2bkitmP0MFS7OOc",
@updated_at="2019-08-06T17:42:38Z",
@verification_value="",
@year="2024",
Hello folks,
Almost all transactions support the email attribute and the gem doesn't cover this. Is there some reason for this?
>> Spreedly::Subscriber.find("non-existent-id")
=> #<Spreedly::Subscriber:0xb6fe9b40 @data=nil>
When an API response does not have the expected fields, a parsing exception will result which makes it seem like the tx failed when in actuality it succeeded. We shouldn't fail parsing for missing fields, or should fail in a very predictable explicit fashion (like throw a clearly client-side exception).
/cc @spreedly/product-dev
Hi, is there an easy way to mock spreedly env for unit testing?
The current gem doesn't support the integration of offsite gateways (paypal / gocardless) and their required fields (redirect_url, callback_url)
It would be helpful to know whether or not a purchase transaction was voidable or refundable using something other than a time stamp.
def refundable?
end
def voidable?
end
I'm intermittently getting this error when trying to make a charge.
transaction = spreedly.purchase_on_gateway(gateway_token, payment_token, session_price )
Any ideas?
NoMethodError: undefined method at_xpath for nil:NilClass from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/common/fields.rb:10:in block in initialize_fields from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/common/fields.rb:9:in each from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/common/fields.rb:9:in initialize_fields from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/transactions/gateway_transaction.rb:26:in initialize from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/transactions/gateway_transaction.rb:13:in new from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/transactions/gateway_transaction.rb:13:in initialize from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/transactions/auth_purchase.rb:11:in initialize from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/transactions/transaction.rb:14:in new from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/transactions/transaction.rb:14:in new_from from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/environment.rb:211:in api_post from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spreedly-2.0.4/lib/spreedly/environment.rb:43:in purchase_on_gateway from /Users/....../code/.../app/models/payment_manager.rb:11:in charge from (irb):12 from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in start from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in start from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus/rails.rb:134:in console ... 10 levels... from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:62:in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:78:in block (3 levels) in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:78:in fork from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:78:in block (2 levels) in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:73:in each from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:73:in block in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:62:in loop from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:62:in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:78:in block (3 levels) in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:78:in fork from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:78:in block (2 levels) in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:73:in each from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:73:in block in go from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:62:in loop from /Users/....../.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb:62:in go from -e:1:in <main>irb(main):013:0>
This option is acceptable by the API but the lib doesn't allow us to send it.
It happens rubygems has an older version of the library. I suspect you have ti bump version and push it into https://rubygems.org/gems/spreedly
We have a large number of gateway tokens. In order to assist the code with selecting a gateway token, we would like to have the "description" field of the gateway token returned as part of the list gateway and return gatweay methods.
In our system users put API credentials (secret and environment key) via web GUI. Is there a way I could test creds (not actually add_gateway, add_credit_card or purchase_on_gateway)? Thanks,
Noticed this in the change log on the Spreedly changelog on Apr. 22, 2014. Doesn't seem to be implemented in the gem yet? We use the first six digits to ping fraud prevention APIs so it's invaluable to our organization.
Hi, there,
Is there an API method to flush all payment methods (credit cards) on gateway?
Doing something like this is not a best idea:
env.list_payment_methods do |cc|
env.redact_payment_method(cc.token)
end
Needed mostly for testing purposes.
I think the verification_value may have been left out of the acceptable params for adding a credit card.
In the environment class there are these methods and they are both missing :verification_value. For update it may not be valid to submit similar to the number attribute being excluded.
def add_credit_card_body(options)
build_xml_request('payment_method') do |doc|
add_to_doc(doc, options, :data, :retained, :email)
doc.credit_card do
add_to_doc(doc, options, :number, :month, :first_name, :last_name, :year,
:address1, :address2, :city, :state, :zip, :country, :phone_number)
end
end
end
def update_credit_card_body(options)
build_xml_request('payment_method') do |doc|
add_to_doc(doc, options, :email, :month, :first_name, :last_name, :year,
:address1, :address2, :city, :state, :zip, :country, :phone_number)
end
end
Hi
response = env.purchase_on_gateway(gateway_token, payment_token, 33)
just calling the purchase_on_gateway method as it mentioned in the readme file, but it says callback url can't be blank. gatway is :test and payment_method_type is sprel.
I tried env.purchase_on_gateway(gateway_token, payment_token, 33, redirect_url: r_url, callback_url: c_url)
still doesn't seem to be working. What am I doing wrong? Thanks
Probably it is a good idea to add Apple Pay as a payment method.
I've found 3 fields are not being parsed in refund response:
I'm using the master branch and following this doc: https://docs.spreedly.com/reference/api/v1/transactions/credit/
Could you guys please help me?
And remove this line:
https://github.com/spreedly/spreedly-gem/blob/master/lib/spreedly/connection.rb#L44
Let Ruby default to the system cert.
Don't follow in ActiveMerchant's footsteps on this.
The ability to list the receivers you added, redact and update them are all missing features. Was there a reason these were excluded? If not, I can submit a PR to get this added. Thoughts? @bpollack
The following test is failing because supports_disburse
is not coming back from core xml:
ruby -Itest test/remote/remote_gateway_options_test.rb --name test_successfully_get_options
Spreedly provides a standard interface for Stored Credentials that requires two fields: stored_credential_initiator
and stored_credential_reason_type
. On some gateways, it is possible to use gateway specific fields to send and receive this data, but most of the eight gateways currently supported (and all new gateway implementations) only support the Spreedly Stored Credentials framework. Let's expose this first-class implementation via the gem.
Checking the API docs for list_payment_methods
, it supports filtering by metadata
, which is very handy, for example, for retrieving all payment methods associated to a user (userId set as metadata).
But checking list_payment_methods
implementation, it only supports since_token
.
Will this Ruby gem be updated to match with the API docs?
What would be the recommended workaround to adapt (add decorators) this gem to filter by metadata?
When calling configure
repeatedly the basic_auth
call to HTTParty
results in the authentication parameters in not all classes in the hierarchy being updated.
To try it out:
irb(main):001:0> SpreedlyCore.configure environment_key: '3', access_secret: '4'
irb(main):002:0> SpreedlyCore::Base.default_options
=> {:basic_auth=>{:username=>"3", :password=>"4"}}
irb(main):003:0> SpreedlyCore::Gateway.default_options
=> {:basic_auth=>{:username=>"3", :password=>"4"}}
irb(main):004:0> SpreedlyCore.configure environment_key: '5', access_secret: '6'
irb(main):005:0> SpreedlyCore::Base.default_options
=> {:basic_auth=>{:username=>"5", :password=>"6"}}
irb(main):006:0> SpreedlyCore::Gateway.default_options
=> {:basic_auth=>{:username=>"3", :password=>"4"}}
The reason is that HTTParty
uses mattr_inheritable :default_options
which according to its documentation:
Allows attributes to be shared within an inheritance hierarchy, but where each > descendant gets a copy of their parents' attributes, instead of just a pointer to the same.
I guess SpreedlyCore.configure
would have to call basic_auth
on every class that inherits from Base
separately. A maybe better alternative would be to move all HTTP calls into a separate client class.
I have a company_name sent in the data field during the payment method creation (transparent redirect). When I retrieve the payment method using the gem it returns .data as "<company_name></company_name>", it should parse the xml data and return an hash of values in this case data: {'company_name' => ''} or even better data.company_name (this could break names like "company-name")
Is there a way to get gateway setup options?
For instance, i can get a list of all available gateways with env.gateway_options
. Response will include available countries and payment methods per gateway. But it does not include which fields it needs when creating a new gateway.
https://core.spreedly.com/manual/payment-gateways/authorize-net
Requires login
, password
https://core.spreedly.com/manual/payment-gateways/balanced
Requires: api_secret
Any suggestions?
The README talks about a few features that haven't been implemented quite yet. Finish these.
I have a Spreedly token that I want to store on the gateway (Stripe).
When I call
store_on_gateway(my_spreedly_provided_stripe_gateway_token, my_spreedly_provided_payment_method_token)
I receive
#<Spreedly::Store:0x00007f82c26e6148
...
@message="This API call cannot be made with a publishable API key. Please use a secret API key. You can find a list of your API keys at https://dashboard.stripe.com/account/apikeys."
According to the documentation the POST api call expects to receive "The token of the gateway to execute against" and "transaction | Root element โฏ payment_method_token required | The token of the payment method to copy to the gateway"
https://docs.spreedly.com/reference/api/v1/#store
looking on spreedly logs, I see the error returned from the Stripe API is
{\n \"error\": {\n \"code\": \"secret_key_required\",\n
However the endpoint doesn't seem to accept a secret key?
Are you able to give me any insights if I am using incorrect tokens or if the gem has a bug?
Thanks
I would like to start with Spreedly, but I'm worried that as soon as I finish the implementation "at your own risk." this gem gets deprecated.
This is an example Ruby integration with Spreedly. This version is no longer actively updated and will be superseded by a new version in the near future. Feature parity may lag behind, so please use this gem at your own risk.
When I try and emulate this in the IRB:
credit_card = env.find_payment_method(token)
credit_card.last_name # => "Jones"
credit_card.valid? # => false
I get this error:
credit_card.last_name
NoMethodError: private method `last_name' called for #Spreedly::CreditCard:0x007fa7186d7dd0
from (irb):22
This is true if I try first_name, last_name, email, even if I try valid?
Lack of support for bank_account payment method
This gem currently does not provide support for distributing payment methods to third parties, as described here: https://docs.spreedly.com/payment-method-distribution/
Issue occurs with version 2.0.27 at environment.rb
How do I update a gateway?
Current project description: "The Spreedly gem provides a convenient Ruby wrapper Spreedly's Subscriptions API."
First, I'd say there are a few words missing in that sentence. But more importantly, I believe it's no longer accurate. It took me a while to figure out if this project was solely focusing on the Subscriptions API. And after reading the history file [1] and the project code, I understand now that it's probably the best wrapper out there for the Spreedly API.
The project description should probably make it more obvious.
[1] https://github.com/spreedly/spreedly-gem/blob/master/HISTORY.md
This spreedly gem is of dubious value (being a thing wrapper around a simple API and only supporting one specific client language). As an organization, Spreedly hasn't yet prioritized a first-class client library approach. So, until we have clear client support, we should discourage use of this gem when integrating to Spreedly (not a formal sun-setting yet, more of a recommendation/signal to our customers).
I believe that should take the following (but not exclusive) actions:
Add to the ruby gem the ability to redact gateways
It seems like there is no equivalent to #add_credit_card
for bank accounts. Is this something you would take a pull request for?
Gem installed fine in development, but in production (Ubuntu) got this error message. It's a build dependency issue with Nokogiri (not spreedly).
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
...
Gem files will remain installed in /opt/ruby/lib/ruby/gems/1.8/gems/nokogiri-1.4.1 for inspection.
Results logged to /opt/ruby/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/ext/nokogiri/gem_make.out
The solution in ubuntu was:
sudo apt-get install libxslt1-dev
then this works
sudo gem install spreedly
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.