-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepay-api.yaml
More file actions
1969 lines (1924 loc) · 79.9 KB
/
Copy pathrepay-api.yaml
File metadata and controls
1969 lines (1924 loc) · 79.9 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: Two Repay API
description: |
## Sequence Diagram
[**Repayment Terms Guide**](/docs/guides/setting-repayment-terms/)
## Overview and usage:
This API is designed for the purpose of creating and managing repayment accounts and repayment plans.
A repayment account stores the billing details of buyers, which are used to issue invoices and follow up for incoming payments.
A business can have one or multiple repayment accounts, each of which should have a corresponding account record in the merchant's system.
A repayment plan represents the receivable purchased from merchants and is expected to be paid by buyers over time. It is a collection of instalments, and the instalments of different repayment plans can be invoiced together.
The Repayment Plans fulfilled via this API will be invoiced and distributed to the Buyers the following 3-36 months.
Instalments created by the same merchant for the same repayment account will be invoiced together, typically on the 1st day of each calendar month, to allow Buyers to pay them together with a single payment.
You will receive a net payout from us upon fulfilment of the repayment plan, at the end of your negotiated payout cycle.
### The Repay API provides the following features:
- Creation and update of repayment accounts, including their contact details
- Creation and fulfilment of new repayment plans
- Cancellation of existing repayment plans to prevent invoicing of uninvoiced instalments
- Credit check of buyers to understand the terms under which a specific repayment plan amount is supported
- Preview of repayment plans with a breakdown of instalments
- Polling of the funding and fulfilment status of repayment plans
- Crediting of specific repayment plans
### Step 1: Identify the Business for Which You're Creating the Account
- To help your buyers select their company's legal name, address, and national ID. You can use the Search API endpoint to search for the company's name, which is documented here: [**Search Company Name**](/docs/api/company/company-search/)
- Additionally, you can use the company address endpoint to access the address information, which is available here: [**Get Company**](/docs/api/company/get-company-company-canonical-or-lookup-id-get/)
### Step 2: Creation of repayment account
- The repayment account is created by the merchant using details inputted by their buyer using the [**create repayment account**](/docs/api/repay/create-repayment-account-account-post/) ` POST /account` endpoint
- You can create multiple repayment accounts for the same `buyer_company` if you would like each to receive seperate invoices.
### Step 3: Credit check the planned repayment plan amount
- Once you have the total order amount being placed by the buyer. Call the [**credit check**](/docs/api/repay/credit-check-credit-check-post/) ` POST /credit-check` endpoint
- The API will then respond with under what conditions Two can provide an approved funding decision for this buyer and the given amount
- The API response will provide you with the maximum and minimum terms, and a maximum monthly amount that can be offered to the buyer
### Step 4: Preview the repayment plan to see the instalment breakdown
**This step is optional**: You might want to show a breakdown of one or more tentative repayment plans to your buyer before they commit to one of them.
- Preview the repayment plans to show to the buyer through the [**create preview**](/docs/api/repay/create-repayment-plan-preview-plan-preview-post/) ` POST /preview` endpoint
- The API response will provide a list of instalments, including issue dates and amounts and tax subtotals, to be presented to your buyer
- This endpoint can be polled multiple times with different options but recommended to only call within the limitations of the credit risk response.
### Step 5: Create the repayment plan and commit the buyer to pay back in instalments.
- A repayment plan can then be created by defining the following required terms through the [**create repayment plan**](/docs/api/repay/create-repayment-plan-plan-post/) `POST /plan` endpoint :
- The number of payment periods associated with this set of terms. (Number Of Periods [ 1 ... 36 ])
- The time slice over which payments are to be made as part of a repayment plan. (currently we only support Monthly cadence)
### Step 6: Poll the repayment status
- You are expected to poll the [**repayment status**](/docs/api/repay/get-repayment-plan-status-plan-repayment-plan-id-status-get/) `GET /status` endpoint until the API responds with an "Accepted" or "Rejected" funding decision
- Once funding has been "Accepted" proceed to **fulfilment**
### Step 7: Fulfil the repayment plan
- Using the `PUT /fulfilment` endpoint you will [**finalise the repayment plan**](/docs/api/repay/fulfill-repayment-plan-plan-repayment-plan-id-fulfilment-put/) and initiate the payout process
- The next business day your payout will incorporate this repayment plan minus the agreed fees.
- If you have negotiated a payout cadence that is not DAILY, you will receive the payout for this repayment plan minus the fees at the end of your current payout cycle.
## Environments
### Testing
[https://api.sandbox.two.inc/repay/v1](https://api.sandbox.two.inc/repay/v1/health)
Note: Read about our [sandbox environment specific behaviour](/docs/guides/sandbox-behaviour-page/).
### Production
[https://api.two.inc/repay/v1](https://api.two.inc/repay/v1/health)
version: 1.0.0
servers:
- url: https://api.sandbox.two.inc/repay/v1
description: Testing
- url: https://api.two.inc/repay/v1
description: Production
paths:
/testing/send-invoices:
post:
tags:
- Sandbox testing
summary: Trigger Future Invoice
description: |-
**Only available in sandbox**
This endpoint can be called to trigger invoice generation and distribution with a specified cut off date in sandbox
and can be used to test invoicing behaviour when integrating with the API.
Normal invoicing rules will run and factor in:
* merchant-specific rules for the invoicing date within the billing cycle
* repayment account configuration rules for the due date
* invoicing grouping keys (if any) for specific plans for the repayment account
The endpoint will trigger invoicing as if it is running on the specified cut off date. This means it will identify
any instalments with an invoicing date between today and the given cut off date (inclusive) and generate invoices
for those instalments according to the factors mentioned above.
As the invoicing process is asynchronous, there will be a short delay after hitting this endpoint before invoices
are distributed. This delay will typically be 2 minutes.
operationId: trigger_future_invoice_testing_send_invoices_post
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TriggerFutureInvoiceRequest'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/FutureInvoiceCreateResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan:
post:
tags:
- Repayment Plans
summary: Create Repayment Plan
description: Create a new repayment plan.
operationId: create_repayment_plan_plan_post
parameters:
- description: A unique value generated by the client which the server
uses to recognize subsequent retries of the same request
required: true
schema:
type: string
maxLength: 36
minLength: 1
title: Idempotency-Key
description: A unique value generated by the client which the
server uses to recognize subsequent retries of the same request
name: Idempotency-Key
in: header
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanRequest'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanResponse'
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/{repayment_plan_id}:
get:
tags:
- Repayment Plans
summary: Get Repayment Plan
operationId: get_repayment_plan_plan__repayment_plan_id__get
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
patch:
tags:
- Repayment Plans
summary: Update Repayment Plan
description: Update repayment plan.
operationId: update_repayment_plan_plan__repayment_plan_id__patch
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanUpdateRequest'
required: true
responses:
'204':
description: Successful Response
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/{repayment_plan_id}/status:
get:
tags:
- Repayment Plans
summary: Get Repayment Plan Status
operationId: get_repayment_plan_status_plan__repayment_plan_id__status_get
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanStatusResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/{repayment_plan_id}/invoices:
get:
tags:
- Repayment Plans
summary: Get Repayment Plan Invoice Details
operationId: get_repayment_plan_invoice_details_plan__repayment_plan_id__invoices_get
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanInvoiceStatusResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/{repayment_plan_id}/cancellation:
put:
tags:
- Repayment Plans
summary: Cancel Repayment Plan
operationId: cancel_repayment_plan_plan__repayment_plan_id__cancellation_put
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
- description: A unique value generated by the client which the server
uses to recognize subsequent retries of the same request
required: true
schema:
type: string
maxLength: 36
minLength: 1
title: Idempotency-Key
description: A unique value generated by the client which the
server uses to recognize subsequent retries of the same request
name: Idempotency-Key
in: header
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Cancellation'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/Cancellation'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/{repayment_plan_id}/fulfilment:
put:
tags:
- Repayment Plans
summary: Fulfill Repayment Plan
description: |-
Requests that Two marks the repayment plan as fulfilled.
This endpoint will submit a request for Two to mark the repayment plan as fulfilled (the HTTP 202 response code
indicates that Two has successfully received the request to fulfil this repayment plan). Note that fulfilment in
Two's systems will happen asynchronously, so your integration should check the repayment plan `fulfilment_status`
using the repayment plan status endpoint before marking the repayment plan as fulfilled (or fulfilled by Two) in
your own system.
* Before the fulfilment request is received for a given repayment plan, `fulfilment_status` in the repayment plan
status endpoint will show as `NOT_INITIATED`.
* Once the request has been received, but before it is considered fulfilled by Two, the status endpoint's
`fulfilment_status` will be marked as `PENDING`.
* When the fulfilment request has been completed in Two's systems, `fulfilment_status` will be `SUCCEEDED`.
* It is possible for `fulfilment_status` to show as `FAILED` if the credit decision for the plan has expired and Two
has reassessed the buyer for this plan and can no longer support this repayment plan.
operationId: fulfill_repayment_plan_plan__repayment_plan_id__fulfilment_put
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanFulfillment'
responses:
'202':
description: Successful Response
content:
application/json:
schema: {}
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/preview:
post:
tags:
- Repayment Plans
summary: Create Repayment Plan Preview
description: Request a preview of a repayment plan based on key features
of a plan including term length and total amount.
operationId: create_repayment_plan_preview_plan_preview_post
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanPreviewRequest'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentPlanPreviewResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/plan/{repayment_plan_id}/instalment/{instalment_id}:
put:
tags:
- Repayment Plans
summary: Update Instalment
operationId: update_instalment_plan__repayment_plan_id__instalment__instalment_id__put
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Plan Id
name: repayment_plan_id
in: path
- required: true
schema:
type: string
format: uuid
title: Instalment Id
name: instalment_id
in: path
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/InstalmentUpdateRequest'
required: true
responses:
'204':
description: Successful Response
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/account:
post:
tags:
- Repayment Accounts
summary: Create Repayment Account
description: |-
Creates a repayment account for use with repayment plan invoicing.
When a repayment plan is created, an existing repayment account must be referenced. Then, whenever an instalment is
invoiced the referenced repayment account is used to determine the billing details for the invoice. Updating a
repayment account will affect subsequent invoices only.
operationId: create_repayment_account_account_post
parameters:
- description: A unique value generated by the client which the server
uses to recognize subsequent retries of the same request
required: true
schema:
type: string
maxLength: 36
minLength: 1
title: Idempotency-Key
description: A unique value generated by the client which the
server uses to recognize subsequent retries of the same request
name: Idempotency-Key
in: header
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentAccount'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentAccount'
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentAccount'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/account/{repayment_account_id}:
get:
tags:
- Repayment Accounts
summary: Get Repayment Account
operationId: get_repayment_account_account__repayment_account_id__get
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Account Id
name: repayment_account_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentAccount'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
put:
tags:
- Repayment Accounts
summary: Update Repayment Account
description: |-
Update the payment account information using the Two `repayment_account_id`.
As was stated when creating a payment account, it is strongly encouraged that the repayment accounts correspond to
existing accounts of your buyers in your system, so that Buyers have a place to change their contact details. You
are expected to provide the buyer company's national id and address, which you can easily get from [**Step
1**](/docs/api/repay/two-repay-api/).
Note that the due_in_days field can only be updated before any repayment plans have been fulfilled, otherwise a 409
error will be returned.
operationId: update_repayment_account_account__repayment_account_id__put
parameters:
- required: true
schema:
type: string
format: uuid
title: Repayment Account Id
name: repayment_account_id
in: path
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RepaymentAccountUpdate'
required: true
responses:
'204':
description: Successful Response
'409':
description: Conflict
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/invoice/{invoice_id}/pdf:
get:
tags:
- Invoices
summary: Get Invoice Document URL
description: Retrieve the URL of the invoice PDF for the given invoice
ID.
operationId: get_invoice_document_url_invoice__invoice_id__pdf_get
parameters:
- required: true
schema:
type: string
format: uuid
title: Invoice Id
name: invoice_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/InvoicePdfUrlResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/invoice/{invoice_id}:
get:
tags:
- Invoices
summary: Get Invoice Details
operationId: get_invoice_details_invoice__invoice_id__get
parameters:
- required: true
schema:
type: string
format: uuid
title: Invoice Id
name: invoice_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/InvoiceDetails'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
/credit-check:
post:
tags:
- Credit Check
summary: Credit Check
description: |-
Use the `POST /credit-check` endpoint to evaluate the funding eligibility of a buyer based on the total value of a
prospective instalment plan and the frequency of invoicing for a prospective plan.
The API responds with the conditions under which Two can approve the funding, including the maximum and minimum
terms, as well as the maximum amount that can be offered per term (such as monthly).
operationId: credit_check_credit_check_post
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreditCheckRequest'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CreditCheckResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- api-key: []
components:
schemas:
Address:
properties:
address_line_1:
type: string
title: Address Line 1
address_line_2:
type: string
title: Address Line 2
city:
type: string
title: City
region:
type: string
title: Region
postal_code:
type: string
title: Postal Code
country_code:
$ref: '#/components/schemas/CountryCode'
type: object
required:
- address_line_1
- city
- postal_code
- country_code
title: Address
Cancellation:
properties:
id:
type: string
maxLength: 40
minLength: 1
pattern: ^[a-zA-Z0-9\-_]+$
title: Id
readOnly: true
cancelled_at:
type: string
format: date-time
title: Cancelled At
cancelled_repayment_amount:
allOf:
- $ref: '#/components/schemas/Money'
title: Cancelled Repayment Amount
description: The sum of repayment amounts over all remaining installments
(i.e. those not yet invoiced). Partially cancelling a repayment
plan is not possible.
readOnly: true
currency:
allOf:
- $ref: '#/components/schemas/CurrencyCode'
readOnly: true
cancel_reason:
allOf:
- $ref: '#/components/schemas/CancellationReason'
default: TERMINATED
type: object
required:
- cancelled_at
title: Cancellation
description: A cancellation cancels the remaining parts of a repayment
plan that has not yet been invoiced.
CancellationReason:
type: string
enum:
- TAX_CHANGES
- CREDIT_LIMITATION
- WRONG_DETAILS
- MIGRATION
- TERMINATED
title: CancellationReason
description: |-
Documents the reason for cancelling remaining instalments of a repayment plan.
Cancelling a repayment plan for any reason only cancels instalments in the
plan that do not yet have invoices.
`TERMINATED` is used by default if not explicitly provided.
* `TAX_CHANGES`: Sales tax (such as VAT) rules change part-way through a
repayment plan and you need to re-create the remainder of the repayment
plan using the new tax rates and amounts.
* `CREDIT_LIMITATION`: You intend to repurchase the repayment plan from Two
when we are unable to fund new repayment plans for a buyer so you can, for
example, continue to send the buyer a single invoice for all repayment
plans.
* `WRONG_DETAILS`: The repayment plan has incorrect details and you intend to
recreate the repayment plan with the correct details. Note that this
excludes incorrect contact details for the repayment account, which can be
updated using the repayment account endpoints without cancelling the
repayment plan.
* `MIGRATION`: The repayment plan has errors introduced while migrating
repayment plan tracking from external systems to the Two service and you
intend to recreate it without errors.
* `TERMINATED` (default): Repurchase a repayment plan from Two, or termination
of a repayment plan for other reasons. There is no expectation to recreate
the repayment plan at a later date.
Company:
properties:
trade_name:
type: string
maxLength: 40
minLength: 1
pattern: ^[a-zA-Z0-9\-_]+$
title: Trade Name
description: The name of the company as registered in the merchant's
systems.
official_address:
$ref: '#/components/schemas/Address'
country_code:
$ref: '#/components/schemas/CountryCode'
national_identifier:
type: string
maxLength: 40
minLength: 1
pattern: ^[a-zA-Z0-9\-_]+$
title: National Identifier
description: The identifier for the company in the national company
registries. For example, CRN in the United Kingdom and Org.
nr. in Norway.
type: object
required:
- trade_name
- official_address
- country_code
- national_identifier
title: Company
CompanyUpdate:
properties:
trade_name:
type: string
maxLength: 40
minLength: 1
pattern: ^[a-zA-Z0-9\-_]+$
title: Trade Name
description: The name of the company as registered in the merchant's
systems.
official_address:
$ref: '#/components/schemas/Address'
type: object
required:
- trade_name
- official_address
title: CompanyUpdate
CountryCode:
type: string
enum:
- AT
- BE
- DE
- DK
- FI
- FR
- GB
- NL
- 'NO'
- SE
- US
title: CountryCode
description: Country code in ISO 3166 Alpha-2 format.
CreditCheckRequest:
properties:
country_code:
$ref: '#/components/schemas/CountryCode'
national_identifier:
type: string
maxLength: 40
minLength: 1
pattern: ^[a-zA-Z0-9\-_]+$
title: National Identifier
description: The identifier for the company in the national company
registries. For example, CRN in the United Kingdom and Org.
nr. in Norway.
company_name:
type: string
title: Company Name
description: The name of the company.
amount:
allOf:
- $ref: '#/components/schemas/PositiveMoney'
title: Amount
description: The amount of credit to check against the given company
details.
currency:
allOf:
- $ref: '#/components/schemas/CurrencyCode'
description: The currency of the credit check.
default: GBP
instalment_period:
allOf:
- $ref: '#/components/schemas/RepaymentPeriod'
description: The period over which the credit should be divided
into instalments. Defaults to MONTHLY. Currently only MONTHLY
is supported.
type: object
required:
- country_code
- national_identifier
- company_name
- amount
title: CreditCheckRequest
CreditCheckResponse:
properties:
minimum_instalments:
type: integer
title: Minimum Instalments
description: The minimum number of term instalments Two will provide
for the queried amount of credit.
maximum_instalments:
type: integer
title: Maximum Instalments
description: The maximum number of term instalments Two will provide
for the queried amount of credit.
maximum_instalment_amount:
$ref: '#/components/schemas/Money'
decision:
allOf:
- $ref: '#/components/schemas/CreditDecisionEnum'
description: Outcome of the credit check
currency:
$ref: '#/components/schemas/CurrencyCode'
type: object
required:
- minimum_instalments
- maximum_instalments
- maximum_instalment_amount
- decision
- currency
title: CreditCheckResponse
description: Details the credit level available to a buyer for a repayment
plan based on the given `CreditCheckRequest`.
CreditDecisionEnum:
type: string
enum:
- APPROVED
- DECLINED
title: CreditDecisionEnum
description: An enumeration.
CurrencyCode:
type: string
enum:
- DKK
- EUR
- GBP
- NOK
- SEK
- USD
title: CurrencyCode
description: Alphabetic currency code according to ISO 4217.
Error:
properties:
description:
type: string
title: Description
code:
allOf:
- $ref: '#/components/schemas/ErrorCode'
default: ERROR
type: object
required:
- description
title: Error
ErrorCode:
type: string
enum:
- ERROR
title: ErrorCode
description: An enumeration.
FulfilmentStatus:
type: string
enum:
- NOT_INITIATED
- PENDING