razorpay / razorpay-ruby

Razorpay Ruby SDK
https://rubygems.org/gems/razorpay
MIT License
64 stars 59 forks source link

Invoice::Create API #52

Closed akashdevaraju closed 6 years ago

akashdevaraju commented 6 years ago

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.

pikender commented 6 years ago

@akashdevaraju does below request answers your question ?

2.3.3 :002 > Razorpay::Invoice.create amount: 100, currency: 'INR', description: 'Test description', type: 'link', customer: {name: 'me you yes', email: 'me@you.com'}
opening connection to api.razorpay.com:443...
opened
starting SSL for api.razorpay.com:443...
SSL established
<- "POST /v1/invoices HTTP/1.1\r\nUser-Agent: Razorpay-Ruby/2.1.0\r\nAuthorization: Basic xxxx\r\nConnection: close\r\nHost: api.razorpay.com\r\nContent-Length: 123\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n"
<- "amount=100&currency=INR&description=Test%20description&type=link&customer[name]=me%20you%20yes&customer[email]=me%40you.com"
-> "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: Fri, 05 Jan 2018 12:23:28 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: 923\r\n"
-> "Connection: Close\r\n"
-> "\r\n"
reading 923 bytes...
-> "{\"id\":\"inv_9LvGp8YKPYIyg2\",\"entity\":\"invoice\",\"receipt\":null,\"invoice_number\":null,\"customer_id\":\"cust_9LvBP1f6aZ1nrq\",\"customer_details\":{\"name\":\"me you yes\",\"email\":\"me@you.com\",\"contact\":null,\"billing_address\":null,\"customer_name\":\"me you yes\",\"customer_email\":\"me@you.com\",\"customer_contact\":null},\"order_id\":\"order_9LvGp9NYj7PTHZ\",\"line_items\":[],\"payment_id\":null,\"status\":\"issued\",\"expire_by\":null,\"issued_at\":1515155008,\"paid_at\":null,\"cancelled_at\":null,\"expired_at\":null,\"sms_status\":\"pending\",\"email_status\":\"pending\",\"date\":1515155008,\"terms\":null,\"partial_payment\":false,\"gross_amount\":100,\"tax_amount\":0,\"amount\":100,\"amount_paid\":0,\"amount_due\":100,\"currency\":\"INR\",\"description\":\"Test description\",\"notes\":[],\"comment\":null,\"short_url\":\"https:\\/\\/rzp.io\\/i\\/bOzbcP3\",\"view_less\":true,\"billing_start\":null,\"billing_end\":null,\"type\":\"link\",\"group_taxes_discounts\":false,\"user_id\":null,\"created_at\":1515155008}"
read 923 bytes
Conn close
 => #<Razorpay::Invoice:0x000000017f7348 @attributes={"id"=>"inv_9LvGp8YKPYIyg2", "entity"=>"invoice", "receipt"=>nil, "invoice_number"=>nil, "customer_id"=>"cust_9LvBP1f6aZ1nrq", "customer_details"=>{"name"=>"me you yes", "email"=>"me@you.com", "contact"=>nil, "billing_address"=>nil, "customer_name"=>"me you yes", "customer_email"=>"me@you.com", "customer_contact"=>nil}, "order_id"=>"order_9LvGp9NYj7PTHZ", "line_items"=>[], "payment_id"=>nil, "status"=>"issued", "expire_by"=>nil, "issued_at"=>1515155008, "paid_at"=>nil, "cancelled_at"=>nil, "expired_at"=>nil, "sms_status"=>"pending", "email_status"=>"pending", "date"=>1515155008, "terms"=>nil, "partial_payment"=>false, "gross_amount"=>100, "tax_amount"=>0, "amount"=>100, "amount_paid"=>0, "amount_due"=>100, "currency"=>"INR", "description"=>"Test description", "notes"=>[], "comment"=>nil, "short_url"=>"https://rzp.io/i/bOzbcP3", "view_less"=>true, "billing_start"=>nil, "billing_end"=>nil, "type"=>"link", "group_taxes_discounts"=>false, "user_id"=>nil, "created_at"=>1515155008}> 
akashdevaraju commented 6 years ago

Works! thanks a bunch @pikender