-
Notifications
You must be signed in to change notification settings - Fork 52
/
test_preapproval_plan.rb
98 lines (84 loc) · 2.37 KB
/
test_preapproval_plan.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# typed: true
# frozen_string_literal: true
require_relative '../lib/mercadopago'
require 'minitest/autorun'
class TestPreapprovalPlan < Minitest::Test
def setup
@preapproval_plan_data = {
reason: 'Yoga classes',
auto_recurring: {
frequency: 1,
frequency_type: 'months',
repetitions: 12,
billing_day: 10,
billing_day_proportional: true,
free_trial: {
frequency: 1,
frequency_type: 'months'
},
transaction_amount: 10,
currency_id: 'BRL'
},
payment_methods_allowed: {
payment_types: [
{}
],
payment_methods: [
{}
]
},
back_url: 'https://www.yoursite.com'
}
end
def test_method_search
sdk = Mercadopago::SDK.new(ENV['ACCESS_TOKEN'])
result = sdk.preapproval_plan.create(@preapproval_plan_data)
assert_equal 201, result[:status]
result = sdk.preapproval_plan.search(filters: { id: result[:response]['id'] })
assert_equal 200, result[:status]
end
def test_method_get_id
sdk = Mercadopago::SDK.new(ENV['ACCESS_TOKEN'])
result = sdk.preapproval_plan.create(@preapproval_plan_data)
assert_equal 201, result[:status]
result = sdk.preapproval_plan.get(result[:response]['id'])
assert_equal 200, result[:status]
end
def test_method_post
sdk = Mercadopago::SDK.new(ENV['ACCESS_TOKEN'])
result = sdk.preapproval_plan.create(@preapproval_plan_data)
assert_equal 201, result[:status]
end
def test_method_put
sdk = Mercadopago::SDK.new(ENV['ACCESS_TOKEN'])
update_data = {
reason: 'Pilates classes',
auto_recurring: {
frequency: 1,
frequency_type: 'months',
repetitions: 20,
billing_day: 15,
billing_day_proportional: true,
free_trial: {
frequency: 1,
frequency_type: 'months'
},
transaction_amount: 10,
currency_id: 'BRL'
},
payment_methods_allowed: {
payment_types: [
{}
],
payment_methods: [
{}
]
},
back_url: 'https://www.yoursite.com'
}
result = sdk.preapproval_plan.create(@preapproval_plan_data)
assert_equal 201, result[:status]
result = sdk.preapproval_plan.update(result[:response]['id'], update_data)
assert_equal 200, result[:status]
end
end