gocardless_pro 2.27.0 → 2.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +20 -1
- data/lib/gocardless_pro/api_service.rb +4 -0
- data/lib/gocardless_pro/client.rb +11 -1
- data/lib/gocardless_pro/error/authentication_error.rb +4 -0
- data/lib/gocardless_pro/error/permission_error.rb +4 -0
- data/lib/gocardless_pro/error/rate_limit_error.rb +4 -0
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +12 -1
- data/lib/gocardless_pro/resources/bank_authorisation.rb +3 -9
- data/lib/gocardless_pro/resources/billing_request.rb +31 -7
- data/lib/gocardless_pro/resources/billing_request_flow.rb +14 -0
- data/lib/gocardless_pro/resources/billing_request_template.rb +68 -0
- data/lib/gocardless_pro/resources/block.rb +76 -0
- data/lib/gocardless_pro/resources/event.rb +20 -0
- data/lib/gocardless_pro/resources/institution.rb +7 -1
- data/lib/gocardless_pro/resources/payer_authorisation.rb +9 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +6 -0
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +0 -2
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +23 -0
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +131 -0
- data/lib/gocardless_pro/services/billing_requests_service.rb +89 -24
- data/lib/gocardless_pro/services/blocks_service.rb +223 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +1 -5
- data/lib/gocardless_pro/services/creditors_service.rb +1 -3
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +1 -1
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +1 -5
- data/lib/gocardless_pro/services/customers_service.rb +1 -3
- data/lib/gocardless_pro/services/events_service.rb +1 -1
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +1 -7
- data/lib/gocardless_pro/services/institutions_service.rb +2 -2
- data/lib/gocardless_pro/services/mandate_import_entries_service.rb +1 -1
- data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -6
- data/lib/gocardless_pro/services/mandates_service.rb +1 -7
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +0 -6
- data/lib/gocardless_pro/services/payments_service.rb +1 -7
- data/lib/gocardless_pro/services/payout_items_service.rb +1 -1
- data/lib/gocardless_pro/services/payouts_service.rb +1 -1
- data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -4
- data/lib/gocardless_pro/services/refunds_service.rb +1 -3
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +28 -6
- data/lib/gocardless_pro/services/subscriptions_service.rb +3 -11
- data/lib/gocardless_pro/services/tax_rates_service.rb +1 -1
- data/lib/gocardless_pro/services/webhooks_service.rb +1 -3
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro.rb +9 -0
- data/spec/api_service_spec.rb +12 -1
- data/spec/middlewares/raise_gocardless_errors_spec.rb +30 -0
- data/spec/resources/bank_authorisation_spec.rb +7 -7
- data/spec/resources/billing_request_flow_spec.rb +104 -0
- data/spec/resources/billing_request_spec.rb +183 -29
- data/spec/resources/billing_request_template_spec.rb +502 -0
- data/spec/resources/block_spec.rb +577 -0
- data/spec/resources/creditor_bank_account_spec.rb +2 -0
- data/spec/resources/customer_bank_account_spec.rb +2 -0
- data/spec/resources/customer_notification_spec.rb +2 -0
- data/spec/resources/customer_spec.rb +2 -0
- data/spec/resources/instalment_schedule_spec.rb +2 -0
- data/spec/resources/institution_spec.rb +5 -0
- data/spec/resources/mandate_import_spec.rb +4 -0
- data/spec/resources/mandate_spec.rb +4 -0
- data/spec/resources/payer_authorisation_spec.rb +4 -0
- data/spec/resources/payment_spec.rb +4 -0
- data/spec/resources/redirect_flow_spec.rb +11 -0
- data/spec/resources/scenario_simulator_spec.rb +2 -0
- data/spec/resources/subscription_spec.rb +6 -0
- data/spec/resources/webhook_spec.rb +2 -0
- data/spec/services/bank_authorisations_service_spec.rb +7 -20
- data/spec/services/billing_request_flows_service_spec.rb +115 -0
- data/spec/services/billing_request_templates_service_spec.rb +789 -0
- data/spec/services/billing_requests_service_spec.rb +210 -47
- data/spec/services/blocks_service_spec.rb +840 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +2 -13
- data/spec/services/creditors_service_spec.rb +0 -13
- data/spec/services/customer_bank_accounts_service_spec.rb +2 -13
- data/spec/services/customer_notifications_service_spec.rb +2 -0
- data/spec/services/customers_service_spec.rb +2 -13
- data/spec/services/instalment_schedules_service_spec.rb +2 -26
- data/spec/services/institutions_service_spec.rb +9 -0
- data/spec/services/mandate_imports_service_spec.rb +4 -13
- data/spec/services/mandates_service_spec.rb +4 -13
- data/spec/services/payer_authorisations_service_spec.rb +4 -13
- data/spec/services/payments_service_spec.rb +4 -13
- data/spec/services/redirect_flows_service_spec.rb +11 -13
- data/spec/services/refunds_service_spec.rb +0 -13
- data/spec/services/scenario_simulators_service_spec.rb +2 -0
- data/spec/services/subscriptions_service_spec.rb +6 -13
- data/spec/services/webhooks_service_spec.rb +2 -0
- metadata +18 -3
@@ -18,8 +18,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
18
18
|
'billing_requests' => [{
|
19
19
|
|
20
20
|
'actions' => 'actions-input',
|
21
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
22
21
|
'created_at' => 'created_at-input',
|
22
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
23
23
|
'id' => 'id-input',
|
24
24
|
'links' => 'links-input',
|
25
25
|
'mandate_request' => 'mandate_request-input',
|
@@ -49,10 +49,10 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
49
49
|
|
50
50
|
expect(get_list_response.records.first.actions).to eq('actions-input')
|
51
51
|
|
52
|
-
expect(get_list_response.records.first.auto_fulfil).to eq('auto_fulfil-input')
|
53
|
-
|
54
52
|
expect(get_list_response.records.first.created_at).to eq('created_at-input')
|
55
53
|
|
54
|
+
expect(get_list_response.records.first.fallback_enabled).to eq('fallback_enabled-input')
|
55
|
+
|
56
56
|
expect(get_list_response.records.first.id).to eq('id-input')
|
57
57
|
|
58
58
|
expect(get_list_response.records.first.mandate_request).to eq('mandate_request-input')
|
@@ -105,8 +105,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
105
105
|
'billing_requests' => [{
|
106
106
|
|
107
107
|
'actions' => 'actions-input',
|
108
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
109
108
|
'created_at' => 'created_at-input',
|
109
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
110
110
|
'id' => 'id-input',
|
111
111
|
'links' => 'links-input',
|
112
112
|
'mandate_request' => 'mandate_request-input',
|
@@ -130,8 +130,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
130
130
|
'billing_requests' => [{
|
131
131
|
|
132
132
|
'actions' => 'actions-input',
|
133
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
134
133
|
'created_at' => 'created_at-input',
|
134
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
135
135
|
'id' => 'id-input',
|
136
136
|
'links' => 'links-input',
|
137
137
|
'mandate_request' => 'mandate_request-input',
|
@@ -164,8 +164,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
164
164
|
'billing_requests' => [{
|
165
165
|
|
166
166
|
'actions' => 'actions-input',
|
167
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
168
167
|
'created_at' => 'created_at-input',
|
168
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
169
169
|
'id' => 'id-input',
|
170
170
|
'links' => 'links-input',
|
171
171
|
'mandate_request' => 'mandate_request-input',
|
@@ -189,8 +189,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
189
189
|
'billing_requests' => [{
|
190
190
|
|
191
191
|
'actions' => 'actions-input',
|
192
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
193
192
|
'created_at' => 'created_at-input',
|
193
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
194
194
|
'id' => 'id-input',
|
195
195
|
'links' => 'links-input',
|
196
196
|
'mandate_request' => 'mandate_request-input',
|
@@ -219,8 +219,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
219
219
|
'billing_requests' => [{
|
220
220
|
|
221
221
|
'actions' => 'actions-input',
|
222
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
223
222
|
'created_at' => 'created_at-input',
|
223
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
224
224
|
'id' => 'id-input',
|
225
225
|
'links' => 'links-input',
|
226
226
|
'mandate_request' => 'mandate_request-input',
|
@@ -247,8 +247,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
247
247
|
'billing_requests' => [{
|
248
248
|
|
249
249
|
'actions' => 'actions-input',
|
250
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
251
250
|
'created_at' => 'created_at-input',
|
251
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
252
252
|
'id' => 'id-input',
|
253
253
|
'links' => 'links-input',
|
254
254
|
'mandate_request' => 'mandate_request-input',
|
@@ -280,8 +280,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
280
280
|
{
|
281
281
|
|
282
282
|
'actions' => 'actions-input',
|
283
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
284
283
|
'created_at' => 'created_at-input',
|
284
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
285
285
|
'id' => 'id-input',
|
286
286
|
'links' => 'links-input',
|
287
287
|
'mandate_request' => 'mandate_request-input',
|
@@ -299,8 +299,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
299
299
|
'billing_requests' => {
|
300
300
|
|
301
301
|
'actions' => 'actions-input',
|
302
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
303
302
|
'created_at' => 'created_at-input',
|
303
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
304
304
|
'id' => 'id-input',
|
305
305
|
'links' => 'links-input',
|
306
306
|
'mandate_request' => 'mandate_request-input',
|
@@ -318,8 +318,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
318
318
|
{
|
319
319
|
|
320
320
|
'actions' => 'actions-input',
|
321
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
322
321
|
'created_at' => 'created_at-input',
|
322
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
323
323
|
'id' => 'id-input',
|
324
324
|
'links' => 'links-input',
|
325
325
|
'mandate_request' => 'mandate_request-input',
|
@@ -393,8 +393,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
393
393
|
{
|
394
394
|
|
395
395
|
'actions' => 'actions-input',
|
396
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
397
396
|
'created_at' => 'created_at-input',
|
397
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
398
398
|
'id' => 'id-input',
|
399
399
|
'links' => 'links-input',
|
400
400
|
'mandate_request' => 'mandate_request-input',
|
@@ -435,8 +435,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
435
435
|
'billing_requests' => {
|
436
436
|
|
437
437
|
'actions' => 'actions-input',
|
438
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
439
438
|
'created_at' => 'created_at-input',
|
439
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
440
440
|
'id' => 'id-input',
|
441
441
|
'links' => 'links-input',
|
442
442
|
'mandate_request' => 'mandate_request-input',
|
@@ -471,19 +471,6 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
471
471
|
to raise_error(GoCardlessPro::IdempotencyConflict)
|
472
472
|
end
|
473
473
|
end
|
474
|
-
|
475
|
-
context 'with on_idempotency_conflict: :unknown' do
|
476
|
-
let(:client) do
|
477
|
-
GoCardlessPro::Client.new(
|
478
|
-
access_token: 'SECRET_TOKEN',
|
479
|
-
on_idempotency_conflict: :unknown
|
480
|
-
)
|
481
|
-
end
|
482
|
-
|
483
|
-
it 'raises an ArgumentError' do
|
484
|
-
expect { post_create_response }.to raise_error(ArgumentError)
|
485
|
-
end
|
486
|
-
end
|
487
474
|
end
|
488
475
|
end
|
489
476
|
|
@@ -502,8 +489,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
502
489
|
'billing_requests' => {
|
503
490
|
|
504
491
|
'actions' => 'actions-input',
|
505
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
506
492
|
'created_at' => 'created_at-input',
|
493
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
507
494
|
'id' => 'id-input',
|
508
495
|
'links' => 'links-input',
|
509
496
|
'mandate_request' => 'mandate_request-input',
|
@@ -537,8 +524,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
537
524
|
'billing_requests' => {
|
538
525
|
|
539
526
|
'actions' => 'actions-input',
|
540
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
541
527
|
'created_at' => 'created_at-input',
|
528
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
542
529
|
'id' => 'id-input',
|
543
530
|
'links' => 'links-input',
|
544
531
|
'mandate_request' => 'mandate_request-input',
|
@@ -644,12 +631,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
644
631
|
# /billing_requests/%v/actions/collect_customer_details
|
645
632
|
stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
|
646
633
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
634
|
+
|
647
635
|
body: {
|
648
636
|
'billing_requests' => {
|
649
637
|
|
650
638
|
'actions' => 'actions-input',
|
651
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
652
639
|
'created_at' => 'created_at-input',
|
640
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
653
641
|
'id' => 'id-input',
|
654
642
|
'links' => 'links-input',
|
655
643
|
'mandate_request' => 'mandate_request-input',
|
@@ -659,6 +647,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
659
647
|
'status' => 'status-input',
|
660
648
|
},
|
661
649
|
}.to_json,
|
650
|
+
|
662
651
|
headers: response_headers
|
663
652
|
)
|
664
653
|
end
|
@@ -699,8 +688,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
699
688
|
'billing_requests' => {
|
700
689
|
|
701
690
|
'actions' => 'actions-input',
|
702
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
703
691
|
'created_at' => 'created_at-input',
|
692
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
704
693
|
'id' => 'id-input',
|
705
694
|
'links' => 'links-input',
|
706
695
|
'mandate_request' => 'mandate_request-input',
|
@@ -716,21 +705,22 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
716
705
|
end
|
717
706
|
end
|
718
707
|
|
719
|
-
describe '#
|
720
|
-
subject(:post_response) { client.billing_requests.
|
708
|
+
describe '#collect_bank_account' do
|
709
|
+
subject(:post_response) { client.billing_requests.collect_bank_account(resource_id) }
|
721
710
|
|
722
711
|
let(:resource_id) { 'ABC123' }
|
723
712
|
|
724
713
|
let!(:stub) do
|
725
|
-
# /billing_requests/%v/actions/
|
726
|
-
stub_url = '/billing_requests/:identity/actions/
|
714
|
+
# /billing_requests/%v/actions/collect_bank_account
|
715
|
+
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
|
727
716
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
717
|
+
|
728
718
|
body: {
|
729
719
|
'billing_requests' => {
|
730
720
|
|
731
721
|
'actions' => 'actions-input',
|
732
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
733
722
|
'created_at' => 'created_at-input',
|
723
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
734
724
|
'id' => 'id-input',
|
735
725
|
'links' => 'links-input',
|
736
726
|
'mandate_request' => 'mandate_request-input',
|
@@ -740,6 +730,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
740
730
|
'status' => 'status-input',
|
741
731
|
},
|
742
732
|
}.to_json,
|
733
|
+
|
743
734
|
headers: response_headers
|
744
735
|
)
|
745
736
|
end
|
@@ -752,7 +743,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
752
743
|
|
753
744
|
describe 'retry behaviour' do
|
754
745
|
it "doesn't retry errors" do
|
755
|
-
stub_url = '/billing_requests/:identity/actions/
|
746
|
+
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
|
756
747
|
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
757
748
|
to_timeout
|
758
749
|
|
@@ -764,13 +755,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
764
755
|
context 'when the request needs a body and custom header' do
|
765
756
|
let(:body) { { foo: 'bar' } }
|
766
757
|
let(:headers) { { 'Foo' => 'Bar' } }
|
767
|
-
subject(:post_response) { client.billing_requests.
|
758
|
+
subject(:post_response) { client.billing_requests.collect_bank_account(resource_id, body, headers) }
|
768
759
|
|
769
760
|
let(:resource_id) { 'ABC123' }
|
770
761
|
|
771
762
|
let!(:stub) do
|
772
|
-
# /billing_requests/%v/actions/
|
773
|
-
stub_url = '/billing_requests/:identity/actions/
|
763
|
+
# /billing_requests/%v/actions/collect_bank_account
|
764
|
+
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
|
774
765
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
775
766
|
with(
|
776
767
|
body: { foo: 'bar' },
|
@@ -780,8 +771,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
780
771
|
'billing_requests' => {
|
781
772
|
|
782
773
|
'actions' => 'actions-input',
|
783
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
784
774
|
'created_at' => 'created_at-input',
|
775
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
785
776
|
'id' => 'id-input',
|
786
777
|
'links' => 'links-input',
|
787
778
|
'mandate_request' => 'mandate_request-input',
|
@@ -806,12 +797,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
806
797
|
# /billing_requests/%v/actions/fulfil
|
807
798
|
stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
|
808
799
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
800
|
+
|
809
801
|
body: {
|
810
802
|
'billing_requests' => {
|
811
803
|
|
812
804
|
'actions' => 'actions-input',
|
813
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
814
805
|
'created_at' => 'created_at-input',
|
806
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
815
807
|
'id' => 'id-input',
|
816
808
|
'links' => 'links-input',
|
817
809
|
'mandate_request' => 'mandate_request-input',
|
@@ -821,6 +813,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
821
813
|
'status' => 'status-input',
|
822
814
|
},
|
823
815
|
}.to_json,
|
816
|
+
|
824
817
|
headers: response_headers
|
825
818
|
)
|
826
819
|
end
|
@@ -861,8 +854,91 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
861
854
|
'billing_requests' => {
|
862
855
|
|
863
856
|
'actions' => 'actions-input',
|
864
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
865
857
|
'created_at' => 'created_at-input',
|
858
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
859
|
+
'id' => 'id-input',
|
860
|
+
'links' => 'links-input',
|
861
|
+
'mandate_request' => 'mandate_request-input',
|
862
|
+
'metadata' => 'metadata-input',
|
863
|
+
'payment_request' => 'payment_request-input',
|
864
|
+
'resources' => 'resources-input',
|
865
|
+
'status' => 'status-input',
|
866
|
+
},
|
867
|
+
}.to_json,
|
868
|
+
headers: response_headers
|
869
|
+
)
|
870
|
+
end
|
871
|
+
end
|
872
|
+
end
|
873
|
+
|
874
|
+
describe '#confirm_payer_details' do
|
875
|
+
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id) }
|
876
|
+
|
877
|
+
let(:resource_id) { 'ABC123' }
|
878
|
+
|
879
|
+
let!(:stub) do
|
880
|
+
# /billing_requests/%v/actions/confirm_payer_details
|
881
|
+
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
|
882
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
883
|
+
|
884
|
+
body: {
|
885
|
+
'billing_requests' => {
|
886
|
+
|
887
|
+
'actions' => 'actions-input',
|
888
|
+
'created_at' => 'created_at-input',
|
889
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
890
|
+
'id' => 'id-input',
|
891
|
+
'links' => 'links-input',
|
892
|
+
'mandate_request' => 'mandate_request-input',
|
893
|
+
'metadata' => 'metadata-input',
|
894
|
+
'payment_request' => 'payment_request-input',
|
895
|
+
'resources' => 'resources-input',
|
896
|
+
'status' => 'status-input',
|
897
|
+
},
|
898
|
+
}.to_json,
|
899
|
+
|
900
|
+
headers: response_headers
|
901
|
+
)
|
902
|
+
end
|
903
|
+
|
904
|
+
it 'wraps the response and calls the right endpoint' do
|
905
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
|
906
|
+
|
907
|
+
expect(stub).to have_been_requested
|
908
|
+
end
|
909
|
+
|
910
|
+
describe 'retry behaviour' do
|
911
|
+
it "doesn't retry errors" do
|
912
|
+
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
|
913
|
+
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
914
|
+
to_timeout
|
915
|
+
|
916
|
+
expect { post_response }.to raise_error(Faraday::ConnectionFailed)
|
917
|
+
expect(stub).to have_been_requested
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
context 'when the request needs a body and custom header' do
|
922
|
+
let(:body) { { foo: 'bar' } }
|
923
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
924
|
+
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id, body, headers) }
|
925
|
+
|
926
|
+
let(:resource_id) { 'ABC123' }
|
927
|
+
|
928
|
+
let!(:stub) do
|
929
|
+
# /billing_requests/%v/actions/confirm_payer_details
|
930
|
+
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
|
931
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
932
|
+
with(
|
933
|
+
body: { foo: 'bar' },
|
934
|
+
headers: { 'Foo' => 'Bar' }
|
935
|
+
).to_return(
|
936
|
+
body: {
|
937
|
+
'billing_requests' => {
|
938
|
+
|
939
|
+
'actions' => 'actions-input',
|
940
|
+
'created_at' => 'created_at-input',
|
941
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
866
942
|
'id' => 'id-input',
|
867
943
|
'links' => 'links-input',
|
868
944
|
'mandate_request' => 'mandate_request-input',
|
@@ -887,12 +963,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
887
963
|
# /billing_requests/%v/actions/cancel
|
888
964
|
stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
|
889
965
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
966
|
+
|
890
967
|
body: {
|
891
968
|
'billing_requests' => {
|
892
969
|
|
893
970
|
'actions' => 'actions-input',
|
894
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
895
971
|
'created_at' => 'created_at-input',
|
972
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
896
973
|
'id' => 'id-input',
|
897
974
|
'links' => 'links-input',
|
898
975
|
'mandate_request' => 'mandate_request-input',
|
@@ -902,6 +979,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
902
979
|
'status' => 'status-input',
|
903
980
|
},
|
904
981
|
}.to_json,
|
982
|
+
|
905
983
|
headers: response_headers
|
906
984
|
)
|
907
985
|
end
|
@@ -942,8 +1020,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
942
1020
|
'billing_requests' => {
|
943
1021
|
|
944
1022
|
'actions' => 'actions-input',
|
945
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
946
1023
|
'created_at' => 'created_at-input',
|
1024
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
947
1025
|
'id' => 'id-input',
|
948
1026
|
'links' => 'links-input',
|
949
1027
|
'mandate_request' => 'mandate_request-input',
|
@@ -968,12 +1046,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
968
1046
|
# /billing_requests/%v/actions/notify
|
969
1047
|
stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
|
970
1048
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
1049
|
+
|
971
1050
|
body: {
|
972
1051
|
'billing_requests' => {
|
973
1052
|
|
974
1053
|
'actions' => 'actions-input',
|
975
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
976
1054
|
'created_at' => 'created_at-input',
|
1055
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
977
1056
|
'id' => 'id-input',
|
978
1057
|
'links' => 'links-input',
|
979
1058
|
'mandate_request' => 'mandate_request-input',
|
@@ -983,6 +1062,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
983
1062
|
'status' => 'status-input',
|
984
1063
|
},
|
985
1064
|
}.to_json,
|
1065
|
+
|
986
1066
|
headers: response_headers
|
987
1067
|
)
|
988
1068
|
end
|
@@ -1023,8 +1103,91 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
1023
1103
|
'billing_requests' => {
|
1024
1104
|
|
1025
1105
|
'actions' => 'actions-input',
|
1026
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
1027
1106
|
'created_at' => 'created_at-input',
|
1107
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
1108
|
+
'id' => 'id-input',
|
1109
|
+
'links' => 'links-input',
|
1110
|
+
'mandate_request' => 'mandate_request-input',
|
1111
|
+
'metadata' => 'metadata-input',
|
1112
|
+
'payment_request' => 'payment_request-input',
|
1113
|
+
'resources' => 'resources-input',
|
1114
|
+
'status' => 'status-input',
|
1115
|
+
},
|
1116
|
+
}.to_json,
|
1117
|
+
headers: response_headers
|
1118
|
+
)
|
1119
|
+
end
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
describe '#fallback' do
|
1124
|
+
subject(:post_response) { client.billing_requests.fallback(resource_id) }
|
1125
|
+
|
1126
|
+
let(:resource_id) { 'ABC123' }
|
1127
|
+
|
1128
|
+
let!(:stub) do
|
1129
|
+
# /billing_requests/%v/actions/fallback
|
1130
|
+
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
|
1131
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
1132
|
+
|
1133
|
+
body: {
|
1134
|
+
'billing_requests' => {
|
1135
|
+
|
1136
|
+
'actions' => 'actions-input',
|
1137
|
+
'created_at' => 'created_at-input',
|
1138
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
1139
|
+
'id' => 'id-input',
|
1140
|
+
'links' => 'links-input',
|
1141
|
+
'mandate_request' => 'mandate_request-input',
|
1142
|
+
'metadata' => 'metadata-input',
|
1143
|
+
'payment_request' => 'payment_request-input',
|
1144
|
+
'resources' => 'resources-input',
|
1145
|
+
'status' => 'status-input',
|
1146
|
+
},
|
1147
|
+
}.to_json,
|
1148
|
+
|
1149
|
+
headers: response_headers
|
1150
|
+
)
|
1151
|
+
end
|
1152
|
+
|
1153
|
+
it 'wraps the response and calls the right endpoint' do
|
1154
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
|
1155
|
+
|
1156
|
+
expect(stub).to have_been_requested
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
describe 'retry behaviour' do
|
1160
|
+
it "doesn't retry errors" do
|
1161
|
+
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
|
1162
|
+
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
1163
|
+
to_timeout
|
1164
|
+
|
1165
|
+
expect { post_response }.to raise_error(Faraday::ConnectionFailed)
|
1166
|
+
expect(stub).to have_been_requested
|
1167
|
+
end
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
context 'when the request needs a body and custom header' do
|
1171
|
+
let(:body) { { foo: 'bar' } }
|
1172
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
1173
|
+
subject(:post_response) { client.billing_requests.fallback(resource_id, body, headers) }
|
1174
|
+
|
1175
|
+
let(:resource_id) { 'ABC123' }
|
1176
|
+
|
1177
|
+
let!(:stub) do
|
1178
|
+
# /billing_requests/%v/actions/fallback
|
1179
|
+
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
|
1180
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
1181
|
+
with(
|
1182
|
+
body: { foo: 'bar' },
|
1183
|
+
headers: { 'Foo' => 'Bar' }
|
1184
|
+
).to_return(
|
1185
|
+
body: {
|
1186
|
+
'billing_requests' => {
|
1187
|
+
|
1188
|
+
'actions' => 'actions-input',
|
1189
|
+
'created_at' => 'created_at-input',
|
1190
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
1028
1191
|
'id' => 'id-input',
|
1029
1192
|
'links' => 'links-input',
|
1030
1193
|
'mandate_request' => 'mandate_request-input',
|