razorpay 3.0.0 → 3.1.0
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/.github/pull_request_template.md +8 -0
- data/.github/workflows/ci.yml +79 -0
- data/CHANGELOG.md +21 -0
- data/README.md +5 -1
- data/documents/Invoice.md +11 -3
- data/documents/account.md +449 -0
- data/documents/addon.md +23 -1
- data/documents/card.md +73 -29
- data/documents/customer.md +2 -0
- data/documents/emandate.md +20 -12
- data/documents/fund.md +19 -17
- data/documents/items.md +65 -41
- data/documents/order.md +51 -0
- data/documents/papernach.md +40 -20
- data/documents/payment.md +247 -14
- data/documents/paymentLink.md +37 -19
- data/documents/plan.md +3 -3
- data/documents/productConfiguration.md +444 -0
- data/documents/qrcode.md +17 -19
- data/documents/refund.md +11 -10
- data/documents/registerEmandate.md +25 -18
- data/documents/registerNach.md +49 -57
- data/documents/settlement.md +1 -0
- data/documents/stakeholder.md +334 -0
- data/documents/subscriptions.md +3 -1
- data/documents/tokens.md +201 -2
- data/documents/transfers.md +292 -195
- data/documents/upi.md +25 -28
- data/documents/virtualAccount.md +18 -13
- data/documents/webhook.md +224 -0
- data/lib/razorpay/account.rb +39 -0
- data/lib/razorpay/addon.rb +5 -1
- data/lib/razorpay/card.rb +4 -0
- data/lib/razorpay/constants.rb +2 -2
- data/lib/razorpay/iin.rb +15 -0
- data/lib/razorpay/order.rb +1 -1
- data/lib/razorpay/payment.rb +8 -0
- data/lib/razorpay/payment_method.rb +17 -0
- data/lib/razorpay/product.rb +37 -0
- data/lib/razorpay/request.rb +16 -16
- data/lib/razorpay/stakeholder.rb +39 -0
- data/lib/razorpay/token.rb +28 -0
- data/lib/razorpay/virtual_account.rb +1 -1
- data/lib/razorpay/webhook.rb +50 -0
- data/lib/razorpay.rb +7 -0
- data/razorpay-ruby.gemspec +2 -1
- data/test/fixtures/fake_account.json +78 -0
- data/test/fixtures/fake_card_reference.json +5 -0
- data/test/fixtures/fake_create_upi_payment.json +3 -0
- data/test/fixtures/fake_iin_token.json +23 -0
- data/test/fixtures/fake_product.json +138 -0
- data/test/fixtures/fake_stakeholder.json +29 -0
- data/test/fixtures/fake_tokenise_customer.json +40 -0
- data/test/fixtures/fake_validate_vpa.json +5 -0
- data/test/fixtures/fake_webhook.json +79 -0
- data/test/fixtures/fake_webhook_by_account_id.json +22 -0
- data/test/fixtures/fetch_tnc.json +11 -0
- data/test/fixtures/payment_methods_collection.json +149 -0
- data/test/fixtures/stakeholder_collection.json +35 -0
- data/test/fixtures/webhook_by_account_collection.json +35 -0
- data/test/fixtures/webhook_collection.json +85 -0
- data/test/razorpay/test_account.rb +134 -0
- data/test/razorpay/test_addon.rb +6 -2
- data/test/razorpay/test_card.rb +6 -0
- data/test/razorpay/test_customer.rb +8 -8
- data/test/razorpay/test_iin.rb +23 -0
- data/test/razorpay/test_order.rb +1 -1
- data/test/razorpay/test_payment.rb +46 -2
- data/test/razorpay/test_product.rb +67 -0
- data/test/razorpay/test_settlement.rb +1 -1
- data/test/razorpay/test_stakeholder.rb +87 -0
- data/test/razorpay/test_token.rb +66 -0
- data/test/razorpay/test_transfer.rb +1 -1
- data/test/razorpay/test_webhook.rb +132 -0
- data/test/test_helper.rb +2 -0
- metadata +76 -7
@@ -0,0 +1,149 @@
|
|
1
|
+
{
|
2
|
+
"entity": "methods",
|
3
|
+
"card": true,
|
4
|
+
"debit_card": true,
|
5
|
+
"credit_card": true,
|
6
|
+
"prepaid_card": true,
|
7
|
+
"card_networks": {
|
8
|
+
"AMEX": 0,
|
9
|
+
"DICL": 0,
|
10
|
+
"MC": 1,
|
11
|
+
"MAES": 1,
|
12
|
+
"VISA": 1,
|
13
|
+
"JCB": 0,
|
14
|
+
"RUPAY": 1,
|
15
|
+
"BAJAJ": 0
|
16
|
+
},
|
17
|
+
"card_subtype": {
|
18
|
+
"consumer": 1,
|
19
|
+
"business": 1,
|
20
|
+
"premium": 0
|
21
|
+
},
|
22
|
+
"amex": false,
|
23
|
+
"netbanking": {
|
24
|
+
"AUBL": "AU Small Finance Bank",
|
25
|
+
"AIRP": "Airtel Payments Bank",
|
26
|
+
"ANDB": "Andhra Bank",
|
27
|
+
"UTIB": "Axis Bank",
|
28
|
+
"BARB_R": "Bank of Baroda - Retail Banking",
|
29
|
+
"VIJB": "Bank of Baroda - Retail Banking (Erstwhile Vijaya Bank)",
|
30
|
+
"MAHB": "Bank of Maharashtra",
|
31
|
+
"CNRB": "Canara Bank",
|
32
|
+
"CSBK": "Catholic Syrian Bank",
|
33
|
+
"CBIN": "Central Bank of India",
|
34
|
+
"DCBL": "DCB Bank",
|
35
|
+
"DEUT": "Deutsche Bank",
|
36
|
+
"DLXB": "Dhanlaxmi Bank",
|
37
|
+
"ESFB": "Equitas Small Finance Bank",
|
38
|
+
"FSFB": "Fincare Small Finance Bank",
|
39
|
+
"ICIC": "ICICI Bank",
|
40
|
+
"IBKL": "IDBI",
|
41
|
+
"IDFB": "IDFC FIRST Bank",
|
42
|
+
"IDIB": "Indian Bank",
|
43
|
+
"ALLA": "Indian Bank (Erstwhile Allahabad Bank)",
|
44
|
+
"IOBA": "Indian Overseas Bank",
|
45
|
+
"INDB": "Indusind Bank",
|
46
|
+
"JAKA": "Jammu and Kashmir Bank",
|
47
|
+
"JSFB": "Jana Small Finance Bank",
|
48
|
+
"KARB": "Karnataka Bank",
|
49
|
+
"KVBL": "Karur Vysya Bank",
|
50
|
+
"KKBK": "Kotak Mahindra Bank",
|
51
|
+
"LAVB_R": "Lakshmi Vilas Bank - Retail Banking",
|
52
|
+
"NSPB": "NSDL Payments Bank",
|
53
|
+
"ORBC": "PNB (Erstwhile-Oriental Bank of Commerce)",
|
54
|
+
"UTBI": "PNB (Erstwhile-United Bank of India)",
|
55
|
+
"PSIB": "Punjab & Sind Bank",
|
56
|
+
"PUNB_R": "Punjab National Bank - Retail Banking",
|
57
|
+
"RATN": "RBL Bank",
|
58
|
+
"SVCB": "SVC Co-Operative Bank Ltd.",
|
59
|
+
"SRCB": "Saraswat Co-operative Bank",
|
60
|
+
"SIBL": "South Indian Bank",
|
61
|
+
"SCBL": "Standard Chartered Bank",
|
62
|
+
"SBBJ": "State Bank of Bikaner and Jaipur",
|
63
|
+
"SBHY": "State Bank of Hyderabad",
|
64
|
+
"SBIN": "State Bank of India",
|
65
|
+
"SBMY": "State Bank of Mysore",
|
66
|
+
"STBP": "State Bank of Patiala",
|
67
|
+
"SBTR": "State Bank of Travancore",
|
68
|
+
"TMBL": "Tamilnad Mercantile Bank",
|
69
|
+
"UCBA": "UCO Bank",
|
70
|
+
"UBIN": "Union Bank of India",
|
71
|
+
"CORP": "Union Bank of India (Erstwhile Corporation Bank)",
|
72
|
+
"YESB": "Yes Bank"
|
73
|
+
},
|
74
|
+
"wallet": {
|
75
|
+
"mobikwik": true,
|
76
|
+
"payzapp": true,
|
77
|
+
"olamoney": true,
|
78
|
+
"airtelmoney": true,
|
79
|
+
"freecharge": true,
|
80
|
+
"jiomoney": true
|
81
|
+
},
|
82
|
+
"emi": false,
|
83
|
+
"upi": true,
|
84
|
+
"cardless_emi": [],
|
85
|
+
"paylater": {
|
86
|
+
"epaylater": true,
|
87
|
+
"getsimpl": true,
|
88
|
+
"icic": true,
|
89
|
+
"hdfc": true,
|
90
|
+
"kkbk": true,
|
91
|
+
"lazypay": true
|
92
|
+
},
|
93
|
+
"google_pay_cards": false,
|
94
|
+
"app": {
|
95
|
+
"cred": 0,
|
96
|
+
"twid": 0,
|
97
|
+
"trustly": 0,
|
98
|
+
"poli": 0,
|
99
|
+
"sofort": 0,
|
100
|
+
"giropay": 0
|
101
|
+
},
|
102
|
+
"gpay": false,
|
103
|
+
"emi_types": {
|
104
|
+
"credit": false,
|
105
|
+
"debit": false
|
106
|
+
},
|
107
|
+
"debit_emi_providers": {
|
108
|
+
"HDFC": 0
|
109
|
+
},
|
110
|
+
"nach": false,
|
111
|
+
"cod": false,
|
112
|
+
"offline": false,
|
113
|
+
"recurring": {
|
114
|
+
"card": {
|
115
|
+
"credit": [
|
116
|
+
"MasterCard",
|
117
|
+
"Visa"
|
118
|
+
],
|
119
|
+
"prepaid": [
|
120
|
+
"MasterCard",
|
121
|
+
"Visa"
|
122
|
+
],
|
123
|
+
"debit": {
|
124
|
+
"UTIB": "Axis Bank",
|
125
|
+
"BARB": "Bank of Baroda",
|
126
|
+
"MAHB": "Bank of Maharashtra",
|
127
|
+
"CITI": "CITI Bank",
|
128
|
+
"CNRB": "Canara Bank",
|
129
|
+
"CIUB": "City Union Bank",
|
130
|
+
"ESFB": "Equitas Small Finance Bank",
|
131
|
+
"FDRL": "Federal Bank",
|
132
|
+
"HDFC": "HDFC Bank",
|
133
|
+
"HSBC": "HSBC",
|
134
|
+
"ICIC": "ICICI Bank",
|
135
|
+
"IDIB": "Indian Bank",
|
136
|
+
"ALLA": "Indian Bank (Erstwhile Allahabad Bank)",
|
137
|
+
"IOBA": "Indian Overseas Bank",
|
138
|
+
"INDB": "Indusind Bank",
|
139
|
+
"KVBL": "Karur Vysya Bank",
|
140
|
+
"KKBK": "Kotak Mahindra Bank",
|
141
|
+
"RATN": "RBL Bank",
|
142
|
+
"SBIN": "State Bank of India"
|
143
|
+
}
|
144
|
+
},
|
145
|
+
"upi": true,
|
146
|
+
"nach": false
|
147
|
+
},
|
148
|
+
"upi_intent": true
|
149
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"entity": "collection",
|
3
|
+
"items": [
|
4
|
+
{
|
5
|
+
"id": "GZ13yPHLJof9IE",
|
6
|
+
"entity": "stakeholder",
|
7
|
+
"relationship": {
|
8
|
+
"director": true
|
9
|
+
},
|
10
|
+
"phone": {
|
11
|
+
"primary": "9000090000",
|
12
|
+
"secondary": "9000090000"
|
13
|
+
},
|
14
|
+
"notes": {
|
15
|
+
"random_key_by_partner": "random_value"
|
16
|
+
},
|
17
|
+
"kyc": {
|
18
|
+
"pan": "AVOPB1111K"
|
19
|
+
},
|
20
|
+
"name": "Gaurav Kumar",
|
21
|
+
"email": "gaurav.kumar@acme.org",
|
22
|
+
"percentage_ownership": 10,
|
23
|
+
"addresses": {
|
24
|
+
"residential": {
|
25
|
+
"street": "506, Koramangala 1st block",
|
26
|
+
"city": "Bengaluru",
|
27
|
+
"state": "Karnataka",
|
28
|
+
"postal_code": "560034",
|
29
|
+
"country": "in"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
],
|
34
|
+
"count": 1
|
35
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"entity": "collection",
|
3
|
+
"items": [
|
4
|
+
{
|
5
|
+
"id": "GZ13yPHLJof9IE",
|
6
|
+
"entity": "stakeholder",
|
7
|
+
"relationship": {
|
8
|
+
"director": true
|
9
|
+
},
|
10
|
+
"phone": {
|
11
|
+
"primary": "9000090000",
|
12
|
+
"secondary": "9000090000"
|
13
|
+
},
|
14
|
+
"notes": {
|
15
|
+
"random_key_by_partner": "random_value"
|
16
|
+
},
|
17
|
+
"kyc": {
|
18
|
+
"pan": "AVOPB1111K"
|
19
|
+
},
|
20
|
+
"name": "Gaurav Kumar",
|
21
|
+
"email": "gaurav.kumar@acme.org",
|
22
|
+
"percentage_ownership": 10,
|
23
|
+
"addresses": {
|
24
|
+
"residential": {
|
25
|
+
"street": "506, Koramangala 1st block",
|
26
|
+
"city": "Bengaluru",
|
27
|
+
"state": "Karnataka",
|
28
|
+
"postal_code": "560034",
|
29
|
+
"country": "in"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
],
|
34
|
+
"count": 1
|
35
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
{
|
2
|
+
"entity": "collection",
|
3
|
+
"count": 1,
|
4
|
+
"items": [
|
5
|
+
{
|
6
|
+
"id": "KTBSNfvnYlcKnH",
|
7
|
+
"created_at": 1665648343,
|
8
|
+
"updated_at": 1695729722,
|
9
|
+
"service": "api-test",
|
10
|
+
"owner_id": "Hn1ukn2d32Fqww",
|
11
|
+
"owner_type": "merchant",
|
12
|
+
"disabled_at": 1665736246,
|
13
|
+
"url": "https://www.linkedin.com",
|
14
|
+
"created_by": "Hn1ukgebfkBJ4L",
|
15
|
+
"secret_exists": true,
|
16
|
+
"created_by_email": "ankit.das@razorpay.com",
|
17
|
+
"entity": "webhook",
|
18
|
+
"active": true,
|
19
|
+
"events": {
|
20
|
+
"payment.authorized": false,
|
21
|
+
"payment.failed": false,
|
22
|
+
"payment.captured": false,
|
23
|
+
"payment.dispute.created": false,
|
24
|
+
"order.paid": false,
|
25
|
+
"invoice.paid": false,
|
26
|
+
"invoice.partially_paid": false,
|
27
|
+
"invoice.expired": false,
|
28
|
+
"subscription.authenticated": false,
|
29
|
+
"subscription.paused": false,
|
30
|
+
"subscription.resumed": false,
|
31
|
+
"subscription.activated": false,
|
32
|
+
"subscription.pending": false,
|
33
|
+
"subscription.halted": false,
|
34
|
+
"subscription.charged": false,
|
35
|
+
"subscription.cancelled": false,
|
36
|
+
"subscription.completed": false,
|
37
|
+
"subscription.updated": false,
|
38
|
+
"settlement.processed": false,
|
39
|
+
"virtual_account.credited": false,
|
40
|
+
"virtual_account.created": false,
|
41
|
+
"virtual_account.closed": false,
|
42
|
+
"qr_code.closed": false,
|
43
|
+
"qr_code.created": false,
|
44
|
+
"qr_code.credited": false,
|
45
|
+
"payment.dispute.won": false,
|
46
|
+
"payment.dispute.lost": false,
|
47
|
+
"payment.dispute.closed": false,
|
48
|
+
"payment.dispute.under_review": false,
|
49
|
+
"payment.dispute.action_required": false,
|
50
|
+
"fund_account.validation.completed": false,
|
51
|
+
"fund_account.validation.failed": false,
|
52
|
+
"payout.processed": false,
|
53
|
+
"payout.reversed": false,
|
54
|
+
"payment.downtime.started": false,
|
55
|
+
"payment.downtime.updated": false,
|
56
|
+
"payment.downtime.resolved": false,
|
57
|
+
"payout.initiated": false,
|
58
|
+
"refund.speed_changed": false,
|
59
|
+
"refund.processed": false,
|
60
|
+
"refund.failed": false,
|
61
|
+
"refund.created": true,
|
62
|
+
"transfer.processed": false,
|
63
|
+
"transfer.failed": false,
|
64
|
+
"account.under_review": false,
|
65
|
+
"account.needs_clarification": false,
|
66
|
+
"account.activated": false,
|
67
|
+
"account.rejected": false,
|
68
|
+
"account.updated": false,
|
69
|
+
"payout.updated": false,
|
70
|
+
"payout.rejected": false,
|
71
|
+
"payout.pending": false,
|
72
|
+
"payment_link.paid": false,
|
73
|
+
"payment_link.partially_paid": false,
|
74
|
+
"payment_link.expired": false,
|
75
|
+
"payment_link.cancelled": false,
|
76
|
+
"zapier.payment_page.paid.v1": false,
|
77
|
+
"shiprocket.payment_page.paid.v1": false,
|
78
|
+
"product.route.under_review": false,
|
79
|
+
"product.route.activated": false,
|
80
|
+
"product.route.needs_clarification": false,
|
81
|
+
"product.route.rejected": false
|
82
|
+
}
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
# Tests for Razorpay::Account
|
5
|
+
class RazorpayAccountonTest < Minitest::Test
|
6
|
+
class Account < Razorpay::Entity; end
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@account_id = 'acc_00000000000001'
|
10
|
+
@email = 'gauriagain.kumar@example.org'
|
11
|
+
# Any request that ends with account/account_id
|
12
|
+
stub_get(%r{/v2/accounts\/#{Regexp.quote(@account_id)}$}, 'fake_account')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_account_should_be_defined
|
16
|
+
refute_nil Razorpay::Account
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_account_should_be_available
|
20
|
+
account = Razorpay::Account.fetch(@account_id)
|
21
|
+
assert_instance_of Razorpay::Entity, account, 'Account not an instance of Entity class'
|
22
|
+
assert_equal @account_id, account.id, 'Account IDs do not match'
|
23
|
+
assert_equal @email, account.email, 'Account email is accessible'
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_account_should_be_created
|
27
|
+
|
28
|
+
payload = create_account_payload()
|
29
|
+
|
30
|
+
stub_post(/accounts$/,'fake_account',payload.to_json)
|
31
|
+
|
32
|
+
account = Razorpay::Account.create payload.to_json
|
33
|
+
assert_instance_of Razorpay::Entity, account
|
34
|
+
assert_equal @account_id, account.id
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_account_edit
|
38
|
+
|
39
|
+
param_attr = {
|
40
|
+
"notes": {
|
41
|
+
"internal_ref_id": "111111"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
stub_patch(%r{accounts/#{@account_id}$}, 'fake_account', param_attr.to_json)
|
46
|
+
|
47
|
+
account = Razorpay::Account.edit(@account_id, param_attr.to_json)
|
48
|
+
assert_instance_of Razorpay::Entity, account
|
49
|
+
assert_equal @account_id, account.id
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_delete_account
|
53
|
+
stub_delete(%r{accounts/#{@account_id}$}, 'fake_account')
|
54
|
+
account = Razorpay::Account.delete(@account_id)
|
55
|
+
assert_instance_of Razorpay::Entity, account
|
56
|
+
assert_equal @account_id, account.id
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_account_payload
|
60
|
+
return {
|
61
|
+
"email": "gauriagainqzy.kumar@example.org",
|
62
|
+
"phone": "9000090000",
|
63
|
+
"legal_business_name": "Acme Corp",
|
64
|
+
"business_type": "partnership",
|
65
|
+
"customer_facing_business_name": "Example",
|
66
|
+
"profile": {
|
67
|
+
"category": "healthcare",
|
68
|
+
"subcategory": "clinic",
|
69
|
+
"description": "Healthcare E-commerce platform",
|
70
|
+
"addresses": {
|
71
|
+
"operation": {
|
72
|
+
"street1": "507, Koramangala 6th block",
|
73
|
+
"street2": "Kormanagala",
|
74
|
+
"city": "Bengaluru",
|
75
|
+
"state": "Karnataka",
|
76
|
+
"postal_code": 560047,
|
77
|
+
"country": "IN"
|
78
|
+
},
|
79
|
+
"registered": {
|
80
|
+
"street1": "507, Koramangala 1st block",
|
81
|
+
"street2": "MG Road",
|
82
|
+
"city": "Bengaluru",
|
83
|
+
"state": "Karnataka",
|
84
|
+
"postal_code": 560034,
|
85
|
+
"country": "IN"
|
86
|
+
}
|
87
|
+
},
|
88
|
+
"business_model": "Online Clothing ( men, women, ethnic, modern ) fashion and lifestyle, accessories, t-shirt, shirt, track pant, shoes."
|
89
|
+
},
|
90
|
+
"legal_info": {
|
91
|
+
"pan": "AAACL1234C",
|
92
|
+
"gst": "18AABCU9603R1ZM"
|
93
|
+
},
|
94
|
+
"brand": {
|
95
|
+
"color": "FFFFFF"
|
96
|
+
},
|
97
|
+
"notes": {
|
98
|
+
"internal_ref_id": "111111"
|
99
|
+
},
|
100
|
+
"contact_name": "Gaurav Kumar",
|
101
|
+
"contact_info": {
|
102
|
+
"chargeback": {
|
103
|
+
"email": "cb@example.org"
|
104
|
+
},
|
105
|
+
"refund": {
|
106
|
+
"email": "cb@example.org"
|
107
|
+
},
|
108
|
+
"support": {
|
109
|
+
"email": "support@example.org",
|
110
|
+
"phone": "9999999998",
|
111
|
+
"policy_url": "https://www.google.com"
|
112
|
+
}
|
113
|
+
},
|
114
|
+
"apps": {
|
115
|
+
"websites": [
|
116
|
+
"https://www.example.org"
|
117
|
+
],
|
118
|
+
"android": [
|
119
|
+
{
|
120
|
+
"url": "playstore.example.org",
|
121
|
+
"name": "Example"
|
122
|
+
}
|
123
|
+
],
|
124
|
+
"ios": [
|
125
|
+
{
|
126
|
+
"url": "appstore.example.org",
|
127
|
+
"name": "Example"
|
128
|
+
}
|
129
|
+
]
|
130
|
+
}
|
131
|
+
}
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/test/razorpay/test_addon.rb
CHANGED
@@ -57,8 +57,6 @@ module Razorpay
|
|
57
57
|
assert_addon_item_details(addon)
|
58
58
|
end
|
59
59
|
|
60
|
-
private
|
61
|
-
|
62
60
|
def assert_addon_item_details(addon)
|
63
61
|
addon_item = Item.new(addon.item)
|
64
62
|
|
@@ -68,5 +66,11 @@ module Razorpay
|
|
68
66
|
assert_equal 'INR', addon_item.currency, 'Addon Item currency is accessible'
|
69
67
|
assert_equal 500, addon_item.amount, 'Addon Item amount is accessible'
|
70
68
|
end
|
69
|
+
|
70
|
+
def test_delete_addon
|
71
|
+
stub_delete(%r{addons/#{@addon_id}$}, 'empty')
|
72
|
+
addon = Razorpay::Addon.delete(@addon_id)
|
73
|
+
assert_instance_of Razorpay::Entity, addon
|
74
|
+
end
|
71
75
|
end
|
72
76
|
end
|
data/test/razorpay/test_card.rb
CHANGED
@@ -19,5 +19,11 @@ module Razorpay
|
|
19
19
|
assert_instance_of Razorpay::Card, card, 'card not an instance of Razorpay::Card class'
|
20
20
|
assert_equal @card_id, card.id, 'card IDs do not match'
|
21
21
|
end
|
22
|
+
|
23
|
+
def test_request_card_reference_should_be_fetched
|
24
|
+
stub_post(%r{cards/fingerprints$}, 'fake_card_reference', {"number": "4111111111111111"})
|
25
|
+
card = Razorpay::Card.request_card_reference({"number": "4111111111111111"})
|
26
|
+
assert_instance_of Razorpay::Entity, card, 'card not an instance of Razorpay::Card class'
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
@@ -43,19 +43,19 @@ module Razorpay
|
|
43
43
|
assert_equal "test@razorpay.com", customer.email
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
def test_customer_fetch_tokens
|
47
|
+
stub_get(%r{customers/#{@customer_id}$}, 'fake_customer')
|
48
|
+
stub_get(%r{customers/cust_6vRXClWqnLhV14/tokens$}, 'tokens_collection')
|
49
|
+
tokens = Razorpay::Customer.fetch(@customer_id).fetchTokens
|
50
|
+
assert_instance_of Razorpay::Collection, tokens, 'Tokens should be an array'
|
51
|
+
refute_empty tokens.items, 'tokens should be more than one'
|
52
|
+
end
|
53
53
|
|
54
54
|
def test_customer_fetch_token
|
55
55
|
stub_get(%r{customers/#{@customer_id}$}, 'fake_customer')
|
56
56
|
stub_get(%r{customers/cust_6vRXClWqnLhV14/tokens/token_FHfn3rIiM1Z8nr$}, 'fake_token')
|
57
57
|
token = Razorpay::Customer.fetch(@customer_id).fetchToken("token_FHfn3rIiM1Z8nr")
|
58
|
-
assert_instance_of Razorpay::
|
58
|
+
assert_instance_of Razorpay::Token, token, 'Token not an instance of Razorpay::Entity class'
|
59
59
|
assert_equal "token_FHfn3rIiM1Z8nr", token.id
|
60
60
|
end
|
61
61
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
# Tests for Razorpay::Iin
|
5
|
+
class RazorpayIinTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@token_id = '411111'
|
8
|
+
|
9
|
+
# Any request that ends with token/token_id
|
10
|
+
stub_get(%r{iins/#{@token_id}$}, 'fake_iin_token')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_iin_should_be_defined
|
14
|
+
refute_nil Razorpay::Iin
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_iin_should_be_fetched
|
18
|
+
token = Razorpay::Iin.fetch(@token_id)
|
19
|
+
assert_instance_of Razorpay::Iin, token, 'Iin not an instance of Razorpay::Iin class'
|
20
|
+
assert_equal @token_id, token.iin, 'token IDs do not match'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/razorpay/test_order.rb
CHANGED
@@ -60,7 +60,7 @@ module Razorpay
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_fetch_order_transfers
|
63
|
-
stub_get("#{BASE_URI}orders/#{@order_id}/?expand[]=transfers&status", 'fake_order_transfers')
|
63
|
+
stub_get("#{BASE_URI}/v1/orders/#{@order_id}/?expand[]=transfers&status", 'fake_order_transfers')
|
64
64
|
order = Razorpay::Order.fetch_transfer_order(@order_id)
|
65
65
|
assert_instance_of Razorpay::Order, order, 'order not an instance of Razorpay::Order class'
|
66
66
|
assert_equal @order_id, order.id, 'order IDs do not match'
|
@@ -217,6 +217,7 @@ module Razorpay
|
|
217
217
|
stub_post(%r{payments/#{@payment_id}/otp/resend$}, 'fake_otp_resend', {})
|
218
218
|
payment = Razorpay::Payment.fetch(@payment_id).otp_resend
|
219
219
|
assert_equal @payment_id, payment.razorpay_payment_id
|
220
|
+
end
|
220
221
|
|
221
222
|
def test_payment_edit
|
222
223
|
|
@@ -253,7 +254,50 @@ module Razorpay
|
|
253
254
|
stub_post(%r{payments/create/json$}, 'create_json_payment',payment_attr.to_json)
|
254
255
|
payment = Razorpay::Payment.create_json_payment payment_attr.to_json
|
255
256
|
assert_equal 'pay_FVmAstJWfsD3SO', payment.razorpay_payment_id
|
257
|
+
end
|
258
|
+
def test_create_upi
|
259
|
+
|
260
|
+
param_attr = {
|
261
|
+
"amount": 200,
|
262
|
+
"currency": "INR",
|
263
|
+
"order_id": "order_GAWRjlWkVcRh0V",
|
264
|
+
"email": "gaurav.kumar@example.com",
|
265
|
+
"contact": "9123456789",
|
266
|
+
"method": "upi",
|
267
|
+
"customer_id": "cust_EIW4T2etiweBmG",
|
268
|
+
"save": 1,
|
269
|
+
"ip": "192.168.0.103",
|
270
|
+
"referer": "http",
|
271
|
+
"user_agent": "Mozilla/5.0",
|
272
|
+
"description": "Test flow",
|
273
|
+
"notes": {
|
274
|
+
"note_key": "value1"
|
275
|
+
},
|
276
|
+
"upi": {
|
277
|
+
"flow": "collect",
|
278
|
+
"vpa": "gauravkumar@exampleupi",
|
279
|
+
"expiry_time": 5
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
stub_post(%r{payments/create/upi$}, 'fake_create_upi_payment',param_attr.to_json)
|
284
|
+
payment = Razorpay::Payment.create_upi param_attr.to_json
|
285
|
+
assert_equal 'pay_FVmAstJWfsD3SO', payment.razorpay_payment_id
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_payment_methods
|
289
|
+
stub_get(/methods$/, 'payment_methods_collection')
|
290
|
+
methods = Razorpay::PaymentMethods.all
|
291
|
+
assert_equal 'methods', methods.entity
|
256
292
|
end
|
257
|
-
|
258
|
-
|
293
|
+
|
294
|
+
def test_validate_vpa
|
295
|
+
param_attr = {
|
296
|
+
"vpa": "gauravkumar@exampleupi"
|
297
|
+
}
|
298
|
+
stub_post(%r{payments/validate/vpa$}, 'fake_validate_vpa',param_attr.to_json)
|
299
|
+
payment = Razorpay::Payment.validate_vpa param_attr.to_json
|
300
|
+
assert_equal param_attr[:vpa], payment.vpa
|
301
|
+
end
|
302
|
+
end
|
259
303
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
# Tests for Razorpay::Product
|
5
|
+
class RazorpayProductonTest < Minitest::Test
|
6
|
+
class Product < Razorpay::Entity; end
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@product_id = 'acc_prd_00000000000001'
|
10
|
+
@account_id = 'acc_00000000000001'
|
11
|
+
@product_name = 'payment_gateway'
|
12
|
+
@tnc_id = 'tnc_map_00000000000001'
|
13
|
+
# Any request that ends with product_id
|
14
|
+
stub_get(%r{/v2/accounts\/#{Regexp.quote(@account_id)}/products\/#{Regexp.quote(@product_id)}$}, 'fake_product')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_product_should_be_defined
|
18
|
+
refute_nil Razorpay::Product
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_product_should_be_available
|
22
|
+
product = Razorpay::Product.fetch(@account_id, @product_id)
|
23
|
+
assert_instance_of Razorpay::Entity, product, 'product not an instance of Entity class'
|
24
|
+
assert_equal @product_id, product.id, 'Product IDs do not match'
|
25
|
+
assert_equal @product_name, product.product_name, 'product name is accessible'
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_product_request_product_configuration
|
29
|
+
|
30
|
+
payload = create_product_payload()
|
31
|
+
stub_post(%r{accounts/#{@account_id}/products$}, 'fake_product', payload.to_json)
|
32
|
+
|
33
|
+
product = Razorpay::Product.request_product_configuration(@account_id, payload.to_json)
|
34
|
+
assert_instance_of Razorpay::Entity, product, 'Product not an instance of Entity class'
|
35
|
+
assert_equal @product_id, product.id, 'Product IDs do not match'
|
36
|
+
assert_equal @product_name, product.product_name, 'product name is accessible'
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_product_edit
|
40
|
+
|
41
|
+
payload = create_product_payload()
|
42
|
+
stub_patch(%r{accounts/#{@account_id}/products/#{@product_id}$}, 'fake_product', payload.to_json)
|
43
|
+
|
44
|
+
product = Razorpay::Product.edit(@account_id, @product_id, payload.to_json)
|
45
|
+
assert_instance_of Razorpay::Entity, product, 'Product not an instance of Entity class'
|
46
|
+
assert_equal @product_id, product.id, 'Product IDs do not match'
|
47
|
+
assert_equal @product_name, product.product_name, 'product name is accessible'
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_product_fetchTnc
|
51
|
+
product_name = "payments"
|
52
|
+
|
53
|
+
stub_get("#{BASE_URI}/v2/products/#{product_name}/tnc", 'fetch_tnc')
|
54
|
+
product = Razorpay::Product.fetch_tnc(product_name)
|
55
|
+
assert_instance_of Razorpay::Entity, product, 'Product not an instance of Entity class'
|
56
|
+
assert_equal @tnc_id, product.id, 'Product IDs do not match'
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_product_payload
|
60
|
+
return {
|
61
|
+
"product_name": "payment_gateway",
|
62
|
+
"tnc_accepted": true,
|
63
|
+
"ip": "233.233.233.234"
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -36,7 +36,7 @@ module Razorpay
|
|
36
36
|
"year": 2022,
|
37
37
|
"month":12
|
38
38
|
}
|
39
|
-
stub_get("#{BASE_URI}settlements/recon/combined?month=12&year=2022", 'settlement_report_collection')
|
39
|
+
stub_get("#{BASE_URI}/v1/settlements/recon/combined?month=12&year=2022", 'settlement_report_collection')
|
40
40
|
settlement = Razorpay::Settlement.reports(para_attr)
|
41
41
|
assert_instance_of Razorpay::Collection, settlement, 'Settlement not an instance of Settlement class'
|
42
42
|
refute_empty settlement.items, 'Settlement should be more than one'
|