pay-lago 0.1.0 → 0.1.1

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +2 -5
  5. data/app/models/concerns/pay/lago/pay_payment_method_extensions.rb +23 -0
  6. data/docs/4_payment_methods.md +40 -0
  7. data/lib/pay/lago/billable.rb +53 -12
  8. data/lib/pay/lago/engine.rb +2 -1
  9. data/lib/pay/lago/payment_method.rb +44 -6
  10. data/lib/pay/lago/subscription.rb +6 -13
  11. data/lib/pay/lago/version.rb +1 -1
  12. data/lib/pay/lago/webhooks/customer_payment_provider_created.rb +1 -7
  13. data/pay-lago.gemspec +1 -1
  14. data/test/dummy/db/migrate/1_create_pay_tables.rb +93 -0
  15. data/test/dummy/db/schema.rb +17 -16
  16. data/test/fixtures/pay/customers.yml +1 -0
  17. data/test/pay/lago/billable_test.rb +1 -1
  18. data/test/pay/lago/payment_method_test.rb +34 -0
  19. data/test/pay/lago/subscription_test.rb +3 -5
  20. data/test/vcr_cassettes/test_PaymentMethod_can_be_made_default__updating_Lago.yml +163 -0
  21. data/test/vcr_cassettes/test_add_payment_method_to_lago.yml +62 -8
  22. data/test/vcr_cassettes/test_can_get_lago_processor_customer.yml +7 -7
  23. data/test/vcr_cassettes/test_can_make_a_lago_processor_charge.yml +22 -22
  24. data/test/vcr_cassettes/test_generates_lago_processor_id.yml +8 -59
  25. data/test/vcr_cassettes/test_lago_cannot_change_quantity.yml +16 -16
  26. data/test/vcr_cassettes/test_lago_processor_cancel.yml +32 -32
  27. data/test/vcr_cassettes/test_lago_processor_charge.yml +55 -55
  28. data/test/vcr_cassettes/test_lago_processor_on_grace_period__is_always_false.yml +16 -16
  29. data/test/vcr_cassettes/test_lago_processor_pause_raises_an_error.yml +16 -16
  30. data/test/vcr_cassettes/test_lago_processor_paused__is_always_false.yml +16 -16
  31. data/test/vcr_cassettes/test_lago_processor_refund_with_premium.yml +64 -64
  32. data/test/vcr_cassettes/test_lago_processor_resume_raises_an_error.yml +16 -16
  33. data/test/vcr_cassettes/test_lago_processor_subscribe.yml +17 -16
  34. data/test/vcr_cassettes/test_lago_processor_subscription.yml +24 -24
  35. data/test/vcr_cassettes/test_lago_processor_swap.yml +86 -32
  36. metadata +10 -5
  37. /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 155ed033-8716-4587-9ac6-fed8ddae3317
11
+ - Bearer <LAGO_API_KEY>
12
12
  Content-Type:
13
13
  - application/json
14
14
  User-Agent:
15
- - Lago Ruby v0.44.0-beta
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/"af429c6f51b25054dd9b23522b77d57d"
40
+ - W/"97cba9d09cf8d9e47b2eb5e9e4d3f468"
41
41
  Cache-Control:
42
42
  - max-age=0, private, must-revalidate
43
43
  X-Request-Id:
44
- - "1eb621ad-c152-487e-8233-ed29ea1ddbe0"
44
+ - 04a9bef2-322e-418b-8a8e-b499c604ea5b
45
45
  X-Runtime:
46
- - '0.006367'
46
+ - '0.007947'
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":"c8bb805a-590c-444f-ae14-66589764f273","external_id":"gid://dummy/Pay::Customer/772847388","name":"Lago
54
- User","sequential_id":4,"slug":"AMO-FBCD-004","created_at":"2023-09-18T06:42:57Z","updated_at":"2023-09-18T06:43:11Z","country":null,"address_line1":null,"address_line2":null,"state":null,"zipcode":null,"email":"test@example.com","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":null,"vat_rate":null,"document_locale":null},"metadata":[],"taxes":[]}}'
55
- recorded_at: Wed, 20 Sep 2023 03:07:55 GMT
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/913727099"}}'
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 155ed033-8716-4587-9ac6-fed8ddae3317
64
+ - Bearer <LAGO_API_KEY>
65
65
  Content-Type:
66
66
  - application/json
67
67
  User-Agent:
68
- - Lago Ruby v0.44.0-beta
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,34 +90,34 @@ http_interactions:
90
90
  Content-Type:
91
91
  - application/json; charset=utf-8
92
92
  Etag:
93
- - W/"fb3fb93434e12318f7063defd93d7c68"
93
+ - W/"a40b5ae362acd75fd3cb1682b457acac"
94
94
  Cache-Control:
95
95
  - max-age=0, private, must-revalidate
96
96
  X-Request-Id:
97
- - 33b9839a-08f2-4c19-82ba-76d2add45bdf
97
+ - e70edeec-5770-42f2-b2ed-2f06a08128c1
98
98
  X-Runtime:
99
- - 0.017908
99
+ - '0.030655'
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":"4a849692-2b6d-48cc-a3f4-02c03a004b3b","external_id":"gid://dummy/Pay::Subscription/913727099","lago_customer_id":"c8bb805a-590c-444f-ae14-66589764f273","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-09-19T00:47:59Z","started_at":"2023-09-19T00:47:59Z","terminated_at":null,"canceled_at":null,"created_at":"2023-09-19T00:47:59Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-09-19"}}'
107
- recorded_at: Wed, 20 Sep 2023 03:07:55 GMT
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
  - request:
109
109
  method: get
110
- uri: http://localhost:3000/api/v1/subscriptions?external_customer_id=gid://dummy/Pay::Customer/772847388&per_page=9223372036854775807
110
+ uri: http://localhost:3000/api/v1/subscriptions/gid:%2F%2Fdummy%2FPay::Subscription%2F2
111
111
  body:
112
112
  encoding: UTF-8
113
113
  string: ''
114
114
  headers:
115
115
  Authorization:
116
- - Bearer 155ed033-8716-4587-9ac6-fed8ddae3317
116
+ - Bearer <LAGO_API_KEY>
117
117
  Content-Type:
118
118
  - application/json
119
119
  User-Agent:
120
- - Lago Ruby v0.44.0-beta
120
+ - Lago Ruby v0.52.2-beta
121
121
  Accept-Encoding:
122
122
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
123
123
  Accept:
@@ -142,19 +142,19 @@ http_interactions:
142
142
  Content-Type:
143
143
  - application/json; charset=utf-8
144
144
  Etag:
145
- - W/"a5adc13a7d66ae7cd525b05b0c7afdad"
145
+ - W/"a40b5ae362acd75fd3cb1682b457acac"
146
146
  Cache-Control:
147
147
  - max-age=0, private, must-revalidate
148
148
  X-Request-Id:
149
- - "1373b2d1-3494-48d2-b3f5-5c6049bb40bb"
149
+ - 43e0e14c-e45c-41d4-b518-b52eb213dd09
150
150
  X-Runtime:
151
- - 0.016650
151
+ - '0.022499'
152
152
  Vary:
153
153
  - Origin
154
154
  Transfer-Encoding:
155
155
  - chunked
156
156
  body:
157
157
  encoding: UTF-8
158
- string: '{"subscriptions":[{"lago_id":"4a849692-2b6d-48cc-a3f4-02c03a004b3b","external_id":"gid://dummy/Pay::Subscription/913727099","lago_customer_id":"c8bb805a-590c-444f-ae14-66589764f273","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-09-19T00:47:59Z","started_at":"2023-09-19T00:47:59Z","terminated_at":null,"canceled_at":null,"created_at":"2023-09-19T00:47:59Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-09-19"}],"meta":{"current_page":1,"next_page":null,"prev_page":null,"total_pages":1,"total_count":1}}'
159
- recorded_at: Wed, 20 Sep 2023 03:07:55 GMT
158
+ 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":[]}}}'
159
+ recorded_at: Mon, 11 Dec 2023 06:07:17 GMT
160
160
  recorded_with: VCR 6.2.0
@@ -8,11 +8,11 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  Authorization:
11
- - Bearer 155ed033-8716-4587-9ac6-fed8ddae3317
11
+ - Bearer <LAGO_API_KEY>
12
12
  Content-Type:
13
13
  - application/json
14
14
  User-Agent:
15
- - Lago Ruby v0.44.0-beta
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/"af429c6f51b25054dd9b23522b77d57d"
40
+ - W/"97cba9d09cf8d9e47b2eb5e9e4d3f468"
41
41
  Cache-Control:
42
42
  - max-age=0, private, must-revalidate
43
43
  X-Request-Id:
44
- - 55db2865-29d7-4e9c-99e5-84b7ca8e0529
44
+ - '058d0cce-9dd5-4d49-abf5-a8c897287377'
45
45
  X-Runtime:
46
- - 0.008192
46
+ - '0.012613'
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":"c8bb805a-590c-444f-ae14-66589764f273","external_id":"gid://dummy/Pay::Customer/772847388","name":"Lago
54
- User","sequential_id":4,"slug":"AMO-FBCD-004","created_at":"2023-09-18T06:42:57Z","updated_at":"2023-09-18T06:43:11Z","country":null,"address_line1":null,"address_line2":null,"state":null,"zipcode":null,"email":"test@example.com","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":null,"vat_rate":null,"document_locale":null},"metadata":[],"taxes":[]}}'
55
- recorded_at: Wed, 20 Sep 2023 03:27:08 GMT
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: Tue, 12 Dec 2023 01:54:55 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/913727099"}}'
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 155ed033-8716-4587-9ac6-fed8ddae3317
64
+ - Bearer <LAGO_API_KEY>
65
65
  Content-Type:
66
66
  - application/json
67
67
  User-Agent:
68
- - Lago Ruby v0.44.0-beta
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,34 +90,34 @@ http_interactions:
90
90
  Content-Type:
91
91
  - application/json; charset=utf-8
92
92
  Etag:
93
- - W/"e02fd87d05bded0f1ac0e8d1345a6991"
93
+ - W/"01324a35d6c6a010518baa666a945a1f"
94
94
  Cache-Control:
95
95
  - max-age=0, private, must-revalidate
96
96
  X-Request-Id:
97
- - fd96eca5-5543-4934-be42-e26299bf9963
97
+ - d0039292-aceb-4431-a0b8-47b200e5cb4d
98
98
  X-Runtime:
99
- - 0.021745
99
+ - '0.059010'
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":"4a849692-2b6d-48cc-a3f4-02c03a004b3b","external_id":"gid://dummy/Pay::Subscription/913727099","lago_customer_id":"c8bb805a-590c-444f-ae14-66589764f273","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-09-19T00:47:59Z","started_at":"2023-09-19T00:47:59Z","terminated_at":null,"canceled_at":null,"created_at":"2023-09-19T00:47:59Z","previous_plan_code":null,"next_plan_code":"another_plan","downgrade_plan_date":"2023-10-01","subscription_date":"2023-09-19"}}'
107
- recorded_at: Wed, 20 Sep 2023 03:27:08 GMT
106
+ string: '{"subscription":{"lago_id":"d258f521-d901-4895-9b92-9a0eaa6a1d6e","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-12T01:54:55Z","started_at":"2023-12-12T01:54:55Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-12T01:54:55Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-12","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: Tue, 12 Dec 2023 01:54:55 GMT
108
108
  - request:
109
109
  method: get
110
- uri: http://localhost:3000/api/v1/subscriptions?external_customer_id=gid://dummy/Pay::Customer/772847388&per_page=9223372036854775807
110
+ uri: http://localhost:3000/api/v1/subscriptions/gid:%2F%2Fdummy%2FPay::Subscription%2F2
111
111
  body:
112
112
  encoding: UTF-8
113
113
  string: ''
114
114
  headers:
115
115
  Authorization:
116
- - Bearer 155ed033-8716-4587-9ac6-fed8ddae3317
116
+ - Bearer <LAGO_API_KEY>
117
117
  Content-Type:
118
118
  - application/json
119
119
  User-Agent:
120
- - Lago Ruby v0.44.0-beta
120
+ - Lago Ruby v0.52.2-beta
121
121
  Accept-Encoding:
122
122
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
123
123
  Accept:
@@ -142,34 +142,34 @@ http_interactions:
142
142
  Content-Type:
143
143
  - application/json; charset=utf-8
144
144
  Etag:
145
- - W/"7fc7bee0fb810974f19d17e80ded8d7b"
145
+ - W/"01324a35d6c6a010518baa666a945a1f"
146
146
  Cache-Control:
147
147
  - max-age=0, private, must-revalidate
148
148
  X-Request-Id:
149
- - 798b937b-612a-4e6f-ae3a-7c23a8d96d65
149
+ - a3a2d3f2-70a6-4a5a-ae1a-574dd7c6b554
150
150
  X-Runtime:
151
- - 0.011820
151
+ - '0.022375'
152
152
  Vary:
153
153
  - Origin
154
154
  Transfer-Encoding:
155
155
  - chunked
156
156
  body:
157
157
  encoding: UTF-8
158
- string: '{"subscriptions":[{"lago_id":"4a849692-2b6d-48cc-a3f4-02c03a004b3b","external_id":"gid://dummy/Pay::Subscription/913727099","lago_customer_id":"c8bb805a-590c-444f-ae14-66589764f273","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-09-19T00:47:59Z","started_at":"2023-09-19T00:47:59Z","terminated_at":null,"canceled_at":null,"created_at":"2023-09-19T00:47:59Z","previous_plan_code":null,"next_plan_code":"another_plan","downgrade_plan_date":"2023-10-01","subscription_date":"2023-09-19"}],"meta":{"current_page":1,"next_page":null,"prev_page":null,"total_pages":1,"total_count":1}}'
159
- recorded_at: Wed, 20 Sep 2023 03:27:08 GMT
158
+ string: '{"subscription":{"lago_id":"d258f521-d901-4895-9b92-9a0eaa6a1d6e","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-12T01:54:55Z","started_at":"2023-12-12T01:54:55Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-12T01:54:55Z","previous_plan_code":null,"next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-12","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":[]}}}'
159
+ recorded_at: Tue, 12 Dec 2023 01:54:55 GMT
160
160
  - request:
161
161
  method: post
162
162
  uri: http://localhost:3000/api/v1/subscriptions
163
163
  body:
164
164
  encoding: UTF-8
165
- string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"another_plan","external_id":"gid://dummy/Pay::Subscription/913727099"}}'
165
+ string: '{"subscription":{"external_customer_id":"gid://dummy/Pay::Customer/772847388","plan_code":"another_plan","external_id":"gid://dummy/Pay::Subscription/2"}}'
166
166
  headers:
167
167
  Authorization:
168
- - Bearer 155ed033-8716-4587-9ac6-fed8ddae3317
168
+ - Bearer <LAGO_API_KEY>
169
169
  Content-Type:
170
170
  - application/json
171
171
  User-Agent:
172
- - Lago Ruby v0.44.0-beta
172
+ - Lago Ruby v0.52.2-beta
173
173
  Accept-Encoding:
174
174
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
175
175
  Accept:
@@ -194,19 +194,73 @@ http_interactions:
194
194
  Content-Type:
195
195
  - application/json; charset=utf-8
196
196
  Etag:
197
- - W/"e02fd87d05bded0f1ac0e8d1345a6991"
197
+ - W/"f406e40e5f461a912e86f2be1311caaf"
198
198
  Cache-Control:
199
199
  - max-age=0, private, must-revalidate
200
200
  X-Request-Id:
201
- - fd754b57-e750-4d01-92b8-b77f4489304d
201
+ - 50a7effb-1549-4c01-ba10-cb331b7dc533
202
202
  X-Runtime:
203
- - 0.039601
203
+ - '0.051581'
204
204
  Vary:
205
205
  - Origin
206
206
  Transfer-Encoding:
207
207
  - chunked
208
208
  body:
209
209
  encoding: UTF-8
210
- string: '{"subscription":{"lago_id":"4a849692-2b6d-48cc-a3f4-02c03a004b3b","external_id":"gid://dummy/Pay::Subscription/913727099","lago_customer_id":"c8bb805a-590c-444f-ae14-66589764f273","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"default","plan_code":"default","status":"active","billing_time":"calendar","subscription_at":"2023-09-19T00:47:59Z","started_at":"2023-09-19T00:47:59Z","terminated_at":null,"canceled_at":null,"created_at":"2023-09-19T00:47:59Z","previous_plan_code":null,"next_plan_code":"another_plan","downgrade_plan_date":"2023-10-01","subscription_date":"2023-09-19"}}'
211
- recorded_at: Wed, 20 Sep 2023 03:27:08 GMT
210
+ string: '{"subscription":{"lago_id":"e242f14a-e9f8-4b5c-957e-528fa69eba2e","external_id":"gid://dummy/Pay::Subscription/2","lago_customer_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"","plan_code":"another_plan","status":"active","billing_time":"calendar","subscription_at":"2023-12-12T01:54:55Z","started_at":"2023-12-12T01:54:55Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-12T01:54:55Z","previous_plan_code":"default","next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-12","plan":{"lago_id":"962313a3-eb7c-4ba7-ac11-777a39ab47ca","name":"Another
211
+ Plan","invoice_display_name":null,"created_at":"2023-12-11T05:34:56Z","code":"another_plan","interval":"monthly","description":"","amount_cents":200,"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":[]}}}'
212
+ recorded_at: Tue, 12 Dec 2023 01:54:55 GMT
213
+ - request:
214
+ method: get
215
+ uri: http://localhost:3000/api/v1/subscriptions/gid:%2F%2Fdummy%2FPay::Subscription%2F2
216
+ body:
217
+ encoding: UTF-8
218
+ string: ''
219
+ headers:
220
+ Authorization:
221
+ - Bearer <LAGO_API_KEY>
222
+ Content-Type:
223
+ - application/json
224
+ User-Agent:
225
+ - Lago Ruby v0.52.2-beta
226
+ Accept-Encoding:
227
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
228
+ Accept:
229
+ - "*/*"
230
+ response:
231
+ status:
232
+ code: 200
233
+ message: OK
234
+ headers:
235
+ X-Frame-Options:
236
+ - SAMEORIGIN
237
+ X-Xss-Protection:
238
+ - '0'
239
+ X-Content-Type-Options:
240
+ - nosniff
241
+ X-Download-Options:
242
+ - noopen
243
+ X-Permitted-Cross-Domain-Policies:
244
+ - none
245
+ Referrer-Policy:
246
+ - strict-origin-when-cross-origin
247
+ Content-Type:
248
+ - application/json; charset=utf-8
249
+ Etag:
250
+ - W/"f406e40e5f461a912e86f2be1311caaf"
251
+ Cache-Control:
252
+ - max-age=0, private, must-revalidate
253
+ X-Request-Id:
254
+ - 79c627be-2b36-4a6b-991d-d3ed74f01e39
255
+ X-Runtime:
256
+ - '0.020220'
257
+ Vary:
258
+ - Origin
259
+ Transfer-Encoding:
260
+ - chunked
261
+ body:
262
+ encoding: UTF-8
263
+ string: '{"subscription":{"lago_id":"e242f14a-e9f8-4b5c-957e-528fa69eba2e","external_id":"gid://dummy/Pay::Subscription/2","lago_customer_id":"f8186952-5b73-480b-96ac-af4c7c953344","external_customer_id":"gid://dummy/Pay::Customer/772847388","name":"","plan_code":"another_plan","status":"active","billing_time":"calendar","subscription_at":"2023-12-12T01:54:55Z","started_at":"2023-12-12T01:54:55Z","ending_at":null,"terminated_at":null,"canceled_at":null,"created_at":"2023-12-12T01:54:55Z","previous_plan_code":"default","next_plan_code":null,"downgrade_plan_date":null,"subscription_date":"2023-12-12","plan":{"lago_id":"962313a3-eb7c-4ba7-ac11-777a39ab47ca","name":"Another
264
+ Plan","invoice_display_name":null,"created_at":"2023-12-11T05:34:56Z","code":"another_plan","interval":"monthly","description":"","amount_cents":200,"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":[]}}}'
265
+ recorded_at: Sun, 10 Dec 2023 00:00:00 GMT
212
266
  recorded_with: VCR 6.2.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pay-lago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moxvallix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-23 00:00:00.000000000 Z
11
+ date: 2023-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pay
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.50.0.pre.beta
33
+ version: 0.53.0.pre.beta
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.50.0.pre.beta
40
+ version: 0.53.0.pre.beta
41
41
  description:
42
42
  email:
43
43
  - dev@moxvallix.com
@@ -59,6 +59,7 @@ files:
59
59
  - app/controllers/pay/webhooks/lago_controller.rb
60
60
  - app/models/concerns/pay/lago/pay_customer_extensions.rb
61
61
  - app/models/concerns/pay/lago/pay_extensions.rb
62
+ - app/models/concerns/pay/lago/pay_payment_method_extensions.rb
62
63
  - bin/console
63
64
  - bin/rails
64
65
  - bin/setup
@@ -66,7 +67,8 @@ files:
66
67
  - docs/1_customers.md
67
68
  - docs/2_charges.md
68
69
  - docs/3_subscriptions.md
69
- - docs/4_webhooks.md
70
+ - docs/4_payment_methods.md
71
+ - docs/5_webhooks.md
70
72
  - lib/pay/lago.rb
71
73
  - lib/pay/lago/attributes.rb
72
74
  - lib/pay/lago/billable.rb
@@ -146,6 +148,7 @@ files:
146
148
  - test/dummy/config/secrets.yml
147
149
  - test/dummy/config/spring.rb
148
150
  - test/dummy/config/storage.yml
151
+ - test/dummy/db/migrate/1_create_pay_tables.rb
149
152
  - test/dummy/db/migrate/20170205000000_create_users.rb
150
153
  - test/dummy/db/schema.rb
151
154
  - test/dummy/lib/assets/.keep
@@ -163,10 +166,12 @@ files:
163
166
  - test/fixtures/users.yml
164
167
  - test/pay/lago/billable_test.rb
165
168
  - test/pay/lago/charge_test.rb
169
+ - test/pay/lago/payment_method_test.rb
166
170
  - test/pay/lago/subscription_test.rb
167
171
  - test/support/fixtures/lago/invoice.one_off_created.json
168
172
  - test/support/vcr.rb
169
173
  - test/test_helper.rb
174
+ - test/vcr_cassettes/test_PaymentMethod_can_be_made_default__updating_Lago.yml
170
175
  - test/vcr_cassettes/test_add_payment_method_to_lago.yml
171
176
  - test/vcr_cassettes/test_can_get_lago_processor_customer.yml
172
177
  - test/vcr_cassettes/test_can_make_a_lago_processor_charge.yml
File without changes