-
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
Changes from 3 commits
c46ee6c
85a453a
6436192
194133c
ee8441e
3b7970e
75f75c0
b7f55ec
4baba13
23228a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -863,6 +863,253 @@ Razorpay::Iin.fetch(tokenIin); | |||
} | ||||
``` | ||||
------------------------------------------------------------------------------------------------------- | ||||
------------------------------------------------------------------------------------------------------- | ||||
|
||||
### Fetch a Payment (With Expanded EMI Details) | ||||
|
||||
```rb | ||||
Razorpay::Payment.fetch("pay_XXXXXXXXXXXXXX").expendDetails({"expand[]": "emi"}) | ||||
``` | ||||
|
||||
**Parameters:** | ||||
|
||||
| Name | Type | Description | | ||||
|-------------|---------|------------------------------------------------------------------| | ||||
| paymentId* | integer | Unique identifier of the payment | | ||||
| expand[] | string | Use to expand the `emi` details when the payment method is emi. | | ||||
|
||||
**Response:** <br> | ||||
|
||||
```json | ||||
{ | ||||
"id": "pay_DG4ZdRK8ZnXC3k", | ||||
"entity": "payment", | ||||
"amount": 200000, | ||||
"currency": "INR", | ||||
"status": "authorized", | ||||
"order_id": null, | ||||
"invoice_id": null, | ||||
"international": false, | ||||
"method": "emi", | ||||
"amount_refunded": 0, | ||||
"refund_status": null, | ||||
"captured": false, | ||||
"description": null, | ||||
"card_id": "card_DG4ZdUO3xABb20", | ||||
"bank": "ICIC", | ||||
"wallet": null, | ||||
"vpa": null, | ||||
"email": "[email protected]", | ||||
"contact": "+919972000005", | ||||
"notes": [], | ||||
"fee": null, | ||||
"tax": null, | ||||
"error_code": null, | ||||
"error_description": null, | ||||
"error_source": null, | ||||
"error_step": null, | ||||
"error_reason": null, | ||||
"emi": { | ||||
"issuer": "ICIC", | ||||
"rate": 1300, | ||||
"duration": 6 | ||||
}, | ||||
"acquirer_data": { | ||||
"auth_code": "828553" | ||||
}, | ||||
"created_at": 1568026077 | ||||
} | ||||
``` | ||||
------------------------------------------------------------------------------------------------------- | ||||
|
||||
### Fetch a Payment (With Expanded Card Details) | ||||
|
||||
```rb | ||||
Razorpay::Payment.fetch("pay_XXXXXXXXXXXXXX").expendDetails({"expand[]": "card"}) | ||||
``` | ||||
|
||||
**Parameters:** | ||||
|
||||
| Name | Type | Description | | ||||
|-------------|---------|---------------------------------------------------------------------| | ||||
| paymentId* | integer | Unique identifier of the payment | | ||||
| expand[] | string | Use to expand the card details when the payment method is `card`. | | ||||
|
||||
**Response:** <br> | ||||
|
||||
```json | ||||
{ | ||||
"id": "pay_H9oR0gLCaVlV6m", | ||||
"entity": "payment", | ||||
"amount": 100, | ||||
"currency": "INR", | ||||
"status": "failed", | ||||
"order_id": "order_H9o58N6qmLYQKC", | ||||
"invoice_id": null, | ||||
"terminal_id": "term_G5kJnYM9GhhLYT", | ||||
"international": false, | ||||
"method": "card", | ||||
"amount_refunded": 0, | ||||
"refund_status": null, | ||||
"captured": false, | ||||
"description": null, | ||||
"card_id": "card_H9oR0ocen1cmZq", | ||||
"card": { | ||||
"id": "card_H9oR0ocen1cmZq", | ||||
"entity": "card", | ||||
"name": "Gaurav", | ||||
"last4": "1213", | ||||
"network": "RuPay", | ||||
"type": "credit", | ||||
"issuer": "UTIB", | ||||
"international": false, | ||||
"emi": false, | ||||
"sub_type": "business" | ||||
}, | ||||
"bank": null, | ||||
"wallet": null, | ||||
"vpa": null, | ||||
"email": "[email protected]", | ||||
"contact": "+919000090000", | ||||
"notes": { | ||||
"email": "[email protected]", | ||||
"phone": "09000090000" | ||||
}, | ||||
"fee": null, | ||||
"tax": null, | ||||
"error_code": "BAD_REQUEST_ERROR", | ||||
"error_description": "Card issuer is invalid", | ||||
"error_source": "customer", | ||||
"error_step": "payment_authentication", | ||||
"error_reason": "incorrect_card_details", | ||||
"acquirer_data": { | ||||
"auth_code": null, | ||||
"authentication_reference_number": "100222021120200000000742753928" | ||||
}, | ||||
"created_at": 1620807547 | ||||
} | ||||
``` | ||||
|
||||
------------------------------------------------------------------------------------------------------- | ||||
|
||||
### Fetch a Payment (With Expanded Offers Details) | ||||
|
||||
```rb | ||||
Razorpay::Payment.fetch("pay_XXXXXXXXXXXXXX").expendDetails({"expand[]": "offers"}) | ||||
``` | ||||
|
||||
**Parameters:** | ||||
|
||||
| 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. changed razorpay-ruby/documents/payment.md Line 1006 in ee8441e
|
||||
|
||||
**Response:** <br> | ||||
|
||||
```json | ||||
{ | ||||
"id": "pay_DG4ZdRK8ZnXC3k", | ||||
"entity": "payment", | ||||
"amount": 200000, | ||||
"currency": "INR", | ||||
"status": "authorized", | ||||
"order_id": null, | ||||
"invoice_id": null, | ||||
"international": false, | ||||
"method": "emi", | ||||
"amount_refunded": 0, | ||||
"refund_status": null, | ||||
"captured": false, | ||||
"description": null, | ||||
"card_id": "card_DG4ZdUO3xABb20", | ||||
"bank": "ICIC", | ||||
"wallet": null, | ||||
"vpa": null, | ||||
"email": "[email protected]", | ||||
"contact": "+919972000005", | ||||
"notes": [], | ||||
"fee": null, | ||||
"tax": null, | ||||
"error_code": null, | ||||
"error_description": null, | ||||
"error_source": null, | ||||
"error_step": null, | ||||
"error_reason": null, | ||||
"emi": { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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
|
||||
"issuer": "ICIC", | ||||
"rate": 1300, | ||||
"duration": 6 | ||||
}, | ||||
"acquirer_data": { | ||||
"auth_code": "828553" | ||||
}, | ||||
"created_at": 1568026077 | ||||
} | ||||
``` | ||||
|
||||
------------------------------------------------------------------------------------------------------- | ||||
|
||||
### Fetch a Payment (With Expanded UPI Details) | ||||
|
||||
```rb | ||||
Razorpay::Payment.fetch("pay_XXXXXXXXXXXXXX").expendDetails({"expand[]": "upi"}) | ||||
``` | ||||
|
||||
**Parameters:** | ||||
|
||||
| Name | Type | Description | | ||||
|-------------|---------|--------------------------------------------------------------| | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Update table format razorpay-ruby/documents/payment.md Line 1067 in ee8441e
|
||||
| paymentId* | integer | Unique identifier of the payment | | ||||
| expand[] | string | Use to expand the UPI details when the payment method is upi. | | ||||
|
||||
**Response:** <br> | ||||
|
||||
```json | ||||
{ | ||||
"id": "pay_DG4ZdRK8ZnXC3k", | ||||
"entity": "payment", | ||||
"amount": 100, | ||||
"currency": "INR", | ||||
"status": "captured", | ||||
"order_id": "order_GjCr5oKh4AVC51", | ||||
"invoice_id": null, | ||||
"international": false, | ||||
"method": "upi", | ||||
"amount_refunded": 0, | ||||
"refund_status": null, | ||||
"captured": true, | ||||
"description": "Payment for Adidas shoes", | ||||
"card_id": null, | ||||
"bank": null, | ||||
"wallet": null, | ||||
"vpa": "gaurav.kumar@upi", | ||||
"email": "[email protected]", | ||||
"contact": "9000090000", | ||||
"customer_id": "cust_K6fNE0WJZWGqtN", | ||||
"token_id": "token_KOdY$DBYQOv08n", | ||||
"notes": [], | ||||
"fee": 1, | ||||
"tax": 0, | ||||
"error_code": null, | ||||
"error_description": null, | ||||
"error_source": null, | ||||
"error_step": null, | ||||
"error_reason": null, | ||||
"acquirer_data": { | ||||
"rrn": "303107535132" | ||||
}, | ||||
"created_at": 1605871409, | ||||
"upi": { | ||||
"payer_account_type": "credit_card", | ||||
"vpa": "gaurav.kumar@upi", | ||||
"flow": "in_app" // appears only for Turbo UPI Payments. | ||||
} | ||||
} | ||||
``` | ||||
|
||||
------------------------------------------------------------------------------------------------------- | ||||
|
||||
**PN: * indicates mandatory fields** | ||||
<br> | ||||
<br> | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"id": "fake_payment_id", | ||
"entity": "payment", | ||
"amount": 200000, | ||
"currency": "INR", | ||
"status": "authorized", | ||
"order_id": null, | ||
"invoice_id": null, | ||
"international": false, | ||
"method": "emi", | ||
"amount_refunded": 0, | ||
"refund_status": null, | ||
"captured": false, | ||
"description": null, | ||
"card_id": "card_DG4ZdUO3xABb20", | ||
"bank": "ICIC", | ||
"wallet": null, | ||
"vpa": null, | ||
"email": "[email protected]", | ||
"contact": "+919972000005", | ||
"notes": [], | ||
"fee": null, | ||
"tax": null, | ||
"error_code": null, | ||
"error_description": null, | ||
"error_source": null, | ||
"error_step": null, | ||
"error_reason": null, | ||
"emi": { | ||
"issuer": "ICIC", | ||
"rate": 1300, | ||
"duration": 6 | ||
}, | ||
"acquirer_data": { | ||
"auth_code": "828553" | ||
}, | ||
"created_at": 1568026077 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"id": "fake_payment_id", | ||
"entity": "payment", | ||
"amount": 100, | ||
"currency": "INR", | ||
"status": "failed", | ||
"order_id": "order_H9o58N6qmLYQKC", | ||
"invoice_id": null, | ||
"terminal_id": "term_G5kJnYM9GhhLYT", | ||
"international": false, | ||
"method": "card", | ||
"amount_refunded": 0, | ||
"refund_status": null, | ||
"captured": false, | ||
"description": null, | ||
"card_id": "card_H9oR0ocen1cmZq", | ||
"card": { | ||
"id": "card_H9oR0ocen1cmZq", | ||
"entity": "card", | ||
"name": "Gaurav", | ||
"last4": "1213", | ||
"network": "RuPay", | ||
"type": "credit", | ||
"issuer": "UTIB", | ||
"international": false, | ||
"emi": false, | ||
"sub_type": "business" | ||
}, | ||
"bank": null, | ||
"wallet": null, | ||
"vpa": null, | ||
"email": "[email protected]", | ||
"contact": "+919000090000", | ||
"notes": { | ||
"email": "[email protected]", | ||
"phone": "09000090000" | ||
}, | ||
"fee": null, | ||
"tax": null, | ||
"error_code": "BAD_REQUEST_ERROR", | ||
"error_description": "Card issuer is invalid", | ||
"error_source": "customer", | ||
"error_step": "payment_authentication", | ||
"error_reason": "incorrect_card_details", | ||
"acquirer_data": { | ||
"auth_code": null, | ||
"authentication_reference_number": "100222021120200000000742753928" | ||
}, | ||
"created_at": 1620807547 | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -298,6 +298,18 @@ 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 | ||||
end | ||||
|
||||
def test_expendDetails_emi | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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
|
||||
stub_get("#{BASE_URI}/v1/payments/#{@payment_id}/?expand[]=emi", 'fake_payment_expended_details') | ||||
payment = Razorpay::Payment.fetch(@payment_id).expendDetails | ||||
assert_equal @payment_id, payment.id | ||||
end | ||||
|
||||
def test_expendDetails_card | ||||
stub_get("#{BASE_URI}/v1/payments/#{@payment_id}/?expand[]=card", 'fake_payment_expended_details') | ||||
payment = Razorpay::Payment.fetch(@payment_id).expendDetails | ||||
assert_equal @payment_id, payment.id | ||||
end | ||||
end | ||||
end |
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