Giter Club home page Giter Club logo

razorpay-ruby's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

razorpay-ruby's Issues

OpenSSL error on OS X

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.

ActiveRecord::UnknownAttributeError: unknown attribute: entity

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)

Proper language specific documentation missing.

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

  1. For fetching payments:
    Razorpay::Payment.fetch("pay_29QQoUBi66xm2f")
  2. For refund
    Razorpay::Payment.fetch("pay_DgExayLn3RBbZX").refund()

I could not find documentation for:

  1. What are the return value of these methods.
  2. What kind of exceptions are raised or thrown by these methods?
  3. Method documentations for Payment and other classes.

Kindly provide language specific documentation for ruby, python and other languages.

Razorpay::Payment object status improvement

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.

'method' seems to be reserved in rails

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!

Payment link create API requiring line_items

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.

verify_payment_signature doesn't work. Use Rack::Utils secure compare instead.

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. πŸ˜„

Razorpay::BadRequestError: The plan id field is required

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.

LoadError - cannot load such file -- razorpay/bad_request_error:

razorpay
Getting LoadError - cannot load such file -- razorpay/bad_request_error: when capture failed

in file lib/razorpay/request.rb
change
require "razorpay/#{error['code'].downcase}"
to
require "razorpay/errors/#{error['code'].downcase}"
now it is getting response error object

Allow using multiple merchant accounts in a single project

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.

Integrate sub merchant

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
  ...

`verify_payment_signature` always return `nil`

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}]}>

Create linked account is present?

Hi, I'm exploring and building the linked account for Razorpay route, is the module available in this library, if yes then which method?

Razorpay::Payment.fetch(payment_id).capture({amount:amount}) throwing error.

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

Need a provision to edit customer's card details

Hello Team,

We would like to have a provision to edit customer's card details via customer id.
Flow could be as follow:

  1. We will ask customer to provide card details that they want to update. (On failed subscription or to update card details)
  2. We will send API request to Razorpay to authenticate new card details.
  3. On successful authorisation, Razorpay would send success message and we will update new razorpay_card_id to our system.
  4. Finally, subsequent subscription should be charged from new card details.

This would be very helpful for us to provide ease to our customers.

Thanks in advance!

payment.method does not work properly

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)

Razorpay payment link not working in test mode

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"

Virtual Account API not working

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

ArgumentError: wrong number of arguments (given 2, expected 1)

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?

[Discussion] Subscription Create with addons fails and the solution

Subscription create with upfront fees as addons fails

Scenario

  • Subscription Api allows sending addons while creating subscriptions as a way to charge upfront fees
  • When addons are passed with subscriptions, it fails with error 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.
  • When custom headers are set to use application/json and data passed as json, it works.

Discussion

  • 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 ?

API Log

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}> 

Support for Razorpay-X APIs

I was unable to find any integration with Razorpay-X payouts api. Is there any plans for adding it to this gem?

Getting error "The addons may not have more than 5 items."

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?

Httparty 0.13 Dependency issue

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?

Razorpay::Utility.verify_webhook_signature not working as expected

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.

Unable to access certain classes within Razorpay module

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?

test issue

this is a test issue to check the integration with slack. please ignore

Error while creating a invoice

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"

Invoice::Create API

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.