-
Notifications
You must be signed in to change notification settings - Fork 59
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
update payment #249
update payment #249
Conversation
documents/payment.md
Outdated
### Fetch a Payment (With Expanded EMI Details) | ||
|
||
```rb | ||
Razorpay::Payment.fetch("pay_XXXXXXXXXXXXXX").expendDetails({"expand[]": "emi"}) |
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.
Are we making two requests to the BE for this ?
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.
Yes it's like a chain request for better readablity.
We also used this in payment.
https://github.com/razorpay/razorpay-ruby/blob/master/documents/payment.md?plain=1#L250
Should I change it to a single request ?
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.
Request chaining does not seem optimal here. Two http requests are being made instead of a single request here ? Is there any reason why we have adopted this pattern in ruby sdk ?
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.
Made a single request instead of chaining
test/razorpay/test_payment.rb
Outdated
@@ -298,6 +298,12 @@ def test_validate_vpa | |||
stub_post(%r{payments/validate/vpa$}, 'fake_validate_vpa',param_attr.to_json) | |||
payment = Razorpay::Payment.validate_vpa param_attr.to_json | |||
assert_equal param_attr[:vpa], payment.vpa | |||
end | |||
|
|||
def test_expendDetails |
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.
can you also add test cases for other options like cards and offers and error scenarios
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.
Added for card
documents/payment.md
Outdated
| Name | Type | Description | | ||
|-------------|---------|----------------------------------------------------------------| | ||
| paymentId* | integer | Unique identifier of the payment | | ||
| expand[] | string | Use to expand the emi details when the payment method is emi. | |
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.
Update the description for offers.
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.
changed emi
to offer
razorpay-ruby/documents/payment.md
Line 1006 in ee8441e
| expand[] | string | Use to expand the offers applied to a payment. | |
documents/payment.md
Outdated
"error_source": null, | ||
"error_step": null, | ||
"error_reason": null, | ||
"emi": { |
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.
This response seems to contain expanded details for emi. Can you update it relevant for offers ?
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.
Updated to offer response
razorpay-ruby/documents/payment.md
Line 1024 in ee8441e
"offers": { |
documents/payment.md
Outdated
**Parameters:** | ||
|
||
| Name | Type | Description | | ||
|-------------|---------|--------------------------------------------------------------| |
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.
please format the table
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.
Update table format
razorpay-ruby/documents/payment.md
Line 1067 in ee8441e
| Name | Type | Description | |
test/razorpay/test_payment.rb
Outdated
end | ||
end | ||
|
||
def test_expendDetails_emi |
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.
please add test case for 5xx response for fetch api
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.
We can't mock the response status.
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.
Added BAD REQUEST json to test the failure cases
razorpay-ruby/test/razorpay/test_payment.rb
Line 315 in ee8441e
def test_expend_details_failure |
lib/razorpay/payment.rb
Outdated
@@ -112,5 +112,9 @@ def self.create_upi(data={}) | |||
def self.validate_vpa(data={}) | |||
request.post "validate/vpa" , data | |||
end | |||
|
|||
def self.expend_details(id, options={}) |
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.
Can this function name be expand_details
instead ?
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.
made correction in payment.rb
, payment.md
& in unit test file
razorpay-ruby/lib/razorpay/payment.rb
Line 116 in 75f75c0
def self.expand_details(id, options={}) |
documents/payment.md
Outdated
### Fetch a Payment (With Expanded EMI Details) | ||
|
||
```rb | ||
Razorpay::Payment.expendDetails("pay_XXXXXXXXXXXXXX",{"expand[]": "emi"}) |
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.
please update the function name here
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.
updated
razorpay-ruby/documents/payment.md
Line 871 in 4baba13
Razorpay::Payment.expand_details("pay_XXXXXXXXXXXXXX",{"expand[]": "emi"}) |
Add Doc Reference
Fetch a Payment (With Expanded Card Details)
Fetch a Payment (With Expanded EMI Details)
Fetch a Payment (With Expanded Offers Details)