razorpay 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +2 -0
- data/documents/customer.md +242 -0
- data/documents/dispute.md +301 -0
- data/documents/documents.md +65 -0
- data/documents/order.md +71 -0
- data/documents/payment.md +253 -0
- data/documents/transfers.md +40 -0
- data/lib/razorpay/constants.rb +1 -1
- data/lib/razorpay/customer.rb +16 -0
- data/lib/razorpay/dispute.rb +26 -0
- data/lib/razorpay/document.rb +19 -0
- data/lib/razorpay/order.rb +8 -0
- data/lib/razorpay/payment.rb +4 -0
- data/lib/razorpay/transfer.rb +4 -0
- data/lib/razorpay.rb +2 -0
- data/test/fixtures/dispute_collection.json +67 -0
- data/test/fixtures/dispute_error.json +10 -0
- data/test/fixtures/document_error.json +10 -0
- data/test/fixtures/error_customer.json +10 -0
- data/test/fixtures/error_eligibility.json +10 -0
- data/test/fixtures/error_eligibility_check.json +10 -0
- data/test/fixtures/fake_bank_account.json +9 -0
- data/test/fixtures/fake_dispute.json +29 -0
- data/test/fixtures/fake_document.json +9 -0
- data/test/fixtures/fake_eligiblity.json +79 -0
- data/test/fixtures/fake_fulfillment.json +10 -0
- data/test/fixtures/fake_payment_expanded_details.json +38 -0
- data/test/fixtures/fake_payment_expanded_details_card.json +50 -0
- data/test/fixtures/fake_rto.json +15 -0
- data/test/fixtures/order_error.json +10 -0
- data/test/fixtures/payment_error.json +10 -0
- data/test/fixtures/reversals_collection.json +22 -0
- data/test/fixtures/transfer_error.json +10 -0
- data/test/razorpay/test_customer.rb +105 -0
- data/test/razorpay/test_dispute.rb +98 -0
- data/test/razorpay/test_document.rb +27 -0
- data/test/razorpay/test_order.rb +43 -1
- data/test/razorpay/test_payment.rb +23 -1
- data/test/razorpay/test_transfer.rb +17 -0
- metadata +47 -3
@@ -0,0 +1,79 @@
|
|
1
|
+
{
|
2
|
+
"amount": "500000",
|
3
|
+
"customer": {
|
4
|
+
"id": "KkBhM9EC1Y0HTm",
|
5
|
+
"contact": "+918220722114"
|
6
|
+
},
|
7
|
+
"instruments": [
|
8
|
+
{
|
9
|
+
"method": "emi",
|
10
|
+
"issuer": "HDFC",
|
11
|
+
"type": "debit",
|
12
|
+
"eligibility_req_id": "elig_KkCNLzlNeMYQyZ",
|
13
|
+
"eligibility": {
|
14
|
+
"status": "eligible"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"method": "paylater",
|
19
|
+
"provider": "getsimpl",
|
20
|
+
"eligibility_req_id": "elig_KkCNLzlNeMYQyZ",
|
21
|
+
"eligibility": {
|
22
|
+
"status": "eligible"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"method": "paylater",
|
27
|
+
"provider": "icic",
|
28
|
+
"eligibility_req_id": "elig_KkCNLzlNeMYQyZ",
|
29
|
+
"eligibility": {
|
30
|
+
"status": "eligible"
|
31
|
+
}
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"method": "cardless_emi",
|
35
|
+
"provider": "walnut369",
|
36
|
+
"eligibility_req_id": "elig_KkCNLzlNeMYQyZ",
|
37
|
+
"eligibility": {
|
38
|
+
"status": "ineligible",
|
39
|
+
"error": {
|
40
|
+
"code": "GATEWAY_ERROR",
|
41
|
+
"description": "The customer has not been approved by the partner.",
|
42
|
+
"source": "business",
|
43
|
+
"step": "inquiry",
|
44
|
+
"reason": "user_not_approved"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"method": "cardless_emi",
|
50
|
+
"provider": "zestmoney",
|
51
|
+
"eligibility_req_id": "elig_KkCNLzlNeMYQyZ",
|
52
|
+
"eligibility": {
|
53
|
+
"status": "ineligible",
|
54
|
+
"error": {
|
55
|
+
"code": "GATEWAY_ERROR",
|
56
|
+
"description": "The customer has exhausted their credit limit.",
|
57
|
+
"source": "business",
|
58
|
+
"step": "inquiry",
|
59
|
+
"reason": "credit_limit_exhausted"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"method": "paylater",
|
65
|
+
"provider": "lazypay",
|
66
|
+
"eligibility_req_id": "elig_KkCNLzlNeMYQyZ",
|
67
|
+
"eligibility": {
|
68
|
+
"status": "ineligible",
|
69
|
+
"error": {
|
70
|
+
"code": "GATEWAY_ERROR",
|
71
|
+
"description": "The order amount is less than the minimum transaction amount.",
|
72
|
+
"source": "business",
|
73
|
+
"step": "inquiry",
|
74
|
+
"reason": "min_amt_required"
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
]
|
79
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"id": "fake_payment_id",
|
3
|
+
"entity": "payment",
|
4
|
+
"amount": 200000,
|
5
|
+
"currency": "INR",
|
6
|
+
"status": "authorized",
|
7
|
+
"order_id": null,
|
8
|
+
"invoice_id": null,
|
9
|
+
"international": false,
|
10
|
+
"method": "emi",
|
11
|
+
"amount_refunded": 0,
|
12
|
+
"refund_status": null,
|
13
|
+
"captured": false,
|
14
|
+
"description": null,
|
15
|
+
"card_id": "card_DG4ZdUO3xABb20",
|
16
|
+
"bank": "ICIC",
|
17
|
+
"wallet": null,
|
18
|
+
"vpa": null,
|
19
|
+
"email": "gaurav@example.com",
|
20
|
+
"contact": "+919972000005",
|
21
|
+
"notes": [],
|
22
|
+
"fee": null,
|
23
|
+
"tax": null,
|
24
|
+
"error_code": null,
|
25
|
+
"error_description": null,
|
26
|
+
"error_source": null,
|
27
|
+
"error_step": null,
|
28
|
+
"error_reason": null,
|
29
|
+
"emi": {
|
30
|
+
"issuer": "ICIC",
|
31
|
+
"rate": 1300,
|
32
|
+
"duration": 6
|
33
|
+
},
|
34
|
+
"acquirer_data": {
|
35
|
+
"auth_code": "828553"
|
36
|
+
},
|
37
|
+
"created_at": 1568026077
|
38
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"id": "fake_payment_id",
|
3
|
+
"entity": "payment",
|
4
|
+
"amount": 100,
|
5
|
+
"currency": "INR",
|
6
|
+
"status": "failed",
|
7
|
+
"order_id": "order_H9o58N6qmLYQKC",
|
8
|
+
"invoice_id": null,
|
9
|
+
"terminal_id": "term_G5kJnYM9GhhLYT",
|
10
|
+
"international": false,
|
11
|
+
"method": "card",
|
12
|
+
"amount_refunded": 0,
|
13
|
+
"refund_status": null,
|
14
|
+
"captured": false,
|
15
|
+
"description": null,
|
16
|
+
"card_id": "card_H9oR0ocen1cmZq",
|
17
|
+
"card": {
|
18
|
+
"id": "card_H9oR0ocen1cmZq",
|
19
|
+
"entity": "card",
|
20
|
+
"name": "Gaurav",
|
21
|
+
"last4": "1213",
|
22
|
+
"network": "RuPay",
|
23
|
+
"type": "credit",
|
24
|
+
"issuer": "UTIB",
|
25
|
+
"international": false,
|
26
|
+
"emi": false,
|
27
|
+
"sub_type": "business"
|
28
|
+
},
|
29
|
+
"bank": null,
|
30
|
+
"wallet": null,
|
31
|
+
"vpa": null,
|
32
|
+
"email": "gaurav.kumar@example.com",
|
33
|
+
"contact": "+919000090000",
|
34
|
+
"notes": {
|
35
|
+
"email": "gaurav.kumar@example.com",
|
36
|
+
"phone": "09000090000"
|
37
|
+
},
|
38
|
+
"fee": null,
|
39
|
+
"tax": null,
|
40
|
+
"error_code": "BAD_REQUEST_ERROR",
|
41
|
+
"error_description": "Card issuer is invalid",
|
42
|
+
"error_source": "customer",
|
43
|
+
"error_step": "payment_authentication",
|
44
|
+
"error_reason": "incorrect_card_details",
|
45
|
+
"acquirer_data": {
|
46
|
+
"auth_code": null,
|
47
|
+
"authentication_reference_number": "100222021120200000000742753928"
|
48
|
+
},
|
49
|
+
"created_at": 1620807547
|
50
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"risk_tier": "high",
|
3
|
+
"rto_reasons": [
|
4
|
+
{
|
5
|
+
"reason": "short_shipping_address",
|
6
|
+
"description": "Short shipping address",
|
7
|
+
"bucket": "address"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"reason": "address_pincode_state_mismatch",
|
11
|
+
"description": "Incorrect pincode state entered",
|
12
|
+
"bucket": "address"
|
13
|
+
}
|
14
|
+
]
|
15
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"entity":"collection",
|
3
|
+
"count":1,
|
4
|
+
"items":[
|
5
|
+
{
|
6
|
+
"id":"rvrsl_Lt09xvyzskI7KZ",
|
7
|
+
"entity":"reversal",
|
8
|
+
"transfer_id":"trf_Lt048W7cgLdo1u",
|
9
|
+
"amount":50000,
|
10
|
+
"fee":0,
|
11
|
+
"tax":0,
|
12
|
+
"currency":"INR",
|
13
|
+
"notes":[
|
14
|
+
|
15
|
+
],
|
16
|
+
"initiator_id":"Ghri4beeOuMTAb",
|
17
|
+
"customer_refund_id":null,
|
18
|
+
"utr":null,
|
19
|
+
"created_at":1684822489
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -6,6 +6,8 @@ module Razorpay
|
|
6
6
|
def setup
|
7
7
|
@customer_id = 'cust_6vRXClWqnLhV14'
|
8
8
|
@token_id = "token_FHfn3rIiM1Z8nr"
|
9
|
+
@bank_id = "ba_Evg09Ll05SIPSD"
|
10
|
+
@eligibilityId = "elig_F1cxDoHWD4fkQt"
|
9
11
|
# Any request that ends with customers/customer_id
|
10
12
|
stub_get(%r{customers/#{@customer_id}$}, 'fake_customer')
|
11
13
|
end
|
@@ -65,5 +67,108 @@ module Razorpay
|
|
65
67
|
token = Razorpay::Customer.fetch(@customer_id).deleteToken("token_FHfn3rIiM1Z8nr")
|
66
68
|
assert token.deleted
|
67
69
|
end
|
70
|
+
|
71
|
+
def test_customer_add_bank_account
|
72
|
+
para_attr = {
|
73
|
+
"ifsc_code": "UTIB0000194",
|
74
|
+
"account_number": "916010082985661",
|
75
|
+
"beneficiary_name": "Pratheek",
|
76
|
+
"beneficiary_address1": "address 1",
|
77
|
+
"beneficiary_address2": "address 2",
|
78
|
+
"beneficiary_address3": "address 3",
|
79
|
+
"beneficiary_address4": "address 4",
|
80
|
+
"beneficiary_email": "random@email.com",
|
81
|
+
"beneficiary_mobile": "8762489310",
|
82
|
+
"beneficiary_city": "Bangalore",
|
83
|
+
"beneficiary_state": "KA",
|
84
|
+
"beneficiary_country": "IN"
|
85
|
+
}
|
86
|
+
|
87
|
+
stub_post(%r{customers/#{@customer_id}/bank_account$}, 'fake_bank_account', para_attr.to_json)
|
88
|
+
bankAccount = Razorpay::Customer.add_bank_account(@customer_id, para_attr.to_json)
|
89
|
+
assert bankAccount.bank_name
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_customer_add_bank_account_exception
|
93
|
+
para_attr = {}
|
94
|
+
stub_post(%r{customers/#{@customer_id}/bank_account$}, 'error_customer', para_attr.to_json)
|
95
|
+
assert_raises(Razorpay::Error) do
|
96
|
+
customer = Razorpay::Customer.add_bank_account(@customer_id, para_attr.to_json)
|
97
|
+
if customer.error
|
98
|
+
raise Razorpay::Error.new, customer.error['code']
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_customer_delete_bank_account
|
104
|
+
stub_delete(%r{customers/#{@customer_id}/bank_account/#{@bank_id}$}, 'success')
|
105
|
+
bankAccount = Razorpay::Customer.delete_bank_account(@customer_id, @bank_id)
|
106
|
+
assert bankAccount.success
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_customer_delete_bank_account_exception
|
110
|
+
stub_delete(%r{customers/#{@customer_id}/bank_account/#{@bank_id}$}, 'error_customer')
|
111
|
+
assert_raises(Razorpay::Error) do
|
112
|
+
customer = Razorpay::Customer.delete_bank_account(@customer_id,@bank_id)
|
113
|
+
if customer.error
|
114
|
+
raise Razorpay::Error.new, customer.error['code']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_customer_request_eligiblity_check
|
120
|
+
para_attr = {
|
121
|
+
"inquiry": "affordability",
|
122
|
+
"amount": 500000,
|
123
|
+
"currency": "INR",
|
124
|
+
"customer": {
|
125
|
+
"id": "cust_KhP5dO1dKmc0Rm",
|
126
|
+
"contact": "+918220276214",
|
127
|
+
"ip": "105.106.107.108",
|
128
|
+
"referrer": "https://merchansite.com/example/paybill",
|
129
|
+
"user_agent": "Mozilla/5.0"
|
130
|
+
}
|
131
|
+
}
|
132
|
+
stub_post(%r{customers/eligibility$}, 'fake_eligiblity', para_attr.to_json)
|
133
|
+
bankAccount = Razorpay::Customer.request_eligibility_check(para_attr.to_json)
|
134
|
+
assert bankAccount.amount
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_customer_fetch_eligiblity_check_exception
|
138
|
+
para_attr = {
|
139
|
+
"inquiry": "affordability",
|
140
|
+
"currency": "INR",
|
141
|
+
"customer": {
|
142
|
+
"id": "cust_KhP5dO1dKmc0Rm",
|
143
|
+
"contact": "+918220276214",
|
144
|
+
"ip": "105.106.107.108",
|
145
|
+
"referrer": "https://merchansite.com/example/paybill",
|
146
|
+
"user_agent": "Mozilla/5.0"
|
147
|
+
}
|
148
|
+
}
|
149
|
+
stub_post(%r{customers/eligibility$}, 'error_eligibility_check', para_attr.to_json)
|
150
|
+
assert_raises(Razorpay::Error) do
|
151
|
+
customer = Razorpay::Customer.request_eligibility_check(para_attr.to_json)
|
152
|
+
if customer.error
|
153
|
+
raise Razorpay::Error.new, customer.error['code']
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_customer_fetch_eligiblity
|
159
|
+
stub_get(%r{customers/eligibility/#{@eligibilityId}$}, 'fake_eligiblity')
|
160
|
+
bankAccount = Razorpay::Customer.fetch_eligibility(@eligibilityId)
|
161
|
+
assert bankAccount.amount
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_customer_fetch_eligiblity_exception
|
165
|
+
stub_get(%r{customers/eligibility/#{@eligibilityId}$}, 'error_eligibility_check')
|
166
|
+
assert_raises(Razorpay::Error) do
|
167
|
+
customer = Razorpay::Customer.fetch_eligibility(@eligibilityId)
|
168
|
+
if customer.error
|
169
|
+
raise Razorpay::Error.new, customer.error['code']
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
68
173
|
end
|
69
174
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
|
5
|
+
class RazorpayDisputeonTest < Minitest::Test
|
6
|
+
class Dispute < Razorpay::Entity; end
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@dispute_id = 'disp_XXXXXXXXXXXXX'
|
10
|
+
|
11
|
+
# Any request that ends with disputes/dispute_id
|
12
|
+
stub_get(%r{disputes\/#{Regexp.quote(@dispute_id)}$}, 'fake_dispute')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_dispute_should_be_defined
|
16
|
+
refute_nil Razorpay::Addon
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_addon_should_be_available
|
20
|
+
dispute = Razorpay::Dispute.fetch(@dispute_id)
|
21
|
+
assert_instance_of Razorpay::Dispute, dispute, 'Dispute not an instance of Dispute class'
|
22
|
+
assert_equal @dispute_id, dispute.id
|
23
|
+
assert_equal 'INR', dispute.currency
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_addon_should_be_available_failure
|
27
|
+
stub_get(%r{disputes\/#{Regexp.quote(@dispute_id)}$}, 'dispute_error')
|
28
|
+
assert_raises(Razorpay::Error) do
|
29
|
+
dispute = Razorpay::Dispute.fetch(@dispute_id)
|
30
|
+
if dispute.error
|
31
|
+
raise Razorpay::Error.new, dispute.error['code']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_fetch_all_dispute
|
37
|
+
stub_get(/disputes$/, 'dispute_collection')
|
38
|
+
dispute = Razorpay::Dispute.all
|
39
|
+
assert_instance_of Razorpay::Collection, dispute, 'Dispute should be an array'
|
40
|
+
refute_empty dispute.items, 'Dispute should be more than one'
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_dispute_accept
|
44
|
+
param_attr = {}
|
45
|
+
|
46
|
+
stub_post(%r{disputes\/#{@dispute_id}\/accept$}, 'fake_dispute', param_attr.to_json)
|
47
|
+
|
48
|
+
dispute = Razorpay::Dispute.accept(@dispute_id, param_attr.to_json)
|
49
|
+
assert_instance_of Razorpay::Dispute, dispute, 'Dispute not an instance of Dispute class'
|
50
|
+
|
51
|
+
assert_equal @dispute_id, dispute.id, 'Dispute IDs do not match'
|
52
|
+
assert_equal 10000, dispute.amount
|
53
|
+
assert_equal 0, dispute.amount_deducted
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_dispute_accept_failure
|
57
|
+
param_attr = {}
|
58
|
+
stub_post(%r{disputes\/#{@dispute_id}\/accept$}, 'dispute_error', param_attr.to_json)
|
59
|
+
assert_raises(Razorpay::Error) do
|
60
|
+
dispute = Razorpay::Dispute.accept(@dispute_id, param_attr.to_json)
|
61
|
+
if dispute.error
|
62
|
+
raise Razorpay::Error.new, dispute.error['code']
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_dispute_contest
|
68
|
+
|
69
|
+
param_attr = {
|
70
|
+
"billing_proof": [
|
71
|
+
"doc_EFtmUsbwpXwBG9",
|
72
|
+
"doc_EFtmUsbwpXwBG8"
|
73
|
+
],
|
74
|
+
"action": "submit"
|
75
|
+
}
|
76
|
+
|
77
|
+
stub_patch(%r{disputes\/#{@dispute_id}\/contest$}, 'fake_dispute', param_attr.to_json)
|
78
|
+
|
79
|
+
dispute = Razorpay::Dispute.contest(@dispute_id, param_attr.to_json)
|
80
|
+
assert_instance_of Razorpay::Dispute, dispute, 'Dispute not an instance of Dispute class'
|
81
|
+
|
82
|
+
assert_equal @dispute_id, dispute.id, 'Dispute IDs do not match'
|
83
|
+
assert_equal 10000, dispute.amount
|
84
|
+
assert_equal 0, dispute.amount_deducted
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_dispute_contest_failure
|
88
|
+
param_attr = {}
|
89
|
+
stub_patch(%r{disputes\/#{@dispute_id}\/contest$}, 'dispute_error', param_attr.to_json)
|
90
|
+
assert_raises(Razorpay::Error) do
|
91
|
+
dispute = Razorpay::Dispute.contest(@dispute_id, param_attr.to_json)
|
92
|
+
if dispute.error
|
93
|
+
raise Razorpay::Error.new, dispute.error['code']
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
# Tests for Razorpay::Document
|
5
|
+
class RazorpayDocumentTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@document_id = 'doc_O4KCaSbX4BjA6I'
|
8
|
+
# Any request that ends with document/document_id
|
9
|
+
stub_get(%r{documents/#{@document_id}$}, 'fake_document')
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_document_should_be_defined
|
13
|
+
refute_nil Razorpay::Document
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_document_should_be_defined_exception
|
17
|
+
para_attr = {}
|
18
|
+
stub_get(%r{documents/#{@document_id}$}, 'document_error')
|
19
|
+
assert_raises(Razorpay::Error) do
|
20
|
+
document = Razorpay::Document.fetch(@document_id)
|
21
|
+
if document.error
|
22
|
+
raise Razorpay::Error.new, document.error['code']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/test/razorpay/test_order.rb
CHANGED
@@ -66,6 +66,48 @@ module Razorpay
|
|
66
66
|
assert_equal @order_id, order.id, 'order IDs do not match'
|
67
67
|
refute_empty order.transfers["items"]
|
68
68
|
assert_equal @transfer_id, order.transfers["items"][0]["id"]
|
69
|
-
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_view_rto
|
72
|
+
stub_post(%r{orders/#{@order_id}/rto_review$}, 'fake_rto', {})
|
73
|
+
order = Razorpay::Order.view_rto(@order_id)
|
74
|
+
assert !order.rto_reasons.empty?, 'orders should be more than one'
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_view_rto_exception
|
78
|
+
stub_post(%r{orders/#{@order_id}/rto_review$}, 'order_error', {})
|
79
|
+
assert_raises(Razorpay::Error) do
|
80
|
+
order = Razorpay::Order.view_rto(@order_id)
|
81
|
+
if order.error
|
82
|
+
raise Razorpay::Error.new, order.error['code']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_fulfillment
|
88
|
+
param_attr = {
|
89
|
+
"payment_method": "upi",
|
90
|
+
"shipping": {
|
91
|
+
"waybill": "123456789",
|
92
|
+
"status": "rto",
|
93
|
+
"provider": "Bluedart"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
stub_post(%r{orders/#{@order_id}/fulfillment$}, 'fake_fulfillment', param_attr.to_json)
|
98
|
+
order = Razorpay::Order.edit_fulfillment(@order_id, param_attr.to_json)
|
99
|
+
assert_equal "upi", order.payment_method, 'order payment method do not match'
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_fulfillment_exception
|
103
|
+
para_attr = {}
|
104
|
+
stub_post(%r{orders/#{@order_id}/fulfillment$}, 'order_error', para_attr.to_json)
|
105
|
+
assert_raises(Razorpay::Error) do
|
106
|
+
order = Razorpay::Order.edit_fulfillment(@order_id, para_attr.to_json)
|
107
|
+
if order.error
|
108
|
+
raise Razorpay::Error.new, order.error['code']
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
70
112
|
end
|
71
113
|
end
|
@@ -298,6 +298,28 @@ module Razorpay
|
|
298
298
|
stub_post(%r{payments/validate/vpa$}, 'fake_validate_vpa',param_attr.to_json)
|
299
299
|
payment = Razorpay::Payment.validate_vpa param_attr.to_json
|
300
300
|
assert_equal param_attr[:vpa], payment.vpa
|
301
|
-
end
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_expand_details_emi
|
304
|
+
stub_get("#{BASE_URI}/v1/payments/#{@payment_id}/?expand[]=emi", 'fake_payment_expanded_details')
|
305
|
+
payment = Razorpay::Payment.expand_details @payment_id
|
306
|
+
assert_equal @payment_id, payment.id
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_expand_details_card
|
310
|
+
stub_get("#{BASE_URI}/v1/payments/#{@payment_id}/?expand[]=card", 'fake_payment_expanded_details')
|
311
|
+
payment = Razorpay::Payment.expand_details @payment_id
|
312
|
+
assert_equal @payment_id, payment.id
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_expand_details_failure
|
316
|
+
stub_get(%r{payments\/#{@payment_id}$}, 'payment_error')
|
317
|
+
assert_raises(Razorpay::Error) do
|
318
|
+
payment = Razorpay::Payment.expand_details(@payment_id)
|
319
|
+
if payment.error
|
320
|
+
raise Razorpay::Error.new, payment.error['code']
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
302
324
|
end
|
303
325
|
end
|
@@ -73,5 +73,22 @@ module Razorpay
|
|
73
73
|
assert_equal transfer.id, @transfer_id , 'Transfer transfer_id is accessible'
|
74
74
|
refute transfer.on_hold
|
75
75
|
end
|
76
|
+
|
77
|
+
def test_fetch_reversals
|
78
|
+
stub_get(%r{/transfers/#{@transfer_id}/reversals$}, 'reversals_collection')
|
79
|
+
transfer = Razorpay::Transfer.reversals(@transfer_id)
|
80
|
+
assert_instance_of Razorpay::Collection, transfer , 'Transfer should be an array'
|
81
|
+
refute_empty transfer.items , 'Transfer should be more than one'
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_fetch_reversals_exception
|
85
|
+
stub_get(%r{/transfers/#{@transfer_id}/reversals$}, 'transfer_error')
|
86
|
+
assert_raises(Razorpay::Error) do
|
87
|
+
transfer = Razorpay::Transfer.reversals(@transfer_id)
|
88
|
+
if transfer.error
|
89
|
+
raise Razorpay::Error.new, transfer.error['code']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
76
93
|
end
|
77
94
|
end
|