User information
User information retrieval (getConsentedUserData)
getConsentedUserDataIt is a function that requests consent-based user data. If consent is required, it opens the terms webview, and when consent is completed, returns the data retrieved from the server.
Signature
function getConsentedUserData(options: GetConsentedUserDataOptions): Promise<ConsentedUserData | undefined>;Type
type GetConsentedUserDataErrorCode =
| 'USER_DECLINED'
| 'UNAVAILABLE'
| 'TERMS_NOT_SET'
| 'INVALID_REQUEST'
| 'CANCELED'
| 'CONSENTED_USER_DATA_AGREEMENT_FAILED'
| 'CONSENTED_USER_DATA_INVALID_DATA';
interface GetConsentedUserDataOptions {
consentedUserDataKey: string;
shouldRequestAgreementWhenUserDeclined?: boolean;
}
type ConsentedUserDataKey =
| 'USER_NAME'
| 'USER_GENDER'
| 'USER_NATIONALITY'
| 'USER_BIRTHDAY'
| 'USER_PHONE'
| 'USER_ADDRESS'
| 'USER_EMAIL'
| 'USER_CONSUMPTION_HISTORY';
type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;Parameters
options · Required ·
GetConsentedUserDataOptionsThe options used when requesting consent-based user data.
options.consentedUserDataKey · Required ·
stringThe key used by the server to find the user data consent text and data bundle. For example:
cud_deliveryoptions.shouldRequestAgreementWhenUserDeclined ·
booleanUSER_DECLINEDWhether to show the terms webview again in the USER_DECLINED state. The default isfalse.
Return value
Promise<ConsentedUserData | undefined>Returns the user data provided by the server. If the Toss app version is
5.264.0less thanundefinedis returned.
ConsentedUserDataonly the keys corresponding to the requested items may be included.
USER_NAME
User name
USER_GENDER
User gender
USER_NATIONALITY
Whether domestic or foreign
USER_BIRTHDAY
User date of birth
USER_PHONE
User mobile phone number
USER_ADDRESS
User home address
Because it isn't required when signing up for Toss, there may be no value, and in that case it is passed as null.
USER_EMAIL
User email address
Because it isn't required when signing up for Toss, there may be no value, and in that case it is passed as null.
Error code
getConsentedUserData If the call fails, the error codes below may be returned.
USER_DECLINED
This is the case when the user explicitly declined and there is no retry request option, or when they declined in the terms webview.
UNAVAILABLE
This is the case when the server cannot determine whether the user has consented.
TERMS_NOT_SET
This is the case when the mini app does not have the user data provision consent text set.
INVALID_REQUEST
consentedUserDataKeyis empty, or termsUrlis missing, or it is not an HTTPS company domain.
CANCELED
This is the case when the terms webview is closed before sending the result.
CONSENTED_USER_DATA_AGREEMENT_FAILED
An error occurred while processing the terms webview.
CONSENTED_USER_DATA_INVALID_DATA
PROVIDEDbut datais missing, or after successful consent the re-query result is PROVIDEDnot
Example
Notes
USER_ADDRESS,USER_EMAILIf the user has not registered with Toss,nullit is passed as null. Please be sure to handle null.If the user wants to withdraw consent, Toss app → Settings → Terms and Privacy Policy Consent → mini app nameyou can withdraw each item individually.
Last updated
Was this helpful?