github.com/stripe/stripe-go/v76@v76.25.0/issuing_token.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // The token service provider / card network associated with the token.
    12  type IssuingTokenNetwork string
    13  
    14  // List of values that IssuingTokenNetwork can take
    15  const (
    16  	IssuingTokenNetworkMastercard IssuingTokenNetwork = "mastercard"
    17  	IssuingTokenNetworkVisa       IssuingTokenNetwork = "visa"
    18  )
    19  
    20  // The type of device used for tokenization.
    21  type IssuingTokenNetworkDataDeviceType string
    22  
    23  // List of values that IssuingTokenNetworkDataDeviceType can take
    24  const (
    25  	IssuingTokenNetworkDataDeviceTypeOther IssuingTokenNetworkDataDeviceType = "other"
    26  	IssuingTokenNetworkDataDeviceTypePhone IssuingTokenNetworkDataDeviceType = "phone"
    27  	IssuingTokenNetworkDataDeviceTypeWatch IssuingTokenNetworkDataDeviceType = "watch"
    28  )
    29  
    30  // The network that the token is associated with. An additional hash is included with a name matching this value, containing tokenization data specific to the card network.
    31  type IssuingTokenNetworkDataType string
    32  
    33  // List of values that IssuingTokenNetworkDataType can take
    34  const (
    35  	IssuingTokenNetworkDataTypeMastercard IssuingTokenNetworkDataType = "mastercard"
    36  	IssuingTokenNetworkDataTypeVisa       IssuingTokenNetworkDataType = "visa"
    37  )
    38  
    39  // The method used for tokenizing a card.
    40  type IssuingTokenNetworkDataWalletProviderCardNumberSource string
    41  
    42  // List of values that IssuingTokenNetworkDataWalletProviderCardNumberSource can take
    43  const (
    44  	IssuingTokenNetworkDataWalletProviderCardNumberSourceApp    IssuingTokenNetworkDataWalletProviderCardNumberSource = "app"
    45  	IssuingTokenNetworkDataWalletProviderCardNumberSourceManual IssuingTokenNetworkDataWalletProviderCardNumberSource = "manual"
    46  	IssuingTokenNetworkDataWalletProviderCardNumberSourceOnFile IssuingTokenNetworkDataWalletProviderCardNumberSource = "on_file"
    47  	IssuingTokenNetworkDataWalletProviderCardNumberSourceOther  IssuingTokenNetworkDataWalletProviderCardNumberSource = "other"
    48  )
    49  
    50  // The reasons for suggested tokenization given by the card network.
    51  type IssuingTokenNetworkDataWalletProviderReasonCode string
    52  
    53  // List of values that IssuingTokenNetworkDataWalletProviderReasonCode can take
    54  const (
    55  	IssuingTokenNetworkDataWalletProviderReasonCodeAccountCardTooNew                       IssuingTokenNetworkDataWalletProviderReasonCode = "account_card_too_new"
    56  	IssuingTokenNetworkDataWalletProviderReasonCodeAccountRecentlyChanged                  IssuingTokenNetworkDataWalletProviderReasonCode = "account_recently_changed"
    57  	IssuingTokenNetworkDataWalletProviderReasonCodeAccountTooNew                           IssuingTokenNetworkDataWalletProviderReasonCode = "account_too_new"
    58  	IssuingTokenNetworkDataWalletProviderReasonCodeAccountTooNewSinceLaunch                IssuingTokenNetworkDataWalletProviderReasonCode = "account_too_new_since_launch"
    59  	IssuingTokenNetworkDataWalletProviderReasonCodeAdditionalDevice                        IssuingTokenNetworkDataWalletProviderReasonCode = "additional_device"
    60  	IssuingTokenNetworkDataWalletProviderReasonCodeDataExpired                             IssuingTokenNetworkDataWalletProviderReasonCode = "data_expired"
    61  	IssuingTokenNetworkDataWalletProviderReasonCodeDeferIDVDecision                        IssuingTokenNetworkDataWalletProviderReasonCode = "defer_id_v_decision"
    62  	IssuingTokenNetworkDataWalletProviderReasonCodeDeviceRecentlyLost                      IssuingTokenNetworkDataWalletProviderReasonCode = "device_recently_lost"
    63  	IssuingTokenNetworkDataWalletProviderReasonCodeGoodActivityHistory                     IssuingTokenNetworkDataWalletProviderReasonCode = "good_activity_history"
    64  	IssuingTokenNetworkDataWalletProviderReasonCodeHasSuspendedTokens                      IssuingTokenNetworkDataWalletProviderReasonCode = "has_suspended_tokens"
    65  	IssuingTokenNetworkDataWalletProviderReasonCodeHighRisk                                IssuingTokenNetworkDataWalletProviderReasonCode = "high_risk"
    66  	IssuingTokenNetworkDataWalletProviderReasonCodeInactiveAccount                         IssuingTokenNetworkDataWalletProviderReasonCode = "inactive_account"
    67  	IssuingTokenNetworkDataWalletProviderReasonCodeLongAccountTenure                       IssuingTokenNetworkDataWalletProviderReasonCode = "long_account_tenure"
    68  	IssuingTokenNetworkDataWalletProviderReasonCodeLowAccountScore                         IssuingTokenNetworkDataWalletProviderReasonCode = "low_account_score"
    69  	IssuingTokenNetworkDataWalletProviderReasonCodeLowDeviceScore                          IssuingTokenNetworkDataWalletProviderReasonCode = "low_device_score"
    70  	IssuingTokenNetworkDataWalletProviderReasonCodeLowPhoneNumberScore                     IssuingTokenNetworkDataWalletProviderReasonCode = "low_phone_number_score"
    71  	IssuingTokenNetworkDataWalletProviderReasonCodeNetworkServiceError                     IssuingTokenNetworkDataWalletProviderReasonCode = "network_service_error"
    72  	IssuingTokenNetworkDataWalletProviderReasonCodeOutsideHomeTerritory                    IssuingTokenNetworkDataWalletProviderReasonCode = "outside_home_territory"
    73  	IssuingTokenNetworkDataWalletProviderReasonCodeProvisioningCardholderMismatch          IssuingTokenNetworkDataWalletProviderReasonCode = "provisioning_cardholder_mismatch"
    74  	IssuingTokenNetworkDataWalletProviderReasonCodeProvisioningDeviceAndCardholderMismatch IssuingTokenNetworkDataWalletProviderReasonCode = "provisioning_device_and_cardholder_mismatch"
    75  	IssuingTokenNetworkDataWalletProviderReasonCodeProvisioningDeviceMismatch              IssuingTokenNetworkDataWalletProviderReasonCode = "provisioning_device_mismatch"
    76  	IssuingTokenNetworkDataWalletProviderReasonCodeSameDeviceNoPriorAuthentication         IssuingTokenNetworkDataWalletProviderReasonCode = "same_device_no_prior_authentication"
    77  	IssuingTokenNetworkDataWalletProviderReasonCodeSameDeviceSuccessfulPriorAuthentication IssuingTokenNetworkDataWalletProviderReasonCode = "same_device_successful_prior_authentication"
    78  	IssuingTokenNetworkDataWalletProviderReasonCodeSoftwareUpdate                          IssuingTokenNetworkDataWalletProviderReasonCode = "software_update"
    79  	IssuingTokenNetworkDataWalletProviderReasonCodeSuspiciousActivity                      IssuingTokenNetworkDataWalletProviderReasonCode = "suspicious_activity"
    80  	IssuingTokenNetworkDataWalletProviderReasonCodeTooManyDifferentCardholders             IssuingTokenNetworkDataWalletProviderReasonCode = "too_many_different_cardholders"
    81  	IssuingTokenNetworkDataWalletProviderReasonCodeTooManyRecentAttempts                   IssuingTokenNetworkDataWalletProviderReasonCode = "too_many_recent_attempts"
    82  	IssuingTokenNetworkDataWalletProviderReasonCodeTooManyRecentTokens                     IssuingTokenNetworkDataWalletProviderReasonCode = "too_many_recent_tokens"
    83  )
    84  
    85  // The recommendation on responding to the tokenization request.
    86  type IssuingTokenNetworkDataWalletProviderSuggestedDecision string
    87  
    88  // List of values that IssuingTokenNetworkDataWalletProviderSuggestedDecision can take
    89  const (
    90  	IssuingTokenNetworkDataWalletProviderSuggestedDecisionApprove     IssuingTokenNetworkDataWalletProviderSuggestedDecision = "approve"
    91  	IssuingTokenNetworkDataWalletProviderSuggestedDecisionDecline     IssuingTokenNetworkDataWalletProviderSuggestedDecision = "decline"
    92  	IssuingTokenNetworkDataWalletProviderSuggestedDecisionRequireAuth IssuingTokenNetworkDataWalletProviderSuggestedDecision = "require_auth"
    93  )
    94  
    95  // The usage state of the token.
    96  type IssuingTokenStatus string
    97  
    98  // List of values that IssuingTokenStatus can take
    99  const (
   100  	IssuingTokenStatusActive    IssuingTokenStatus = "active"
   101  	IssuingTokenStatusDeleted   IssuingTokenStatus = "deleted"
   102  	IssuingTokenStatusRequested IssuingTokenStatus = "requested"
   103  	IssuingTokenStatusSuspended IssuingTokenStatus = "suspended"
   104  )
   105  
   106  // The digital wallet for this token, if one was used.
   107  type IssuingTokenWalletProvider string
   108  
   109  // List of values that IssuingTokenWalletProvider can take
   110  const (
   111  	IssuingTokenWalletProviderApplePay   IssuingTokenWalletProvider = "apple_pay"
   112  	IssuingTokenWalletProviderGooglePay  IssuingTokenWalletProvider = "google_pay"
   113  	IssuingTokenWalletProviderSamsungPay IssuingTokenWalletProvider = "samsung_pay"
   114  )
   115  
   116  // Lists all Issuing Token objects for a given card.
   117  type IssuingTokenListParams struct {
   118  	ListParams `form:"*"`
   119  	// The Issuing card identifier to list tokens for.
   120  	Card *string `form:"card"`
   121  	// Only return Issuing tokens that were created during the given date interval.
   122  	Created *int64 `form:"created"`
   123  	// Only return Issuing tokens that were created during the given date interval.
   124  	CreatedRange *RangeQueryParams `form:"created"`
   125  	// Specifies which fields in the response should be expanded.
   126  	Expand []*string `form:"expand"`
   127  	// Select Issuing tokens with the given status.
   128  	Status *string `form:"status"`
   129  }
   130  
   131  // AddExpand appends a new field to expand.
   132  func (p *IssuingTokenListParams) AddExpand(f string) {
   133  	p.Expand = append(p.Expand, &f)
   134  }
   135  
   136  // Retrieves an Issuing Token object.
   137  type IssuingTokenParams struct {
   138  	Params `form:"*"`
   139  	// Specifies which fields in the response should be expanded.
   140  	Expand []*string `form:"expand"`
   141  	// Specifies which status the token should be updated to.
   142  	Status *string `form:"status"`
   143  }
   144  
   145  // AddExpand appends a new field to expand.
   146  func (p *IssuingTokenParams) AddExpand(f string) {
   147  	p.Expand = append(p.Expand, &f)
   148  }
   149  
   150  type IssuingTokenNetworkDataDevice struct {
   151  	// An obfuscated ID derived from the device ID.
   152  	DeviceFingerprint string `json:"device_fingerprint"`
   153  	// The IP address of the device at provisioning time.
   154  	IPAddress string `json:"ip_address"`
   155  	// The geographic latitude/longitude coordinates of the device at provisioning time. The format is [+-]decimal/[+-]decimal.
   156  	Location string `json:"location"`
   157  	// The name of the device used for tokenization.
   158  	Name string `json:"name"`
   159  	// The phone number of the device used for tokenization.
   160  	PhoneNumber string `json:"phone_number"`
   161  	// The type of device used for tokenization.
   162  	Type IssuingTokenNetworkDataDeviceType `json:"type"`
   163  }
   164  type IssuingTokenNetworkDataMastercard struct {
   165  	// A unique reference ID from MasterCard to represent the card account number.
   166  	CardReferenceID string `json:"card_reference_id"`
   167  	// The network-unique identifier for the token.
   168  	TokenReferenceID string `json:"token_reference_id"`
   169  	// The ID of the entity requesting tokenization, specific to MasterCard.
   170  	TokenRequestorID string `json:"token_requestor_id"`
   171  	// The name of the entity requesting tokenization, if known. This is directly provided from MasterCard.
   172  	TokenRequestorName string `json:"token_requestor_name"`
   173  }
   174  type IssuingTokenNetworkDataVisa struct {
   175  	// A unique reference ID from Visa to represent the card account number.
   176  	CardReferenceID string `json:"card_reference_id"`
   177  	// The network-unique identifier for the token.
   178  	TokenReferenceID string `json:"token_reference_id"`
   179  	// The ID of the entity requesting tokenization, specific to Visa.
   180  	TokenRequestorID string `json:"token_requestor_id"`
   181  	// Degree of risk associated with the token between `01` and `99`, with higher number indicating higher risk. A `00` value indicates the token was not scored by Visa.
   182  	TokenRiskScore string `json:"token_risk_score"`
   183  }
   184  type IssuingTokenNetworkDataWalletProviderCardholderAddress struct {
   185  	// The street address of the cardholder tokenizing the card.
   186  	Line1 string `json:"line1"`
   187  	// The postal code of the cardholder tokenizing the card.
   188  	PostalCode string `json:"postal_code"`
   189  }
   190  type IssuingTokenNetworkDataWalletProvider struct {
   191  	// The wallet provider-given account ID of the digital wallet the token belongs to.
   192  	AccountID string `json:"account_id"`
   193  	// An evaluation on the trustworthiness of the wallet account between 1 and 5. A higher score indicates more trustworthy.
   194  	AccountTrustScore int64                                                   `json:"account_trust_score"`
   195  	CardholderAddress *IssuingTokenNetworkDataWalletProviderCardholderAddress `json:"cardholder_address"`
   196  	// The name of the cardholder tokenizing the card.
   197  	CardholderName string `json:"cardholder_name"`
   198  	// The method used for tokenizing a card.
   199  	CardNumberSource IssuingTokenNetworkDataWalletProviderCardNumberSource `json:"card_number_source"`
   200  	// An evaluation on the trustworthiness of the device. A higher score indicates more trustworthy.
   201  	DeviceTrustScore int64 `json:"device_trust_score"`
   202  	// The hashed email address of the cardholder's account with the wallet provider.
   203  	HashedAccountEmailAddress string `json:"hashed_account_email_address"`
   204  	// The reasons for suggested tokenization given by the card network.
   205  	ReasonCodes []IssuingTokenNetworkDataWalletProviderReasonCode `json:"reason_codes"`
   206  	// The recommendation on responding to the tokenization request.
   207  	SuggestedDecision IssuingTokenNetworkDataWalletProviderSuggestedDecision `json:"suggested_decision"`
   208  	// The version of the standard for mapping reason codes followed by the wallet provider.
   209  	SuggestedDecisionVersion string `json:"suggested_decision_version"`
   210  }
   211  type IssuingTokenNetworkData struct {
   212  	Device     *IssuingTokenNetworkDataDevice     `json:"device"`
   213  	Mastercard *IssuingTokenNetworkDataMastercard `json:"mastercard"`
   214  	// The network that the token is associated with. An additional hash is included with a name matching this value, containing tokenization data specific to the card network.
   215  	Type           IssuingTokenNetworkDataType            `json:"type"`
   216  	Visa           *IssuingTokenNetworkDataVisa           `json:"visa"`
   217  	WalletProvider *IssuingTokenNetworkDataWalletProvider `json:"wallet_provider"`
   218  }
   219  
   220  // An issuing token object is created when an issued card is added to a digital wallet. As a [card issuer](https://stripe.com/docs/issuing), you can [view and manage these tokens](https://stripe.com/docs/issuing/controls/token-management) through Stripe.
   221  type IssuingToken struct {
   222  	APIResource
   223  	// Card associated with this token.
   224  	Card *IssuingCard `json:"card"`
   225  	// Time at which the object was created. Measured in seconds since the Unix epoch.
   226  	Created int64 `json:"created"`
   227  	// The hashed ID derived from the device ID from the card network associated with the token.
   228  	DeviceFingerprint string `json:"device_fingerprint"`
   229  	// Unique identifier for the object.
   230  	ID string `json:"id"`
   231  	// The last four digits of the token.
   232  	Last4 string `json:"last4"`
   233  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
   234  	Livemode bool `json:"livemode"`
   235  	// The token service provider / card network associated with the token.
   236  	Network     IssuingTokenNetwork      `json:"network"`
   237  	NetworkData *IssuingTokenNetworkData `json:"network_data"`
   238  	// Time at which the token was last updated by the card network. Measured in seconds since the Unix epoch.
   239  	NetworkUpdatedAt int64 `json:"network_updated_at"`
   240  	// String representing the object's type. Objects of the same type share the same value.
   241  	Object string `json:"object"`
   242  	// The usage state of the token.
   243  	Status IssuingTokenStatus `json:"status"`
   244  	// The digital wallet for this token, if one was used.
   245  	WalletProvider IssuingTokenWalletProvider `json:"wallet_provider"`
   246  }
   247  
   248  // IssuingTokenList is a list of Tokens as retrieved from a list endpoint.
   249  type IssuingTokenList struct {
   250  	APIResource
   251  	ListMeta
   252  	Data []*IssuingToken `json:"data"`
   253  }
   254  
   255  // UnmarshalJSON handles deserialization of an IssuingToken.
   256  // This custom unmarshaling is needed because the resulting
   257  // property may be an id or the full struct if it was expanded.
   258  func (i *IssuingToken) UnmarshalJSON(data []byte) error {
   259  	if id, ok := ParseID(data); ok {
   260  		i.ID = id
   261  		return nil
   262  	}
   263  
   264  	type issuingToken IssuingToken
   265  	var v issuingToken
   266  	if err := json.Unmarshal(data, &v); err != nil {
   267  		return err
   268  	}
   269  
   270  	*i = IssuingToken(v)
   271  	return nil
   272  }