razorpay / razorpay-ruby Goto Github PK
View Code? Open in Web Editor NEWRazorpay Ruby SDK
Home Page: https://rubygems.org/gems/razorpay
License: MIT License
Razorpay Ruby SDK
Home Page: https://rubygems.org/gems/razorpay
License: MIT License
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Tried almost everything. Updating certs from RVM, Homebrew as well as reinstall Ruby with RVM.
Hi,
We are testing out razorpay as our payment gateway. One of the features that we seek is subscription creation and updating using ruby-gem. Is it possible to do so?
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/attribute_assignment.rb:50:in `rescue in _assign_attribute'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/attribute_assignment.rb:26:in `each'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/core.rb:453:in `init_attributes'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/core.rb:196:in `initialize'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/inheritance.rb:30:in `new'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/activerecord-4.1.8/lib/active_record/inheritance.rb:30:in `new'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/razorpay-1.2.1/lib/razorpay/request.rb:73:in `create_instance'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/razorpay-1.2.1/lib/razorpay/request.rb:48:in `request'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/razorpay-1.2.1/lib/razorpay/request.rb:30:in `all'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/razorpay-1.2.1/lib/razorpay/order.rb:21:in `all'
from (irb):1
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/railties-4.1.8/lib/rails/commands/console.rb:90:in `start'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/railties-4.1.8/lib/rails/commands/console.rb:9:in `start'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:69:in `console'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in](url)
Says Razorpay::Order is uninitialized constant, however the Razorpay::Payment is working fine.
Razorpay::ServerError (We are facing some trouble completing your request at the moment. Please try again shortly.):
For Razorpay::QrCode.create(para_attr.to_json)
I was searching for documentation for routes(https://razorpay.com/docs/api/route/). All examples are for curl.
It would be great if you could provide documentation specific to the language. For example a proper documentation for ruby gem, python package etc. In your document pages you have given following examples for ruby
I could not find documentation for:
Kindly provide language specific documentation for ruby, python and other languages.
When I capture authorized payment or refund captured payment from Razorpay::Payment object status is not changed.
for example
obj = Razorpay::Payment.fetch(raz_payment_id)
obj.status # outputs: "authorized"
obj.capture({amount: 100}) // assume 100 is amount authorized.
obj.status # outputs: "authorized", it should be "captured"
obj.refund
obj.status # outputs: "captured", it should be "refunded"
because of this I had to request razorpay api multiple times to check the status, if this is resolved I could minimize request to razorpay api.
While accessing 'method' using razorpay_response.method it gives an error: ArgumentError Exception: wrong number of arguments (given 0, expected 1)
I think it should be changed or probably another solution is needed!
When I tried to create an order from rails console, I'm getting this error.
I'm using the razorpay 2.3.0 gem. When I try to create a payment link, it gives me an error.
Razorpay::Invoice.create type: 'link', description: 'test description', amount: 100, currency: 'INR', customer: {name: 'Test', email: '[email protected]'}
This gives me the following error.
Razorpay::BadRequestError: line_items is required.
However, the documentation for this does not specify anything regarding line items. Please let me know how I can modify my request, so that I can generate payment links.
The secure_compare I think is faulty. I might be wrong.
I tried using the verify_payment_signature
method provided by the library to verify my signatures from Orders API
but it would always raise SecurityError
error.
I wrote the verify_signature method myself (which I had previously written for Webhook checksum verification) and it works fine. Modified the same to work with Orders API
. The snippet is below:
# Verification method for Razorpay Orders API Signature
def self.verify_signature(data)
signature = data[:signature]
order_id = data[:order_id]
payment_id = data[:payment_id]
data = [order_id, payment_id].join('|')
calculated_hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ENV['RAZORPAY_SECRET'], data).strip()
return Rack::Utils.secure_compare(calculated_hash,signature)
end
# Verification method for Razorpay Webhook Checksum
def verify_signature(received_hash,data)
calculated_hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ENV['RAZORPAY_WEBHOOK_SECRET'], data).strip()
return Rack::Utils.secure_compare(calculated_hash,received_hash)
end
Hope it helps. π
Is there any possibility that during payment capture any error will occur??
We need to allow custom secrets as well
While creating a subscription plan this error is thrown.
data = {
:period => "monthly",
:interval => 1,
:item => {
:name => "Monthly Rs.5,000.00",
:amount => 500000,
:currency => "INR"
}
}
Razorpay::Subscription.create(data) // throws exception
# Razorpay::BadRequestError: The plan id field is required
The interesting outlook is the following request works for the same request data.
Razorpay::Request.new("plans").post("", data)
I'm wondering how can plan id be required while creating the plan.
Help needed.
Its convenient that all the API calls and entities of razorpay can be accessed using class methods, but the design makes heavy use of class variables. Class variables should be frowned upon because they are not thread safe. Moreover, despite everything implemented as classes; usage is mostly as if these were modules. Currently no instances can be created which can be configured at runtime.
There can be many different ways to implement thread safe code, which can be configured at runtime. One such implementation can be as follows:
class Razorpay::Client
attr_accessor :auth, :custom_headers
def initialize(auth=nil, custom_headers=nil)
self.auth = auth || Razorpay.auth
self.custom_header = custom_headers || Razorpay.custom_headers
end
def self.payment
new.payment
end
def self.refund
new.refund
end
# ...... other methods
def payment
@payment ||= Razorpay::Payment.new(self)
end
def refund
@refund ||= Razorpay::Refund.new(self)
end
# ..... other similar methods
end
class Razorpay::Payment
attr_accessor :request
def initialize(client=nil)
self.request = Razorpay::Request.new(client || Razorpay::Client.new, "payments")
end
def fetch(id)
self.request.fetch id
end
# ..... other methods
end
class Request
def initialize(client=nil, entity_name=nil)
# similar to current implementation, but use client.auth and client.custom_headers, instead of Razorpay.auth and Razorpay.custom_headers
end
# ... other request methods
end
##### Basic usage #####
Razorpay::Client.payment.fetch(id)
##### Advanced usage with multiple merchant accounts #####
account1 = Razorpay::Client.new(auth1)
account1.payment.fetch(id)
account2 = Razorpay::Client.new(auth2)
account2.payment.fetch(id)
I am open to feedback and other suggestions to be able use multiple merchant accounts in a single project.
How would you suggest using this library for both normal and a sub-merchant account transactions?
Currently razorpay-ruby
gem is setup-ed with an initializer with single user/merchant's credentials.
Is it a good way to explicitly setup/override Razorpay with sub-merchant's credentials wherever we are require sub-merchant instance
id = Rails.application.secrets.razorpay['sub_merchant_id']
secret = Rails.application.secrets.razorpay['sub_merchant_secret']
Razorpay.setup(id, secret)
Razorpay::Orders.all
...
Here is my verify_payment_signature
input. I always end-up getting nil
as verification state.
{
:razorpay_order_id=>"order_BvgPKQILlFk38U",
:razorpay_payment_id=>"pay_BvgQ5qSaZ25U1U",
:razorpay_signature=>"1fc86eb3406b88bab55ef9dd245a8f7686bfaae8f37bda5dab650580297f8206"
}
status = Razorpay::Utility.verify_payment_signature(payment_response)
# nil
I can check payment state as paid
order = Razorpay::Order.fetch('order_BvgPKQILlFk38U')
#<Razorpay::Order:0x0000562764aaa410 @attributes={"id"=>"order_BvgPKQILlFk38U", "entity"=>"order", "amount"=>100, "amount_paid"=>100, "amount_due"=>0, "currency"=>"INR", "receipt"=>"47", "offer_id"=>nil, "status"=>"paid", "attempts"=>1, "notes"=>{"note"=>"test500"}, "created_at"=>1550037084}>
And payment status is captured
order.payments
#<Razorpay::Collection:0x0000562764a87e38 @attributes={"entity"=>"collection", "count"=>1, "items"=>[{"id"=>"pay_BvgQ5qSaZ25U1U", "entity"=>"payment", "amount"=>100, "currency"=>"INR", "status"=>"captured", "order_id"=>"order_BvgPKQILlFk38U", "invoice_id"=>nil, "international"=>false, "method"=>"card", "amount_refunded"=>0, "refund_status"=>nil, "captured"=>true, "description"=>"Purchase Description", "card_id"=>"card_BvgQ5ss5xV8WwY", "bank"=>nil, "wallet"=>nil, "vpa"=>nil, "email"=>"[email protected]", "contact"=>"+9199999999", "notes"=>{"address"=>"Hello World"}, "fee"=>2, "tax"=>0, "error_code"=>nil, "error_description"=>nil, "created_at"=>1550037128}]}>
Hi, I'm exploring and building the linked account for Razorpay route, is the module available in this library, if yes then which method?
Getting the payment object from razorpay but when trying to capture it, it throws error.
require 'razorpay'
Razorpay.setup(Settings.razorpay_settings['key'], Settings.razorpay_settings['secret'])
res = Razorpay::Payment.fetch(params[:merchant_txn_id]).capture({amount:self.trans_amount})
Error
DEPRECATION WARNING: `#capture(stream)` is deprecated and will be removed in the next release. (called from irb_binding at (irb):37)
NoMethodError: undefined method `reopen' for nil:NilClass
Hello Team,
We would like to have a provision to edit customer's card details via customer id.
Flow could be as follow:
This would be very helpful for us to provide ease to our customers.
Thanks in advance!
Since Ruby has a method
method on the Object class, trying to call payment.method
to get the payment method (card|...) does not work properly.
A workaround is to do the following:
payment.method_missing(:method)
Hello Team,
How can we fetch all the invoices created (along with add-ons data if any) for one subscription?
Can you provide provision to fetch all the invoices on subscription? Something like @subscription.invoices?
After generating test payment link and paying through it using dummy UPI id I am getting the error "We are facing some trouble completing your request at the moment. Please try again shortly"
By mistake I passed signature
instead of razorpay_signature
to verify_payment_signature
. Code failed under secure_compare(a,b)
with error that method bytesize
not available on nil
.
I think it should fail straight away under verify_payment_signature
Something like:
def self.verify_payment_signature(attributes)
signature = attributes.delete(:razorpay_signature) { |k| fail ArgumentError, k }
# .....
end
2.2.4 :038 > va = Razorpay::VirtualAccount.create(h)
Razorpay::BadRequestError: The requested URL was not found on the server.
from /Users/vikas.y/.rvm/gems/ruby-2.2.4/gems/razorpay-2.2.0/lib/razorpay/request.rb:105:in `raise_error'
I am using razorpay gem version 2.2.0
How can I initiate the [Routes API] (https://razorpay.com/docs/route/api-reference/) through this gem? I want to initiate a transfer for a payment as mentioned in the API:
https://razorpay.com/docs/route/api-reference/#funds-movement-in-linked-accounts
Thanks,
Leena
Does the gem support usage by a Partner? Letβs say I do the Razorpay OAuth and get an access token as defined here
https://razorpay.com/docs/oauth/access/#bearer-authorization
Could I just set the access token in the authorisation header and use it? Would be great if we can get official clarification on that.
I and a lot of people have been facing this error for a long time now. Some people are facing in live mode where as some people like me are facing it in the test mode as well.
PLEASE FIX IT ASAP!!!
We should raise a ServerError in such cases?
Whenever I create subscription through the gem, subscription is created but there is an argument error that I get which says:
ArgumentError: wrong number of arguments (given 2, expected 1),
from /Users/test/.rvm/gems/ruby-2.3.3@gor/gems/razorpay-2.3.0/lib/razorpay/entity.rb:17:in `method_missing'
maybe you are passing two arguments to the method_missing method which is only expecting 'name'.
Is there any webhook callback after the subscription is created that I am not handling?
Subscription create with upfront fees as addons fails
The item id field is required when item is not present.
. In the api request params, it can be seen that addon attributes are passed as desired.application/json
and data passed as json, it works.httparty sends data in application/x-www-form-urlencoded
format by default which seems to be supported and working as expected by Razorpay apis but breaks in this particular case.
Should we change the default as application/json
and configure httparty to parse params in json when received ?
Should we patch Razorpay::Request#raw_request to support both and convert data to json based on Content-Type
?
def raw_request(method, url, data = {})
case method
when :get
@options[:query] = data
when :post, :put, :patch
if(@options[:headers].fetch('Content-Type', "") == "application/json")
@options[:body] = data.to_json
else
@options[:body] = data
end
end
self.class.send(method, url, @options)
end
Can we fix this in Razorpay Api's so that behavior remains same throughout whether using Content-Type
as application/json
or application/x-www-form-urlencoded
?
2.3.3 :002 > addon_attrs = {:item=>{:name=>"fake_addon_name", :description=>"fake_addon_description", :currency=>"INR", :amount=>5000}, :quantity=>1}
=> {:item=>{:name=>"fake_addon_name", :description=>"fake_addon_description", :currency=>"INR", :amount=>5000}, :quantity=>1}
2.3.3 :003 > s_attrs = { plan_id: 'plan_97l6xBrTEsPTXe', customer_id: 'cust_8jv29tdSNEpQj5', start_at: (Time.now + (60*60)).to_i, total_count: 3}
=> {:plan_id=>"plan_97l6xBrTEsPTXe", :customer_id=>"cust_8jv29tdSNEpQj5", :start_at=>1512068870, :total_count=>3}
2.3.3 :004 > s = Razorpay::Subscription.create(s_attrs.merge(addons: [addon_attrs]))
opening connection to api.razorpay.com:443...
opened
starting SSL for api.razorpay.com:443...
SSL established
<- "POST /v1/subscriptions HTTP/1.1\r\nUser-Agent: Razorpay-Ruby/2.1.0\r\nAuthorization: Basic xxxxx\r\nConnection: close\r\nHost: api.razorpay.com\r\nContent-Length: 259\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n"
<- "plan_id=plan_97l6xBrTEsPTXe&customer_id=cust_8jv29tdSNEpQj5&start_at=1512068870&total_count=3&addons[][quantity]=1&addons[][item][name]=fake_addon_name&addons[][item][description]=fake_addon_description&addons[][item][currency]=INR&addons[][item][amount]=5000"
-> "HTTP/1.1 400 Bad Request\r\n"
-> "Cache-Control: max-age=0, must-revalidate, no-store, nocache, private\r\n"
-> "Content-Type: application/json\r\n"
-> "Date: Thu, 30 Nov 2017 18:07:56 GMT\r\n"
-> "Expires: Fri, 01 Jan 1990 00:00:00 GMT\r\n"
-> "Pragma: no-cache\r\n"
-> "Server: Apache\r\n"
-> "Strict-Transport-Security: max-age=63072000; includeSubDomains\r\n"
-> "X-Frame-Options: SAMEORIGIN\r\n"
-> "Content-Length: 128\r\n"
-> "Connection: Close\r\n"
-> "\r\n"
reading 128 bytes...
-> "{\"error\":{\"code\":\"BAD_REQUEST_ERROR\",\"description\":\"The item id field is required when item is not present.\",\"field\":\"item_id\"}}"
read 128 bytes
Conn close
Razorpay::BadRequestError: The item id field is required when item is not present.
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:108:in `raise_error'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:85:in `create_instance'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:59:in `request'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:55:in `create'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/subscription.rb:13:in `create'
from (irb):4
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli/console.rb:18:in `run'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli.rb:391:in `console'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/bundle:23:in `load'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/bundle:23:in `<main>'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `eval'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `<main>'
Subscription create with upfront fees as addons still fails
when Content-Type set
as application/json
2.3.3 :005 > Razorpay.headers = { "Content-Type" => "application/json", "Accept" => "application/json" }
=> {"Content-Type"=>"application/json", "Accept"=>"application/json"}
2.3.3 :006 > s = Razorpay::Subscription.create(s_attrs.merge(addons: [addon_attrs]))
opening connection to api.razorpay.com:443...
opened
starting SSL for api.razorpay.com:443...
SSL established
<- "POST /v1/subscriptions HTTP/1.1\r\nContent-Type: application/json\r\nAccept: application/json\r\nUser-Agent: Razorpay-Ruby/2.1.0\r\nAuthorization: Basic xxxxx\r\nConnection: close\r\nHost: api.razorpay.com\r\nContent-Length: 259\r\n\r\n"
<- "plan_id=plan_97l6xBrTEsPTXe&customer_id=cust_8jv29tdSNEpQj5&start_at=1512068870&total_count=3&addons[][quantity]=1&addons[][item][name]=fake_addon_name&addons[][item][description]=fake_addon_description&addons[][item][currency]=INR&addons[][item][amount]=5000"
-> "HTTP/1.1 400 Bad Request\r\n"
-> "Cache-Control: max-age=0, must-revalidate, no-store, nocache, private\r\n"
-> "Content-Type: application/json\r\n"
-> "Date: Thu, 30 Nov 2017 18:09:06 GMT\r\n"
-> "Expires: Fri, 01 Jan 1990 00:00:00 GMT\r\n"
-> "Pragma: no-cache\r\n"
-> "Server: Apache\r\n"
-> "Strict-Transport-Security: max-age=63072000; includeSubDomains\r\n"
-> "X-Frame-Options: SAMEORIGIN\r\n"
-> "Content-Length: 103\r\n"
-> "Connection: Close\r\n"
-> "\r\n"
reading 103 bytes...
-> "{\"error\":{\"code\":\"BAD_REQUEST_ERROR\",\"description\":\"The plan id field is required.\",\"field\":\"plan_id\"}}"
read 103 bytes
Conn close
Razorpay::BadRequestError: The plan id field is required.
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:108:in `raise_error'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:85:in `create_instance'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:59:in `request'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/request.rb:55:in `create'
from /home/pikender/rails/vibrantstack/razorpay-ruby/lib/razorpay/subscription.rb:13:in `create'
from (irb):6
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli/console.rb:18:in `run'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli.rb:391:in `console'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
from /home/pikender/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/bundle:23:in `load'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/bundle:23:in `<main>'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `eval'
from /home/pikender/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `<main>'
Subscription create with upfront fees as addons passes
when Content-Type
set as application/json
and data converted to json
2.3.3 :007 > s = Razorpay::Subscription.create(s_attrs.merge(addons: [addon_attrs]).to_json)
opening connection to api.razorpay.com:443...
opened
starting SSL for api.razorpay.com:443...
SSL established
<- "POST /v1/subscriptions HTTP/1.1\r\nContent-Type: application/json\r\nAccept: application/json\r\nUser-Agent: Razorpay-Ruby/2.1.0\r\nAuthorization: Basic xxxxx\r\nConnection: close\r\nHost: api.razorpay.com\r\nContent-Length: 237\r\n\r\n"
<- "{\"plan_id\":\"plan_97l6xBrTEsPTXe\",\"customer_id\":\"cust_8jv29tdSNEpQj5\",\"start_at\":1512068870,\"total_count\":3,\"addons\":[{\"item\":{\"name\":\"fake_addon_name\",\"description\":\"fake_addon_description\",\"currency\":\"INR\",\"amount\":5000},\"quantity\":1}]}"
-> "HTTP/1.1 200 OK\r\n"
-> "Cache-Control: max-age=0, must-revalidate, no-store, nocache, private\r\n"
-> "Content-Type: application/json\r\n"
-> "Date: Thu, 30 Nov 2017 18:09:12 GMT\r\n"
-> "Expires: Fri, 01 Jan 1990 00:00:00 GMT\r\n"
-> "Pragma: no-cache\r\n"
-> "Server: Apache\r\n"
-> "Strict-Transport-Security: max-age=63072000; includeSubDomains\r\n"
-> "X-Frame-Options: SAMEORIGIN\r\n"
-> "Content-Length: 379\r\n"
-> "Connection: Close\r\n"
-> "\r\n"
reading 379 bytes...
-> "{\"id\":\"sub_97lvgp0x2kyAEZ\",\"entity\":\"subscription\",\"plan_id\":\"plan_97l6xBrTEsPTXe\",\"customer_id\":\"cust_8jv29tdSNEpQj5\",\"status\":\"created\",\"current_start\":null,\"current_end\":null,\"ended_at\":null,\"quantity\":1,\"notes\":[],\"charge_at\":1512068870,\"start_at\":1512068870,\"end_at\":1517423400,\"auth_attempts\":0,\"total_count\":3,\"paid_count\":0,\"customer_notify\":true,\"created_at\":1512065352}"
read 379 bytes
Conn close
=> #<Razorpay::Subscription:0x00000001dec5a0 @attributes={"id"=>"sub_97lvgp0x2kyAEZ", "entity"=>"subscription", "plan_id"=>"plan_97l6xBrTEsPTXe", "customer_id"=>"cust_8jv29tdSNEpQj5", "status"=>"created", "current_start"=>nil, "current_end"=>nil, "ended_at"=>nil, "quantity"=>1, "notes"=>[], "charge_at"=>1512068870, "start_at"=>1512068870, "end_at"=>1517423400, "auth_attempts"=>0, "total_count"=>3, "paid_count"=>0, "customer_notify"=>true, "created_at"=>1512065352}>
2.3.3 :008 > s = Razorpay::Subscription.fetch('sub_97lvgp0x2kyAEZ')
opening connection to api.razorpay.com:443...
opened
starting SSL for api.razorpay.com:443...
SSL established
<- "GET /v1/subscriptions/sub_97lvgp0x2kyAEZ? HTTP/1.1\r\nContent-Type: application/json\r\nAccept: application/json\r\nUser-Agent: Razorpay-Ruby/2.1.0\r\nAuthorization: Basic xxxxx\r\nConnection: close\r\nHost: api.razorpay.com\r\n\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Cache-Control: max-age=0, must-revalidate, no-store, nocache, private\r\n"
-> "Content-Type: application/json\r\n"
-> "Date: Thu, 30 Nov 2017 18:14:03 GMT\r\n"
-> "Expires: Fri, 01 Jan 1990 00:00:00 GMT\r\n"
-> "Pragma: no-cache\r\n"
-> "Server: Apache\r\n"
-> "Strict-Transport-Security: max-age=63072000; includeSubDomains\r\n"
-> "X-Frame-Options: SAMEORIGIN\r\n"
-> "Content-Length: 379\r\n"
-> "Connection: Close\r\n"
-> "\r\n"
reading 379 bytes...
-> "{\"id\":\"sub_97lvgp0x2kyAEZ\",\"entity\":\"subscription\",\"plan_id\":\"plan_97l6xBrTEsPTXe\",\"customer_id\":\"cust_8jv29tdSNEpQj5\",\"status\":\"created\",\"current_start\":null,\"current_end\":null,\"ended_at\":null,\"quantity\":1,\"notes\":[],\"charge_at\":1512068870,\"start_at\":1512068870,\"end_at\":1517423400,\"auth_attempts\":0,\"total_count\":3,\"paid_count\":0,\"customer_notify\":true,\"created_at\":1512065352}"
read 379 bytes
Conn close
=> #<Razorpay::Subscription:0x00000001d489f0 @attributes={"id"=>"sub_97lvgp0x2kyAEZ", "entity"=>"subscription", "plan_id"=>"plan_97l6xBrTEsPTXe", "customer_id"=>"cust_8jv29tdSNEpQj5", "status"=>"created", "current_start"=>nil, "current_end"=>nil, "ended_at"=>nil, "quantity"=>1, "notes"=>[], "charge_at"=>1512068870, "start_at"=>1512068870, "end_at"=>1517423400, "auth_attempts"=>0, "total_count"=>3, "paid_count"=>0, "customer_notify"=>true, "created_at"=>1512065352}>
I was unable to find any integration with Razorpay-X payouts api. Is there any plans for adding it to this gem?
Razorpay Integration on Spree commerce 4.1
When I write on console..
customer = Razorpay::Customer.create email: '[email protected]', contact: '9876543210'
it shows me an error: NameError: uninitialized constant Razorpay::Customer
Fix for this?
When i am hitting the Subscription Create API from postman(/v1/subscriptions), its successfully executing the request
But when same data i am passing through Razorpay Ruby library, its throwing exception.
Razorpay::Subscription.create(data)
Response:
The addons may not have more than 5 items.
Request Data
{"plan_id":"plan_AFQOIFJkuhkzNl", "customer_notify":1, "total_count":10, "addons": [{"item": {"name":"Keto Bundle - BundleVariant1", "amount":300000, "currency":"INR"}}, {"item": {"name":"Ancient Grain Low Carb Amazon - 500g", "amount":27500, "currency":"INR"}}]}
What could be the possible reason for this?
We are using httparty 0.8 and razorpay has dependency on 'httparty', '~> 0.13'
Therefore I`m getting an error while installing bundle. Changing the dependency to httparty 0.8 solves my problem!. Will this change affect any other aspect?
Requestbin - http://requestbin.net/r/zqlgjlzq?inspect
irb> rp = '{"entity":"event","account_id":"acc_CEOgayStbojn2W","event":"refund.created","contains":["refund"],"payload":{"refund":{"entity":{"id":"rfnd_DzcgZ2NB9jkUsY","entity":"refund","amount":22500,"currency":"INR","payment_id":"pay_DzcPVgs5suYXTd","notes":{"comment":""},"receipt":null,"acquirer_data":{},"created_at":1577971510}}},"created_at":1577971510}'
irb> sig = '71b7f3f610ffd99819d8aa1712d909c2a77f7e88dae7283700bf88a851ce99f5'
irb> secret = 'L26zm9kjbmx@JqH'
irb> Razorpay::Utility.verify_webhook_signature(rp, sig, secret)
SecurityError: Signature verification failed
PS: The secret is from our test account.
is there any proper documentation for all functions available in this sdk?
Certain classes, such as Invoice
, Card
, Customer
within the Razorpay module as not accessible.
I get the following errors:
NameError: uninitialized constant Razorpay::Card
NameError: uninitialized constant Razorpay::Invoice
NameError: uninitialized constant Razorpay::Customer
The other classes, such as Order
, Payment
, etc. are working fine.
I tried going through the code, but couldn't find out why. Any ideas?
this is a test issue to check the integration with slack. please ignore
I am able to create a invoice with the type 'link' as per the syntax given.
But when i try to change the type to 'invoice' it throws a error.
code snippet:
invoice = Razorpay::Invoice.create type: 'invoice',customer_id: "cust_CHYKFUnfRjWbEj", line_items: [{item_id: "item_CHYCYqNuYFviS2" }], currency: 'INR',sms_notify: "1",email_notify: "1"
In the case of Subscriptions
, the order in which razorpay_payment_id
and subscription_id
are joined is wrong. I don't know why Razorpay has implemented it in reverse order compared to orders API.
But verify_payment_signature
is not working properly for Subscriptions
.
refer to this link
So, i'm able to create invoices using the basic syntax as so:
Razorpay::Invoice.create amount: 100, currency: 'INR', description: 'Test description', type: 'link'
How do I include name and email for the customer in this syntax.
I have downloaded sample application razorpay from this url https://github.com/devathon/razorpay-rails-sample-app. In this application you have used Rails 4 but I am using Rails 5.1. But order details are not getting saved into database in rails5.1. So, Could you please tell me why it is not getting saved in rails5.1?
Hello Team,
We want to charge customer's card after it is authenticated. Scenario could be when there is a failed subscription.
Let me know if there is already a way to achieve this.
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.