Documentation ¶
Index ¶
- Constants
- Variables
- type Address
- type Addresses
- type Applicant
- type ApplicantIter
- type Applicants
- type Check
- type CheckIter
- type CheckRequest
- type CheckResult
- type CheckStatus
- type CheckType
- type Checks
- type Client
- func (c *Client) CancelReport(ctx context.Context, checkID, id string) error
- func (c *Client) CreateApplicant(ctx context.Context, a Applicant) (*Applicant, error)
- func (c *Client) CreateCheck(ctx context.Context, applicantID string, cr CheckRequest) (*Check, error)
- func (c *Client) DeleteApplicant(ctx context.Context, id string) error
- func (c *Client) GetApplicant(ctx context.Context, id string) (*Applicant, error)
- func (c *Client) GetCheck(ctx context.Context, applicantID, id string) (*Check, error)
- func (c *Client) GetDocument(ctx context.Context, applicantID, id string) (*Document, error)
- func (c *Client) GetReport(ctx context.Context, checkID, id string) (*Report, error)
- func (c *Client) ListApplicants() *ApplicantIter
- func (c *Client) ListChecks(applicantID string) *CheckIter
- func (c *Client) ListDocuments(applicantID string) *DocumentIter
- func (c *Client) ListReports(checkID string) *ReportIter
- func (c *Client) NewSdkToken(ctx context.Context, id, referrer string) (*SdkToken, error)
- func (c *Client) PickAddresses(postcode string) *PickerIter
- func (c *Client) ResumeCheck(ctx context.Context, id string) (*Check, error)
- func (c *Client) ResumeReport(ctx context.Context, checkID, id string) error
- func (c *Client) UpdateApplicant(ctx context.Context, a Applicant) (*Applicant, error)
- func (c *Client) UploadDocument(ctx context.Context, applicantID string, dr DocumentRequest) (*Document, error)
- type Document
- type DocumentIter
- type DocumentRequest
- type DocumentSide
- type DocumentType
- type Documents
- type Error
- type ErrorFields
- type HTTPRequester
- type IDNumber
- type IDNumberType
- type PickerIter
- type Report
- type ReportIter
- type ReportName
- type ReportResult
- type ReportSubResult
- type ReportVariant
- type Reports
- type SdkToken
- type Token
- type Webhook
- type WebhookRequest
Examples ¶
Constants ¶
const ( CheckTypeExpress CheckType = "express" CheckTypeStandard CheckType = "standard" CheckStatusInProgress CheckStatus = "in_progress" CheckStatusAwaitingApplicant CheckStatus = "awaiting_applicant" CheckStatusComplete CheckStatus = "complete" CheckStatusWithdrawn CheckStatus = "withdrawn" CheckStatusPaused CheckStatus = "paused" CheckStatusReopened CheckStatus = "reopened" CheckResultClear CheckResult = "clear" CheckResultConsider CheckResult = "consider" )
Supported check types
const ( DocumentTypeUnknown DocumentType = "unknown" DocumentTypePassport DocumentType = "passport" DocumentTypeIDCard DocumentType = "national_identity_card" DocumentTypeDrivingLicense DocumentType = "driving_licence" DocumentTypeUKBRP DocumentType = "uk_biometric_residence_permit" DocumentTypeTaxID DocumentType = "tax_id" DocumentTypeVoterID DocumentType = "voter_id" DocumentSideFront DocumentSide = "front" DocumentSideBack DocumentSide = "back" )
Supported document types and sides
const ( ClientVersion = "0.1.0" DefaultEndpoint = "https://api.onfido.com/v2" TokenEnv = "ONFIDO_TOKEN" )
Constants
const ( ReportNameIdentity ReportName = "identity" ReportNameDocument ReportName = "document" ReportNameFacialSimilarity ReportName = "facial_similarity" ReportNameStreetLevel ReportName = "street_level" ReportNameWatchlist ReportName = "watchlist" ReportNameProofOfAddress ReportName = "proof_of_address" ReportResultClear ReportResult = "clear" ReportResultConsider ReportResult = "consider" ReportResultUnidentified ReportResult = "unidentified" ReportSubResultClear ReportSubResult = "clear" ReportSubResultRejected ReportSubResult = "rejected" ReportSubResultSuspected ReportSubResult = "suspected" ReportSubResultCaution ReportSubResult = "caution" ReportVariantStandard ReportVariant = "standard" ReportVariantKYC ReportVariant = "kyc" ReportVariantVideo ReportVariant = "video" ReportVariantFull ReportVariant = "full" )
Supported report names, results, subresults, and variants
const ( WebhookSignatureHeader = "X-Signature" WebhookTokenEnv = "ONFIDO_WEBHOOK_TOKEN" )
Constants
Variables ¶
var ( ErrInvalidWebhookSignature = errors.New("invalid request, payload hash doesn't match signature") ErrMissingWebhookToken = errors.New("webhook token not found in environmental variable") )
Webhook errors
var ( // ErrEmptyPostcode means that an empty postcode param was passed ErrEmptyPostcode = errors.New("empty postcode") )
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { FlatNumber string `json:"flat_number"` BuildingNumber string `json:"building_number"` BuildingName string `json:"building_name"` Street string `json:"street"` SubStreet string `json:"sub_street"` Town string `json:"town"` State string `json:"state"` Postcode string `json:"postcode"` Country string `json:"country"` // Applicant specific StartDate string `json:"start_date,omitempty"` EndDate string `json:"end_date,omitempty"` }
Address represents an address from the Onfido API
type Addresses ¶
type Addresses struct {
Addresses []*Address `json:"addresses"`
}
Addresses represents a list of addresses from the Onfido API
type Applicant ¶
type Applicant struct { ID string `json:"id,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Sandbox bool `json:"sandbox,omitempty"` Title string `json:"title,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` MiddleName string `json:"middle_name,omitempty"` Email string `json:"email,omitempty"` Gender string `json:"gender,omitempty"` DOB string `json:"dob,omitempty"` Telephone string `json:"telephone,omitempty"` Mobile string `json:"mobile,omitempty"` Country string `json:"country,omitempty"` MothersMaidenName string `json:"mothers_maiden_name,omitempty"` PreviousLastName string `json:"previous_last_name,omitempty"` Nationality string `json:"nationality,omitempty"` CountryOfBirth string `json:"country_of_birth,omitempty"` TownOfBirth string `json:"town_of_birth,omitempty"` IDNumbers []IDNumber `json:"id_numbers,omitempty"` Addresses []Address `json:"addresses,omitempty"` }
Applicant represents an applicant from the Onfido API
type ApplicantIter ¶
type ApplicantIter struct {
// contains filtered or unexported fields
}
ApplicantIter represents an applicant iterator
func (*ApplicantIter) Applicant ¶
func (i *ApplicantIter) Applicant() *Applicant
Applicant returns the current applicant on the iterator.
type Applicants ¶
type Applicants struct {
Applicants []*Applicant `json:"applicants"`
}
Applicants represents a list of applicants from the Onfido API
type Check ¶
type Check struct { ID string `json:"id,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Href string `json:"href,omitempty"` Type CheckType `json:"type,omitempty"` Status CheckStatus `json:"status,omitempty"` Result CheckResult `json:"result,omitempty"` DownloadURI string `json:"download_uri,omitempty"` FormURI string `json:"form_uri,omitempty"` RedirectURI string `json:"redirect_uri,omitempty"` ResultsURI string `json:"results_uri,omitempty"` Tags []string `json:"tags,omitempty"` }
Check represents a check in Onfido API
type CheckIter ¶
type CheckIter struct {
// contains filtered or unexported fields
}
CheckIter represents a check iterator
type CheckRequest ¶
type CheckRequest struct { Type CheckType `json:"type"` RedirectURI string `json:"redirect_uri,omitempty"` Reports []*Report `json:"reports"` Tags []string `json:"tags,omitempty"` SupressFormEmails bool `json:"suppress_form_emails,omitempty"` Async bool `json:"async,omitempty"` ChargeApplicantForCheck bool `json:"charge_applicant_for_check,omitempty"` // Used for sandbox testing Consider []ReportName `json:"consider,omitempty"` }
CheckRequest represents a check request to Onfido API. It contains the consider field which is used for Sandbox Testing of multiple report scenarios. See https://documentation.onfido.com/#sandbox-responses
type CheckResult ¶
type CheckResult string
CheckResult represents a result of a check (clear, consider)
type Checks ¶
type Checks struct {
Checks []*Check `json:"checks"`
}
Checks represents a list of checks in Onfido API
type Client ¶
type Client struct { Endpoint string HTTPClient HTTPRequester Token Token }
Client represents an Onfido API client
func NewClientFromEnv ¶
NewClientFromEnv creates a new Onfido client using configuration from environment variables.
func (*Client) CancelReport ¶
CancelReport cancels a report by its ID. see https://documentation.onfido.com/?shell#cancel-report
func (*Client) CreateApplicant ¶
CreateApplicant creates a new applicant. see https://documentation.onfido.com/?shell#create-applicant
Example ¶
ctx := context.Background() // Creating Client client, err := NewClientFromEnv() if err != nil { panic(err) } if client.Token.Prod() { panic("onfido token is only for production use") } // Creating Applicant applicant, err := client.CreateApplicant(ctx, Applicant{ Email: "rcrowe@example.co.uk", FirstName: "Rob", LastName: "Crowe", Addresses: []Address{ { BuildingNumber: "18", Street: "Wind Corner", Town: "Crawley", State: "West Sussex", Postcode: "NW9 5AB", Country: "GBR", StartDate: "2018-02-10", }, }, }) if err != nil { panic(err) } // Deleting Applicant if err := client.DeleteApplicant(ctx, applicant.ID); err != nil { panic(err) }
Output:
func (*Client) CreateCheck ¶
func (c *Client) CreateCheck(ctx context.Context, applicantID string, cr CheckRequest) (*Check, error)
CreateCheck creates a new check for the provided applicant. see https://documentation.onfido.com/?shell#create-check
Example ¶
ctx := context.Background() client, err := NewClientFromEnv() if err != nil { panic(err) } if client.Token.Prod() { panic("onfido token is only for production use") } applicant, err := client.CreateApplicant(ctx, Applicant{ Email: "rcrowe@example.co.uk", FirstName: "Rob", LastName: "Crowe", Addresses: []Address{ { BuildingNumber: "18", Street: "Wind Corner", Town: "Crawley", State: "West Sussex", Postcode: "NW9 5AB", Country: "GBR", StartDate: "2018-02-10", }, }, }) if err != nil { panic(err) } check, err := client.CreateCheck(ctx, applicant.ID, CheckRequest{ Type: CheckTypeStandard, Reports: []*Report{ { Name: ReportNameDocument, }, { Name: ReportNameIdentity, Variant: ReportVariantKYC, }, }, }) if err != nil { panic(err) } fmt.Printf("Form: %+v\n", check.FormURI)
Output:
func (*Client) DeleteApplicant ¶
DeleteApplicant deletes an applicant by its id. see https://documentation.onfido.com/?shell#delete-applicant
func (*Client) GetApplicant ¶
GetApplicant retrieves an applicant by its id. see https://documentation.onfido.com/?shell#retrieve-applicant
Example ¶
ctx := context.Background() client, err := NewClientFromEnv() if err != nil { panic(err) } if client.Token.Prod() { panic("onfido token is only for production use") } applicant, err := client.CreateApplicant(ctx, Applicant{ Email: "rcrowe@example.co.uk", FirstName: "Rob", LastName: "Crowe", Addresses: []Address{ { BuildingNumber: "18", Street: "Wind Corner", Town: "Crawley", State: "West Sussex", Postcode: "NW9 5AB", Country: "GBR", StartDate: "2018-02-10", }, }, }) if err != nil { panic(err) } // Getting Applicant applicant, err = client.GetApplicant(ctx, applicant.ID) if err != nil { panic(err) } if err := client.DeleteApplicant(ctx, applicant.ID); err != nil { panic(err) }
Output:
func (*Client) GetCheck ¶
GetCheck retrieves a check for the provided applicant by its ID. see https://documentation.onfido.com/?shell#retrieve-check
func (*Client) GetDocument ¶
GetDocument retrieves a single document for the provided applicant by its ID. see https://documentation.onfido.com/?shell#retrieve-document
func (*Client) GetReport ¶
GetReport retrieves a report for the provided check by its ID. see https://documentation.onfido.com/?shell#retrieve-report
func (*Client) ListApplicants ¶
func (c *Client) ListApplicants() *ApplicantIter
ListApplicants retrieves the list of applicants. see https://documentation.onfido.com/?shell#list-applicants
Example ¶
ctx := context.Background() client, err := NewClientFromEnv() if err != nil { panic(err) } if client.Token.Prod() { panic("onfido token is only for production use") } iter := client.ListApplicants() for iter.Next(ctx) { fmt.Printf("%+v\n", iter.Applicant()) } if iter.Err() != nil { panic(iter.Err()) }
Output:
func (*Client) ListChecks ¶
ListChecks retrieves the list of checks for the provided applicant. see https://documentation.onfido.com/?shell#list-checks
func (*Client) ListDocuments ¶
func (c *Client) ListDocuments(applicantID string) *DocumentIter
ListDocuments retrieves the list of documents for the provided applicant. see https://documentation.onfido.com/?shell#list-documents
func (*Client) ListReports ¶
func (c *Client) ListReports(checkID string) *ReportIter
ListReports retrieves the list of reports for the provided check. see https://documentation.onfido.com/?shell#list-reports
func (*Client) NewSdkToken ¶
NewSdkToken returns a JWT token to used by the Javascript SDK
Example ¶
ctx := context.Background() client, err := NewClientFromEnv() if err != nil { panic(err) } if client.Token.Prod() { panic("onfido token is only for production use") } applicant, err := client.CreateApplicant(ctx, Applicant{ Email: "rcrowe@example.co.uk", FirstName: "Rob", LastName: "Crowe", Addresses: []Address{ { BuildingNumber: "18", Street: "Wind Corner", Town: "Crawley", State: "West Sussex", Postcode: "NW9 5AB", Country: "GBR", StartDate: "2018-02-10", }, }, }) if err != nil { panic(err) } t, err := client.NewSdkToken(ctx, applicant.ID, "https://*.onfido.com/documentation/*") if err != nil { panic(err) } fmt.Printf("Token: %v\n", t.Token) if err := client.DeleteApplicant(ctx, applicant.ID); err != nil { panic(err) }
Output:
func (*Client) PickAddresses ¶
func (c *Client) PickAddresses(postcode string) *PickerIter
PickAddresses retrieves the list of addresses matched against the provided postcode. see https://documentation.onfido.com/?shell#address-picker
func (*Client) ResumeCheck ¶
ResumeCheck resumes a paused check by its ID. see https://documentation.onfido.com/?shell#resume-check
func (*Client) ResumeReport ¶
ResumeReport resumes a paused report by its ID. see https://documentation.onfido.com/?shell#resume-report
func (*Client) UpdateApplicant ¶
UpdateApplicant updates an applicant by its id. see https://documentation.onfido.com/?shell#update-applicant
func (*Client) UploadDocument ¶
func (c *Client) UploadDocument(ctx context.Context, applicantID string, dr DocumentRequest) (*Document, error)
UploadDocument uploads a document for the provided applicant. see https://documentation.onfido.com/?shell#upload-document
Example ¶
ctx := context.Background() applicantID := "3ac9e550-556f-4c67-84f2-0940c85cbe67" client, err := NewClientFromEnv() if err != nil { panic(err) } doc, err := os.Open("id-card.jpg") if err != nil { panic(err) } defer doc.Close() document, err := client.UploadDocument(ctx, applicantID, DocumentRequest{ File: doc, Type: DocumentTypeIDCard, Side: DocumentSideFront, }) if err != nil { panic(err) } fmt.Printf("%+v", document)
Output:
type Document ¶
type Document struct { ID string `json:"id,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Href string `json:"href,omitempty"` DownloadHref string `json:"download_href,omitempty"` FileName string `json:"file_name,omitempty"` FileType string `json:"file_type,omitempty"` FileSize int `json:"file_size,omitempty"` Type DocumentType `json:"type,omitempty"` Side DocumentSide `json:"side,omitempty"` }
Document represents a document in Onfido API
type DocumentIter ¶
type DocumentIter struct {
// contains filtered or unexported fields
}
DocumentIter represents a document iterator
func (*DocumentIter) Document ¶
func (i *DocumentIter) Document() *Document
Document returns the current item in the iterator as a Document.
type DocumentRequest ¶
type DocumentRequest struct { File io.ReadSeeker Type DocumentType Side DocumentSide }
DocumentRequest represents a document request to Onfido API
type DocumentType ¶
type DocumentType string
DocumentType represents a document type (passport, ID, etc)
type Documents ¶
type Documents struct {
Documents []*Document `json:"documents"`
}
Documents represents a list of documents from the Onfido API
type Error ¶
type Error struct { Resp *http.Response Err struct { ID string `json:"id"` Type string `json:"type"` Msg string `json:"message"` Fields ErrorFields `json:"fields"` } `json:"error"` }
Error represents an Onfido API error response
type ErrorFields ¶
type HTTPRequester ¶
HTTPRequester represents an HTTP requester
type IDNumber ¶
type IDNumber struct { Type IDNumberType `json:"type,omitempty"` Value string `json:"value,omitempty"` StateCode string `json:"state_code,omitempty"` }
IDNumber represents an ID number from the Onfido API
type IDNumberType ¶
type IDNumberType string
IDNumberType represents an ID type (ssn, social insurance, etc)
const ( IDNumberTypeSSN IDNumberType = "ssn" IDNumberTypeSocialInsurance IDNumberType = "social_insurance" IDNumberTypeTaxID IDNumberType = "tax_id" IDNumberTypeIdentityCard IDNumberType = "identity_card" IDNumberTypeDrivingLicense IDNumberType = "driving_license" )
Supported ID number types
type PickerIter ¶
type PickerIter struct {
// contains filtered or unexported fields
}
PickerIter represents an address picker iterator
func (*PickerIter) Address ¶
func (i *PickerIter) Address() *Address
Address returns the current address on the iterator.
type Report ¶
type Report struct { ID string `json:"id,omitempty"` Name ReportName `json:"name,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Status string `json:"status,omitempty"` Result ReportResult `json:"result,omitempty"` SubResult ReportSubResult `json:"sub_result,omitempty"` Variant ReportVariant `json:"variant,omitempty"` Href string `json:"href,omitempty"` Options map[string]interface{} `json:"options,omitempty"` Breakdown map[string]interface{} `json:"breakdown,omitempty"` Properties map[string]interface{} `json:"properties,omitempty"` }
Report represents a report from the Onfido API
type ReportIter ¶
type ReportIter struct {
// contains filtered or unexported fields
}
ReportIter represents a document iterator
func (*ReportIter) Report ¶
func (i *ReportIter) Report() *Report
Report returns the current item in the iterator as a Report.
type Reports ¶
type Reports struct {
Reports []*Report `json:"reports"`
}
Reports represents a list of reports from the Onfido API
type SdkToken ¶
type SdkToken struct { ApplicantID string `json:"applicant_id,omitempty"` Referrer string `json:"referrer,omitempty"` Token string `json:"token,omitempty"` }
SdkToken represents the response for a request for a JWT token
type Webhook ¶
type Webhook struct {
Token string
}
Webhook represents a webhook handler
func NewWebhookFromEnv ¶
NewWebhookFromEnv creates a new webhook handler using configuration from environment variables.
func (*Webhook) ParseFromRequest ¶
func (wh *Webhook) ParseFromRequest(req *http.Request) (*WebhookRequest, error)
ParseFromRequest parses the webhook request body and returns it as WebhookRequest if the request signature is valid.
Example ¶
wh, err := NewWebhookFromEnv() if err != nil { panic(err) } http.HandleFunc("/webhook/onfido", func(w http.ResponseWriter, req *http.Request) { whReq, err := wh.ParseFromRequest(req) if err != nil { if err == ErrInvalidWebhookSignature { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("Invalid signature")) return } w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("Error occurred")) return } fmt.Fprintf(w, "Webhook: %+v\n", whReq) }) http.ListenAndServe(":8080", nil)
Output:
type WebhookRequest ¶
type WebhookRequest struct { Payload struct { ResourceType string `json:"resource_type"` Action string `json:"action"` Object struct { ID string `json:"id"` Status string `json:"status"` CompletedAt string `json:"completed_at"` Href string `json:"href"` } `json:"object"` } `json:"payload"` }
WebhookRequest represents an incoming webhook request from Onfido