1
|
|
|
package mollie |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"context" |
5
|
|
|
"encoding/json" |
6
|
|
|
"time" |
7
|
|
|
) |
8
|
|
|
|
9
|
|
|
const onboardingURLPath = "v2/onboarding/me" |
10
|
|
|
|
11
|
|
|
// OnboardingStatus describes status of the organization’s onboarding process. |
12
|
|
|
type OnboardingStatus string |
13
|
|
|
|
14
|
|
|
// Possible status values. |
15
|
|
|
const ( |
16
|
|
|
NeedsDataOnboardingStatus OnboardingStatus = "needs-data" |
17
|
|
|
InReviewOnboardingStatus OnboardingStatus = "in-review" |
18
|
|
|
CompletedOnboardingStatus OnboardingStatus = "completed" |
19
|
|
|
) |
20
|
|
|
|
21
|
|
|
// OnboardingLinks contains URL objects relevant to the onboarding status. |
22
|
|
|
type OnboardingLinks struct { |
23
|
|
|
Self *URL `json:"self,omitempty"` |
24
|
|
|
Dashboard *URL `json:"dashboard,omitempty"` |
25
|
|
|
Organization *URL `json:"organization,omitempty"` |
26
|
|
|
Documentation *URL `json:"documentation,omitempty"` |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// Onboarding data for an organization. |
30
|
|
|
type Onboarding struct { |
31
|
|
|
CanReceivePayments bool `json:"canReceivePayments,omitempty"` |
32
|
|
|
CanReceiveSettlements bool `json:"canReceiveSettlements,omitempty"` |
33
|
|
|
Resource string `json:"reference,omitempty"` |
34
|
|
|
Name string `json:"name,omitempty"` |
35
|
|
|
SignedUpAt *time.Time `json:"signedUpAt,omitempty"` |
36
|
|
|
Status OnboardingStatus `json:"status,omitempty"` |
37
|
|
|
Links OnboardingLinks `json:"_links,omitempty"` |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// OnboardingData request possible values. |
41
|
|
|
// |
42
|
|
|
// Please note that even though all parameters are optional, |
43
|
|
|
// at least one of them needs to be provided in the request. |
44
|
|
|
// |
45
|
|
|
// Information that the merchant has entered in their dashboard will not be overwritten. |
46
|
|
|
|
47
|
1 |
|
// OnboardingDataOrganization contains data of the organization you want to provide. |
48
|
1 |
|
type OnboardingDataOrganization struct { |
49
|
1 |
|
Name string `json:"name,omitempty"` |
50
|
|
|
RegistrationNumber string `json:"registrationNumber,omitempty"` |
51
|
|
|
VatNumber string `json:"vatNumber,omitempty"` |
52
|
1 |
|
VatRegulation string `json:"vatRegulation,omitempty"` |
53
|
1 |
|
Address *Address `json:"address,omitempty"` |
54
|
|
|
} |
55
|
|
|
|
56
|
1 |
|
// OnboardingDataProfile contains data of the payment profile you want to provide. |
57
|
|
|
type OnboardingDataProfile struct { |
58
|
|
|
Name string `json:"name,omitempty"` |
59
|
|
|
URL string `json:"url,omitempty"` |
60
|
|
|
Email string `json:"email,omitempty"` |
61
|
|
|
Description string `json:"description,omitempty"` |
62
|
|
|
Phone string `json:"phone,omitempty"` |
63
|
|
|
BusinessCategory BusinessCategory `json:"businessCategory,omitempty"` |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
// OnboardingData describes the information to be submitted. |
67
|
|
|
type OnboardingData struct { |
68
|
|
|
Organization OnboardingDataOrganization `json:"organization,omitempty"` |
69
|
|
|
Profile OnboardingDataProfile `json:"profile,omitempty"` |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// OnboardingService operates over the onboarding API. |
73
|
|
|
type OnboardingService service |
74
|
|
|
|
75
|
|
|
// GetOnboardingStatus gets the status of onboarding of the authenticated organization. |
76
|
|
|
// |
77
|
|
|
// See: https://docs.mollie.com/reference/get-onboarding-status |
78
|
|
|
func (os *OnboardingService) GetOnboardingStatus(ctx context.Context) (res *Response, o *Onboarding, err error) { |
79
|
|
|
res, err = os.client.get(ctx, onboardingURLPath, nil) |
80
|
|
|
if err != nil { |
81
|
|
|
return |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if err = json.Unmarshal(res.content, &o); err != nil { |
85
|
|
|
return |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
// SubmitOnboardingData sends data that will be prefilled in the merchant’s onboarding. |
92
|
|
|
// Please note that the data you submit will only be processed when the onboarding status is needs-data. |
93
|
|
|
// |
94
|
|
|
// This endpoint has been deprecated. It will be supported for the foreseeable future, but new implementations should |
95
|
|
|
// use the Create client link endpoint to create new clients and submit their organization’s details in one go. |
96
|
|
|
// |
97
|
|
|
// See: https://docs.mollie.com/reference/submit-onboarding-data |
98
|
|
|
func (os *OnboardingService) SubmitOnboardingData(ctx context.Context, d *OnboardingData) (res *Response, err error) { |
99
|
1 |
|
res, err = os.client.post(ctx, onboardingURLPath, d, nil) |
100
|
1 |
|
if err != nil { |
101
|
1 |
|
return |
102
|
|
|
} |
103
|
|
|
|
104
|
1 |
|
return |
105
|
|
|
} |
106
|
|
|
|