-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.1 improvements #4
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ade415f
Fixed payment detail endpoint to use the correct class.
ashwch b2f7e20
Added a class for Payment Request as well
ashwch 7e5c83e
Added payment_request to gemspec and the base imports
ashwch fd9190f
Payment Request endpoints are now using the PaymentRequest class
ashwch b7f78b5
Removed the space
ashwch 75c9383
Updated README
ashwch 8df0f7f
Copy-paste miftake
ashwch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,21 +143,19 @@ payment.to_h | |
This is a part of [RAP API](https://www.instamojo.com/developers/request-a-payment-api/). You can request a payment from anyone via this who will then be notified to make a payment with specified payment. The payment then can be carried out via [Instapay](https://www.instamojo.com/pay/). Jump over to the documentation to see accepted parameters. | ||
##### Code: | ||
```ruby | ||
payment = client.payment_request({amount:100, purpose: 'api', send_email: true, email: '[email protected]', redirect_url: 'http://ankurgoel.com'}) | ||
#=> Returns response of payment request. | ||
p client.response.body[:payment_request] | ||
#=> Print status & details of payment_request. Details will also contain unique id which can be used to request the status of payment request later. | ||
payment_request = client.payment_request({amount:100, purpose: 'api', send_email: true, email: '[email protected]', redirect_url: 'http://ankurgoel.com'}) | ||
#=> Instamojo PaymentRequest(id: 8726f8c5001e426f8b24e908b2761686, purpose: api, amount: 100.00, status: Sent, shorturl: , longurl: https://www.instamojo.com/@ashwini/8726f8c5001e426f8b24e908b2761686) | ||
``` | ||
#### Get Payment Requests | ||
```ruby | ||
response = client.payment_requests_list | ||
#=> Returns response for all payment_requests with their status | ||
#=> Returns array of PaymentRequest objects | ||
``` | ||
#### Status of payment request | ||
You can get the status of a payment_request from the id you obtained after making payment request. | ||
```ruby | ||
client.payment_request_status('payment_request_id_goes_here') | ||
#=> Returns response containing the status of payment request. | ||
payment_request = client.payment_request_status('8726f8c5001e426f8b24e908b2761686') | ||
#=> Instamojo PaymentRequest(id: 8726f8c5001e426f8b24e908b2761686, purpose: api, amount: 100.00, status: Sent, shorturl: http://imjo.in/Nasdf , longurl: https://www.instamojo.com/@ashwini/8726f8c5001e426f8b24e908b2761686) | ||
``` | ||
--- | ||
### Refunds | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Instamojo | ||
|
||
=begin Example | ||
{ | ||
"id" => "92e58bd771414d05a5e443b0a85f8b43", | ||
"phone" => "+919999999999", | ||
"email" => "[email protected]", | ||
"buyer_name" => "John Doe", | ||
"amount" => "2500", | ||
"purpose" => "FIFA 16", | ||
"status" => "Pending", | ||
"send_sms" => true, | ||
"send_email" => true, | ||
"sms_status" => "Pending", | ||
"email_status" => "Pending", | ||
"shorturl" => nil, | ||
"longurl" => "https://www.instamojo.com/@ashwini/92e58bd771414d05a5e443b0a85f8b43", | ||
"redirect_url" => "http://www.example.com/redirect/", | ||
"webhook" => "http://www.example.com/webhook/", | ||
"created_at" => "2015-10-07T21:36:34.665Z", | ||
"modified_at" => "2015-10-07T21:36:34.665Z", | ||
"allow_repeated_payments" => false | ||
} | ||
=end | ||
|
||
class PaymentRequest | ||
attr_accessor :id, :phone, :email, :buyer_name, :amount, :purpose, :status, :send_sms, :send_email, :sms_status | ||
attr_accessor :email_status, :shorturl, :longurl, :redirect_url, :webhook, :created_at, :modified_at, :allow_repeated_payments | ||
|
||
attr_reader :original | ||
include CommonObject | ||
|
||
def initialize(payment_request, client) | ||
@original = payment_request | ||
payment_request.each do |k, v| | ||
instance_variable_set("@#{k}", v) | ||
end | ||
@client = client # Reference to client | ||
end | ||
|
||
def to_s | ||
sprintf("Instamojo PaymentRequest(id: %s, purpose: %s, amount: %s, status: %s, shorturl: %s, longurl: %s)", | ||
id, purpose, amount, status, shorturl, longurl) | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn! my bad 😆