razorpay 3.0.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -2
  3. data/CHANGELOG.md +17 -0
  4. data/README.md +6 -0
  5. data/documents/account.md +449 -0
  6. data/documents/card.md +45 -0
  7. data/documents/generic.md +150 -0
  8. data/documents/payment.md +44 -1
  9. data/documents/productConfiguration.md +444 -0
  10. data/documents/stakeholder.md +334 -0
  11. data/documents/tokens.md +146 -1
  12. data/documents/webhook.md +224 -0
  13. data/lib/razorpay/account.rb +39 -0
  14. data/lib/razorpay/addon.rb +1 -1
  15. data/lib/razorpay/card.rb +4 -0
  16. data/lib/razorpay/constants.rb +28 -2
  17. data/lib/razorpay/generic.rb +39 -0
  18. data/lib/razorpay/iin.rb +15 -0
  19. data/lib/razorpay/order.rb +1 -1
  20. data/lib/razorpay/product.rb +37 -0
  21. data/lib/razorpay/request.rb +22 -16
  22. data/lib/razorpay/stakeholder.rb +39 -0
  23. data/lib/razorpay/token.rb +28 -0
  24. data/lib/razorpay/virtual_account.rb +1 -1
  25. data/lib/razorpay/webhook.rb +50 -0
  26. data/lib/razorpay.rb +7 -0
  27. data/test/fixtures/fake_account.json +78 -0
  28. data/test/fixtures/fake_card_reference.json +5 -0
  29. data/test/fixtures/fake_iin_token.json +23 -0
  30. data/test/fixtures/fake_product.json +138 -0
  31. data/test/fixtures/fake_stakeholder.json +29 -0
  32. data/test/fixtures/fake_tokenise_customer.json +40 -0
  33. data/test/fixtures/fake_webhook.json +79 -0
  34. data/test/fixtures/fake_webhook_by_account_id.json +22 -0
  35. data/test/fixtures/fetch_tnc.json +11 -0
  36. data/test/fixtures/stakeholder_collection.json +35 -0
  37. data/test/fixtures/webhook_by_account_collection.json +35 -0
  38. data/test/fixtures/webhook_collection.json +85 -0
  39. data/test/razorpay/test_account.rb +134 -0
  40. data/test/razorpay/test_card.rb +6 -0
  41. data/test/razorpay/test_customer.rb +8 -8
  42. data/test/razorpay/test_generic.rb +112 -0
  43. data/test/razorpay/test_iin.rb +23 -0
  44. data/test/razorpay/test_order.rb +1 -1
  45. data/test/razorpay/test_product.rb +67 -0
  46. data/test/razorpay/test_settlement.rb +1 -1
  47. data/test/razorpay/test_stakeholder.rb +87 -0
  48. data/test/razorpay/test_token.rb +66 -0
  49. data/test/razorpay/test_transfer.rb +1 -1
  50. data/test/razorpay/test_webhook.rb +132 -0
  51. metadata +52 -2
@@ -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
@@ -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
- # 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
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::Entity, token, 'Token not an instance of Razorpay::Entity class'
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,112 @@
1
+ require 'test_helper'
2
+
3
+ module Razorpay
4
+ # Tests for Razorpay::Addon
5
+ class RazorpayGenericTest < Minitest::Test
6
+ class Generic < Razorpay::Entity; end
7
+
8
+ def setup
9
+ @order_id = 'order_50sX9hGHZJvjjI'
10
+ @customer_id = 'cust_6vRXClWqnLhV14'
11
+ @invoice_id = 'inv_6vRZmJYFAG1mNq'
12
+ @addon_id = 'ao_IrSY3UIqDRx7df'
13
+ end
14
+
15
+ def test_generic_should_be_defined
16
+ refute_nil Razorpay::Generic
17
+ end
18
+
19
+ # Test fetch endpoint by order entity
20
+ def test_generic_orders_should_be_fetch
21
+ stub_get(%r{orders/#{@order_id}$}, 'fake_order')
22
+
23
+ client = Razorpay::Generic.new("orders")
24
+
25
+ order = client.do(@order_id)
26
+
27
+ assert_equal 5000, order.amount
28
+ assert_equal 'INR', order.currency
29
+ assert_equal 'TEST', order.receipt
30
+ end
31
+
32
+ # Test post endpoint by order entity
33
+ def test_generic_orders_should_be_create
34
+ para_attr = {
35
+ "amount": 5000
36
+ }
37
+
38
+ stub_post("#{BASE_URI}/v1/orders/", 'fake_order', para_attr.to_json)
39
+
40
+ client = Razorpay::Generic.new("orders")
41
+ order = client.do("", "Post", para_attr.to_json)
42
+ assert_equal 5000, order.amount
43
+ assert_equal 'INR', order.currency
44
+ assert_equal 'TEST', order.receipt
45
+ end
46
+
47
+ # Test fetch endpoint by order entity
48
+ def test_generic_orders_should_be_edit
49
+ para_attr = {
50
+ "notes": {
51
+ "purpose": "Test UPI QR code notes uodate"
52
+ }
53
+ }
54
+
55
+ stub_patch("#{BASE_URI}/v1/orders/#{@order_id}", 'fake_order', para_attr.to_json)
56
+
57
+ client = Razorpay::Generic.new("orders")
58
+ order = client.do(@order_id, "Patch", para_attr.to_json)
59
+ assert_equal 5000, order.amount
60
+ assert_equal 'INR', order.currency
61
+ assert_equal 'TEST', order.receipt
62
+ end
63
+
64
+ # Test post endpoint by order entity
65
+ def test_generic_customer_should_be_create
66
+ para_attr = {
67
+ "name": "Gaurav Kumar",
68
+ "contact": 9123456780,
69
+ "email": "gaurav.kumar@example.com",
70
+ "notes": {
71
+ "notes_key_1": "Tea, Earl Grey, Hot",
72
+ "notes_key_2": "Tea, Earl Grey… decaf."
73
+ }
74
+ }
75
+
76
+ stub_post("#{BASE_URI}/v1/customers/", 'fake_customer', para_attr.to_json)
77
+
78
+ client = Razorpay::Generic.new("customers")
79
+ customer = client.do("","Post", para_attr.to_json)
80
+ assert_equal 'test@razorpay.com', customer.email
81
+ assert_equal '9876543210', customer.contact
82
+ end
83
+
84
+ # Test put endpoint by order entity
85
+ def test_generic_customer_should_be_edit
86
+ para_attr = {
87
+ "contact": 9123456780,
88
+ }
89
+
90
+ stub_put("#{BASE_URI}/v1/customers/#{@customer_id}", 'fake_customer', para_attr.to_json)
91
+
92
+ client = Razorpay::Generic.new("customers")
93
+ customer = client.do(@customer_id, "Put", para_attr.to_json)
94
+ assert_equal 'test@razorpay.com', customer.email
95
+ assert_equal '9876543210', customer.contact
96
+ end
97
+
98
+ def test_generic_delete_specific_invoice
99
+ stub_delete(%r{invoices/#{@invoice_id}$}, 'empty')
100
+ client = Razorpay::Generic.new("invoices")
101
+ invoice = client.do("#{@invoice_id}", "Delete")
102
+ refute_nil invoice
103
+ end
104
+
105
+ def test_generic_delete_addon
106
+ stub_delete(%r{addons/#{@addon_id}$}, 'empty')
107
+ client = Razorpay::Generic.new("addons")
108
+ addon = client.do("#{@addon_id}", "Delete")
109
+ refute_nil addon
110
+ end
111
+ end
112
+ end
@@ -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
@@ -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'
@@ -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'
@@ -0,0 +1,87 @@
1
+ require 'test_helper'
2
+
3
+ module Razorpay
4
+ # Tests for Razorpay::Account
5
+ class RazorpayStakeholderonTest < Minitest::Test
6
+ class Stakeholder < Razorpay::Entity; end
7
+
8
+ def setup
9
+ @stakeholder_id = 'sth_00000000000001'
10
+ @account_id = 'acc_00000000000001'
11
+ @email = 'gaurav.kumar@example.com'
12
+ # Any request that ends with stakeholder_id
13
+ stub_get(%r{/v2/accounts\/#{Regexp.quote(@account_id)}/stakeholders\/#{Regexp.quote(@stakeholder_id)}$}, 'fake_stakeholder')
14
+ end
15
+
16
+ def test_stakeholder_should_be_defined
17
+ refute_nil Razorpay::Stakeholder
18
+ end
19
+
20
+ def test_stakeholder_should_be_available
21
+ stakeholder = Razorpay::Stakeholder.fetch(@account_id, @stakeholder_id)
22
+ assert_instance_of Razorpay::Stakeholder, stakeholder, 'Stakeholder not an instance of Entity class'
23
+ assert_equal @stakeholder_id, stakeholder.id, 'Stakeholder IDs do not match'
24
+ assert_equal @email, stakeholder.email, 'Stakeholder email is accessible'
25
+ end
26
+
27
+ def test_stakeholder_should_be_create
28
+
29
+ payload = create_stakeholder_payload()
30
+ stub_post(%r{accounts/#{@account_id}/stakeholders$}, 'fake_stakeholder', payload.to_json)
31
+
32
+ stakeholder = Razorpay::Stakeholder.create(@account_id, payload.to_json)
33
+ assert_instance_of Razorpay::Stakeholder, stakeholder, 'Stakeholder not an instance of Entity class'
34
+ assert_equal @stakeholder_id, stakeholder.id, 'Stakeholder IDs do not match'
35
+ assert_equal @email, stakeholder.email, 'Stakeholder email is accessible'
36
+ end
37
+
38
+ def test_stakeholder_edit
39
+
40
+ payload = create_stakeholder_payload()
41
+ stub_patch(%r{accounts/#{@account_id}/stakeholders/#{@stakeholder_id}$}, 'fake_stakeholder', payload.to_json)
42
+
43
+ stakeholder = Razorpay::Stakeholder.edit(@account_id, @stakeholder_id, payload.to_json)
44
+ assert_instance_of Razorpay::Stakeholder, stakeholder, 'Stakeholder not an instance of Entity class'
45
+ assert_equal @stakeholder_id, stakeholder.id, 'Stakeholder IDs do not match'
46
+ assert_equal @email, stakeholder.email, 'Stakeholder email is accessible'
47
+ end
48
+
49
+ def test_fetching_all_stakeholder
50
+ stub_get(%r{accounts/#{@account_id}/stakeholders$}, 'stakeholder_collection')
51
+ orders = Razorpay::Stakeholder.all(@account_id)
52
+ assert_instance_of Razorpay::Collection, orders, 'Orders should be an array'
53
+ assert !orders.items.empty?, 'orders should be more than one'
54
+ end
55
+
56
+ def create_stakeholder_payload
57
+ return {
58
+ "percentage_ownership": 10,
59
+ "name": "Gaurav Kumar",
60
+ "email": "gaurav.kumar@example.com",
61
+ "relationship": {
62
+ "director": true,
63
+ "executive": false
64
+ },
65
+ "phone": {
66
+ "primary": "9000090000",
67
+ "secondary": "9000090000"
68
+ },
69
+ "addresses": {
70
+ "residential": {
71
+ "street": "506, Koramangala 1st block",
72
+ "city": "Bengaluru",
73
+ "state": "Karnataka",
74
+ "postal_code": "560034",
75
+ "country": "IN"
76
+ }
77
+ },
78
+ "kyc": {
79
+ "pan": "AVOPB1111K"
80
+ },
81
+ "notes": {
82
+ "random_key_by_partner": "random_value"
83
+ }
84
+ }
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,66 @@
1
+ require 'test_helper'
2
+
3
+ module Razorpay
4
+ # Tests for Razorpay::Token
5
+ class RazorpayTokenTest < Minitest::Test
6
+ class Token < Razorpay::Entity; end
7
+
8
+ def setup
9
+ @token_id = 'token_00000000000001'
10
+ @customer_id = 'cust_1Aa00000000001'
11
+ @method = 'card'
12
+ end
13
+
14
+ def test_token_should_be_defined
15
+ refute_nil Razorpay::Token
16
+ end
17
+
18
+ def test_token_should_be_available
19
+ payload = {
20
+ "id": @token_id
21
+ }
22
+ stub_post(%r{/tokens/fetch$}, 'fake_tokenise_customer', payload.to_json)
23
+ token = Razorpay::Token.fetch(payload.to_json)
24
+ assert_instance_of Razorpay::Token, token, 'token not an instance of Token class'
25
+ assert_equal @token_id, token.id, 'Token IDs do not match'
26
+ end
27
+
28
+ def test_token_should_be_delete
29
+ payload = {
30
+ "id": @token_id
31
+ }
32
+ stub_post(%r{/tokens/delete$}, 'empty', payload.to_json)
33
+ token = Razorpay::Token.delete(payload.to_json)
34
+ assert_instance_of Razorpay::Entity, token, 'token not an instance of Entity class'
35
+ end
36
+
37
+ def test_token_create
38
+
39
+ payload = create_token_payload()
40
+ stub_post(%r{/tokens$}, 'fake_tokenise_customer', payload.to_json)
41
+
42
+ token = Razorpay::Token.create(payload.to_json)
43
+ assert_instance_of Razorpay::Token, token, 'Token not an instance of Token class'
44
+ assert_equal @token_id, token.id, 'Token IDs do not match'
45
+ end
46
+
47
+ def create_token_payload
48
+ return {
49
+ "customer_id": "cust_00000000000002",
50
+ "method": "card",
51
+ "card": {
52
+ "number": "4854000000708430",
53
+ "cvv": "123",
54
+ "expiry_month": "12",
55
+ "expiry_year": "24",
56
+ "name": "Gaurav Kumar"
57
+ },
58
+ "authentication": {
59
+ "provider": "razorpay",
60
+ "provider_reference_id": "pay_000000000000"
61
+ },
62
+ "notes": []
63
+ }
64
+ end
65
+ end
66
+ end
@@ -45,7 +45,7 @@ module Razorpay
45
45
  end
46
46
 
47
47
  def test_transfer_fetch_settlement_details
48
- stub_get("#{BASE_URI}transfers/?expand[]=recipient_settlement", 'transfers_collection')
48
+ stub_get("#{BASE_URI}/v1/transfers/?expand[]=recipient_settlement", 'transfers_collection')
49
49
  transfer = Razorpay::Transfer.fetch_settlements
50
50
  assert_instance_of Razorpay::Collection, transfer , 'Transfer should be an array'
51
51
  refute_empty transfer.items , 'Transfer should be more than one'