pay-lago 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -5
- data/app/models/concerns/pay/lago/pay_payment_method_extensions.rb +23 -0
- data/docs/4_payment_methods.md +40 -0
- data/lib/pay/lago/billable.rb +53 -12
- data/lib/pay/lago/engine.rb +2 -1
- data/lib/pay/lago/payment_method.rb +44 -6
- data/lib/pay/lago/subscription.rb +6 -13
- data/lib/pay/lago/version.rb +1 -1
- data/lib/pay/lago/webhooks/customer_payment_provider_created.rb +1 -7
- data/pay-lago.gemspec +1 -1
- data/test/dummy/db/migrate/1_create_pay_tables.rb +93 -0
- data/test/dummy/db/schema.rb +17 -16
- data/test/fixtures/pay/customers.yml +1 -0
- data/test/pay/lago/billable_test.rb +1 -1
- data/test/pay/lago/payment_method_test.rb +34 -0
- data/test/pay/lago/subscription_test.rb +3 -5
- data/test/vcr_cassettes/test_PaymentMethod_can_be_made_default__updating_Lago.yml +163 -0
- data/test/vcr_cassettes/test_add_payment_method_to_lago.yml +62 -8
- data/test/vcr_cassettes/test_can_get_lago_processor_customer.yml +7 -7
- data/test/vcr_cassettes/test_can_make_a_lago_processor_charge.yml +22 -22
- data/test/vcr_cassettes/test_generates_lago_processor_id.yml +8 -59
- data/test/vcr_cassettes/test_lago_cannot_change_quantity.yml +16 -16
- data/test/vcr_cassettes/test_lago_processor_cancel.yml +32 -32
- data/test/vcr_cassettes/test_lago_processor_charge.yml +55 -55
- data/test/vcr_cassettes/test_lago_processor_on_grace_period__is_always_false.yml +16 -16
- data/test/vcr_cassettes/test_lago_processor_pause_raises_an_error.yml +16 -16
- data/test/vcr_cassettes/test_lago_processor_paused__is_always_false.yml +16 -16
- data/test/vcr_cassettes/test_lago_processor_refund_with_premium.yml +64 -64
- data/test/vcr_cassettes/test_lago_processor_resume_raises_an_error.yml +16 -16
- data/test/vcr_cassettes/test_lago_processor_subscribe.yml +17 -16
- data/test/vcr_cassettes/test_lago_processor_subscription.yml +24 -24
- data/test/vcr_cassettes/test_lago_processor_swap.yml +86 -32
- metadata +10 -5
- /data/docs/{4_webhooks.md → 5_webhooks.md} +0 -0
@@ -8,11 +8,11 @@ http_interactions:
|
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
Authorization:
|
11
|
-
- Bearer
|
11
|
+
- Bearer <LAGO_API_KEY>
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
User-Agent:
|
15
|
-
- Lago Ruby v0.
|
15
|
+
- Lago Ruby v0.52.2-beta
|
16
16
|
Accept-Encoding:
|
17
17
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
18
|
Accept:
|
@@ -37,35 +37,35 @@ http_interactions:
|
|
37
37
|
Content-Type:
|
38
38
|
- application/json; charset=utf-8
|
39
39
|
Etag:
|
40
|
-
- W/"
|
40
|
+
- W/"97cba9d09cf8d9e47b2eb5e9e4d3f468"
|
41
41
|
Cache-Control:
|
42
42
|
- max-age=0, private, must-revalidate
|
43
43
|
X-Request-Id:
|
44
|
-
-
|
44
|
+
- e21f3b01-ba9c-4c0e-9b3b-e55628b395f1
|
45
45
|
X-Runtime:
|
46
|
-
- '0.
|
46
|
+
- '0.009260'
|
47
47
|
Vary:
|
48
48
|
- Origin
|
49
49
|
Transfer-Encoding:
|
50
50
|
- chunked
|
51
51
|
body:
|
52
52
|
encoding: UTF-8
|
53
|
-
string: '{"customer":{"lago_id":"
|
54
|
-
User","sequential_id":
|
55
|
-
recorded_at:
|
53
|
+
string: '{"customer":{"lago_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_id":"gid://dummy/Pay::Customer/772847388","name":"Lago
|
54
|
+
User","sequential_id":3,"slug":"AMO-15BA-003","created_at":"2023-11-07T23:51:03Z","updated_at":"2023-12-11T04:52:33Z","country":null,"address_line1":null,"address_line2":null,"state":null,"zipcode":null,"email":"lago@example.org","city":null,"url":null,"phone":null,"logo_url":null,"legal_name":null,"legal_number":null,"currency":"USD","tax_identification_number":null,"timezone":null,"applicable_timezone":"UTC","net_payment_term":null,"external_salesforce_id":null,"billing_configuration":{"invoice_grace_period":null,"payment_provider":"stripe","vat_rate":null,"document_locale":null,"provider_customer_id":"x","provider_payment_methods":["card"]},"metadata":[],"taxes":[]}}'
|
55
|
+
recorded_at: Mon, 11 Dec 2023 06:07:17 GMT
|
56
56
|
- request:
|
57
57
|
method: post
|
58
58
|
uri: http://localhost:3000/api/v1/subscriptions
|
59
59
|
body:
|
60
60
|
encoding: UTF-8
|
61
|
-
string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"default","name":"default","external_id":"gid://dummy/Pay::Subscription/
|
61
|
+
string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"default","name":"default","external_id":"gid://dummy/Pay::Subscription/2"}}'
|
62
62
|
headers:
|
63
63
|
Authorization:
|
64
|
-
- Bearer
|
64
|
+
- Bearer <LAGO_API_KEY>
|
65
65
|
Content-Type:
|
66
66
|
- application/json
|
67
67
|
User-Agent:
|
68
|
-
- Lago Ruby v0.
|
68
|
+
- Lago Ruby v0.52.2-beta
|
69
69
|
Accept-Encoding:
|
70
70
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
71
71
|
Accept:
|
@@ -90,19 +90,19 @@ http_interactions:
|
|
90
90
|
Content-Type:
|
91
91
|
- application/json; charset=utf-8
|
92
92
|
Etag:
|
93
|
-
- W/"
|
93
|
+
- W/"a40b5ae362acd75fd3cb1682b457acac"
|
94
94
|
Cache-Control:
|
95
95
|
- max-age=0, private, must-revalidate
|
96
96
|
X-Request-Id:
|
97
|
-
-
|
97
|
+
- 57ff4a45-d60c-4ace-8743-38149f3d95a3
|
98
98
|
X-Runtime:
|
99
|
-
- 0.
|
99
|
+
- '0.038634'
|
100
100
|
Vary:
|
101
101
|
- Origin
|
102
102
|
Transfer-Encoding:
|
103
103
|
- chunked
|
104
104
|
body:
|
105
105
|
encoding: UTF-8
|
106
|
-
string: '{"subscription":{"lago_id":"
|
107
|
-
recorded_at:
|
106
|
+
string: '{"subscription":{"lago_id":"57d6887f-b67b-4572-9dac-1bb4b62a90c9","external_id":"gid://dummy/Pay::Subscription/2","lago_customer_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-12-11T06:07:16Z","started_at":"2023-12-11T06:07:16Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-11T06:07:16Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-11","plan":{"lago_id":"53e656cc-7d9e-433a-9494-7beb33164c1c","name":"Default","invoice_display_name":null,"created_at":"2023-12-11T04:51:50Z","code":"default","interval":"monthly","description":"","amount_cents":100,"amount_currency":"USD","trial_period":0.0,"pay_in_advance":false,"bill_charges_monthly":null,"customers_count":1,"active_subscriptions_count":1,"draft_invoices_count":0,"parent_id":null,"charges":[],"taxes":[]}}}'
|
107
|
+
recorded_at: Mon, 11 Dec 2023 06:07:17 GMT
|
108
108
|
recorded_with: VCR 6.2.0
|
@@ -8,11 +8,11 @@ http_interactions:
|
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
Authorization:
|
11
|
-
- Bearer
|
11
|
+
- Bearer <LAGO_API_KEY>
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
User-Agent:
|
15
|
-
- Lago Ruby v0.
|
15
|
+
- Lago Ruby v0.52.2-beta
|
16
16
|
Accept-Encoding:
|
17
17
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
18
|
Accept:
|
@@ -37,35 +37,35 @@ http_interactions:
|
|
37
37
|
Content-Type:
|
38
38
|
- application/json; charset=utf-8
|
39
39
|
Etag:
|
40
|
-
- W/"
|
40
|
+
- W/"97cba9d09cf8d9e47b2eb5e9e4d3f468"
|
41
41
|
Cache-Control:
|
42
42
|
- max-age=0, private, must-revalidate
|
43
43
|
X-Request-Id:
|
44
|
-
-
|
44
|
+
- 281161e3-2fb9-4d33-969c-35aca0b54813
|
45
45
|
X-Runtime:
|
46
|
-
- '0.
|
46
|
+
- '0.008922'
|
47
47
|
Vary:
|
48
48
|
- Origin
|
49
49
|
Transfer-Encoding:
|
50
50
|
- chunked
|
51
51
|
body:
|
52
52
|
encoding: UTF-8
|
53
|
-
string: '{"customer":{"lago_id":"
|
54
|
-
User","sequential_id":
|
55
|
-
recorded_at:
|
53
|
+
string: '{"customer":{"lago_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_id":"gid://dummy/Pay::Customer/772847388","name":"Lago
|
54
|
+
User","sequential_id":3,"slug":"AMO-15BA-003","created_at":"2023-11-07T23:51:03Z","updated_at":"2023-12-11T04:52:33Z","country":null,"address_line1":null,"address_line2":null,"state":null,"zipcode":null,"email":"lago@example.org","city":null,"url":null,"phone":null,"logo_url":null,"legal_name":null,"legal_number":null,"currency":"USD","tax_identification_number":null,"timezone":null,"applicable_timezone":"UTC","net_payment_term":null,"external_salesforce_id":null,"billing_configuration":{"invoice_grace_period":null,"payment_provider":"stripe","vat_rate":null,"document_locale":null,"provider_customer_id":"x","provider_payment_methods":["card"]},"metadata":[],"taxes":[]}}'
|
55
|
+
recorded_at: Mon, 11 Dec 2023 06:07:16 GMT
|
56
56
|
- request:
|
57
57
|
method: post
|
58
58
|
uri: http://localhost:3000/api/v1/subscriptions
|
59
59
|
body:
|
60
60
|
encoding: UTF-8
|
61
|
-
string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"default","name":"default","external_id":"gid://dummy/Pay::Subscription/
|
61
|
+
string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"default","name":"default","external_id":"gid://dummy/Pay::Subscription/2"}}'
|
62
62
|
headers:
|
63
63
|
Authorization:
|
64
|
-
- Bearer
|
64
|
+
- Bearer <LAGO_API_KEY>
|
65
65
|
Content-Type:
|
66
66
|
- application/json
|
67
67
|
User-Agent:
|
68
|
-
- Lago Ruby v0.
|
68
|
+
- Lago Ruby v0.52.2-beta
|
69
69
|
Accept-Encoding:
|
70
70
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
71
71
|
Accept:
|
@@ -90,19 +90,19 @@ http_interactions:
|
|
90
90
|
Content-Type:
|
91
91
|
- application/json; charset=utf-8
|
92
92
|
Etag:
|
93
|
-
- W/"
|
93
|
+
- W/"a40b5ae362acd75fd3cb1682b457acac"
|
94
94
|
Cache-Control:
|
95
95
|
- max-age=0, private, must-revalidate
|
96
96
|
X-Request-Id:
|
97
|
-
-
|
97
|
+
- 1d4b65bd-05a0-4b44-8cf2-1f77f56ce870
|
98
98
|
X-Runtime:
|
99
|
-
- 0.
|
99
|
+
- '0.047111'
|
100
100
|
Vary:
|
101
101
|
- Origin
|
102
102
|
Transfer-Encoding:
|
103
103
|
- chunked
|
104
104
|
body:
|
105
105
|
encoding: UTF-8
|
106
|
-
string: '{"subscription":{"lago_id":"
|
107
|
-
recorded_at:
|
106
|
+
string: '{"subscription":{"lago_id":"57d6887f-b67b-4572-9dac-1bb4b62a90c9","external_id":"gid://dummy/Pay::Subscription/2","lago_customer_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-12-11T06:07:16Z","started_at":"2023-12-11T06:07:16Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-11T06:07:16Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-11","plan":{"lago_id":"53e656cc-7d9e-433a-9494-7beb33164c1c","name":"Default","invoice_display_name":null,"created_at":"2023-12-11T04:51:50Z","code":"default","interval":"monthly","description":"","amount_cents":100,"amount_currency":"USD","trial_period":0.0,"pay_in_advance":false,"bill_charges_monthly":null,"customers_count":1,"active_subscriptions_count":1,"draft_invoices_count":0,"parent_id":null,"charges":[],"taxes":[]}}}'
|
107
|
+
recorded_at: Mon, 11 Dec 2023 06:07:16 GMT
|
108
108
|
recorded_with: VCR 6.2.0
|
@@ -8,11 +8,11 @@ http_interactions:
|
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
Authorization:
|
11
|
-
- Bearer
|
11
|
+
- Bearer <LAGO_API_KEY>
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
User-Agent:
|
15
|
-
- Lago Ruby v0.
|
15
|
+
- Lago Ruby v0.52.2-beta
|
16
16
|
Accept-Encoding:
|
17
17
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
18
|
Accept:
|
@@ -37,35 +37,35 @@ http_interactions:
|
|
37
37
|
Content-Type:
|
38
38
|
- application/json; charset=utf-8
|
39
39
|
Etag:
|
40
|
-
- W/"
|
40
|
+
- W/"97cba9d09cf8d9e47b2eb5e9e4d3f468"
|
41
41
|
Cache-Control:
|
42
42
|
- max-age=0, private, must-revalidate
|
43
43
|
X-Request-Id:
|
44
|
-
-
|
44
|
+
- 496457ff-cc50-4c94-9c61-9109f240dd9b
|
45
45
|
X-Runtime:
|
46
|
-
- 0.
|
46
|
+
- '0.008925'
|
47
47
|
Vary:
|
48
48
|
- Origin
|
49
49
|
Transfer-Encoding:
|
50
50
|
- chunked
|
51
51
|
body:
|
52
52
|
encoding: UTF-8
|
53
|
-
string: '{"customer":{"lago_id":"
|
54
|
-
User","sequential_id":
|
55
|
-
recorded_at:
|
53
|
+
string: '{"customer":{"lago_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_id":"gid://dummy/Pay::Customer/772847388","name":"Lago
|
54
|
+
User","sequential_id":3,"slug":"AMO-15BA-003","created_at":"2023-11-07T23:51:03Z","updated_at":"2023-12-11T04:52:33Z","country":null,"address_line1":null,"address_line2":null,"state":null,"zipcode":null,"email":"lago@example.org","city":null,"url":null,"phone":null,"logo_url":null,"legal_name":null,"legal_number":null,"currency":"USD","tax_identification_number":null,"timezone":null,"applicable_timezone":"UTC","net_payment_term":null,"external_salesforce_id":null,"billing_configuration":{"invoice_grace_period":null,"payment_provider":"stripe","vat_rate":null,"document_locale":null,"provider_customer_id":"x","provider_payment_methods":["card"]},"metadata":[],"taxes":[]}}'
|
55
|
+
recorded_at: Mon, 11 Dec 2023 06:07:17 GMT
|
56
56
|
- request:
|
57
57
|
method: post
|
58
58
|
uri: http://localhost:3000/api/v1/subscriptions
|
59
59
|
body:
|
60
60
|
encoding: UTF-8
|
61
|
-
string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"default","name":"default","external_id":"gid://dummy/Pay::Subscription/
|
61
|
+
string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"default","name":"default","external_id":"gid://dummy/Pay::Subscription/2"}}'
|
62
62
|
headers:
|
63
63
|
Authorization:
|
64
|
-
- Bearer
|
64
|
+
- Bearer <LAGO_API_KEY>
|
65
65
|
Content-Type:
|
66
66
|
- application/json
|
67
67
|
User-Agent:
|
68
|
-
- Lago Ruby v0.
|
68
|
+
- Lago Ruby v0.52.2-beta
|
69
69
|
Accept-Encoding:
|
70
70
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
71
71
|
Accept:
|
@@ -90,19 +90,19 @@ http_interactions:
|
|
90
90
|
Content-Type:
|
91
91
|
- application/json; charset=utf-8
|
92
92
|
Etag:
|
93
|
-
- W/"
|
93
|
+
- W/"a40b5ae362acd75fd3cb1682b457acac"
|
94
94
|
Cache-Control:
|
95
95
|
- max-age=0, private, must-revalidate
|
96
96
|
X-Request-Id:
|
97
|
-
-
|
97
|
+
- 743142a0-1d22-4966-a285-67035b149128
|
98
98
|
X-Runtime:
|
99
|
-
- 0.
|
99
|
+
- '0.029311'
|
100
100
|
Vary:
|
101
101
|
- Origin
|
102
102
|
Transfer-Encoding:
|
103
103
|
- chunked
|
104
104
|
body:
|
105
105
|
encoding: UTF-8
|
106
|
-
string: '{"subscription":{"lago_id":"
|
107
|
-
recorded_at:
|
106
|
+
string: '{"subscription":{"lago_id":"57d6887f-b67b-4572-9dac-1bb4b62a90c9","external_id":"gid://dummy/Pay::Subscription/2","lago_customer_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-12-11T06:07:16Z","started_at":"2023-12-11T06:07:16Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-11T06:07:16Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-11","plan":{"lago_id":"53e656cc-7d9e-433a-9494-7beb33164c1c","name":"Default","invoice_display_name":null,"created_at":"2023-12-11T04:51:50Z","code":"default","interval":"monthly","description":"","amount_cents":100,"amount_currency":"USD","trial_period":0.0,"pay_in_advance":false,"bill_charges_monthly":null,"customers_count":1,"active_subscriptions_count":1,"draft_invoices_count":0,"parent_id":null,"charges":[],"taxes":[]}}}'
|
107
|
+
recorded_at: Mon, 11 Dec 2023 06:07:17 GMT
|
108
108
|
recorded_with: VCR 6.2.0
|