github.com/stripe/stripe-go/v76@v76.25.0/mandate.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 mandate includes the type of customer acceptance information, such as: `online` or `offline`.
    12  type MandateCustomerAcceptanceType string
    13  
    14  // List of values that MandateCustomerAcceptanceType can take
    15  const (
    16  	MandateCustomerAcceptanceTypeOffline MandateCustomerAcceptanceType = "offline"
    17  	MandateCustomerAcceptanceTypeOnline  MandateCustomerAcceptanceType = "online"
    18  )
    19  
    20  // List of Stripe products where this mandate can be selected automatically.
    21  type MandatePaymentMethodDetailsACSSDebitDefaultFor string
    22  
    23  // List of values that MandatePaymentMethodDetailsACSSDebitDefaultFor can take
    24  const (
    25  	MandatePaymentMethodDetailsACSSDebitDefaultForInvoice      MandatePaymentMethodDetailsACSSDebitDefaultFor = "invoice"
    26  	MandatePaymentMethodDetailsACSSDebitDefaultForSubscription MandatePaymentMethodDetailsACSSDebitDefaultFor = "subscription"
    27  )
    28  
    29  // Payment schedule for the mandate.
    30  type MandatePaymentMethodDetailsACSSDebitPaymentSchedule string
    31  
    32  // List of values that MandatePaymentMethodDetailsACSSDebitPaymentSchedule can take
    33  const (
    34  	MandatePaymentMethodDetailsACSSDebitPaymentScheduleCombined MandatePaymentMethodDetailsACSSDebitPaymentSchedule = "combined"
    35  	MandatePaymentMethodDetailsACSSDebitPaymentScheduleInterval MandatePaymentMethodDetailsACSSDebitPaymentSchedule = "interval"
    36  	MandatePaymentMethodDetailsACSSDebitPaymentScheduleSporadic MandatePaymentMethodDetailsACSSDebitPaymentSchedule = "sporadic"
    37  )
    38  
    39  // Transaction type of the mandate.
    40  type MandatePaymentMethodDetailsACSSDebitTransactionType string
    41  
    42  // List of values that MandatePaymentMethodDetailsACSSDebitTransactionType can take
    43  const (
    44  	MandatePaymentMethodDetailsACSSDebitTransactionTypeBusiness MandatePaymentMethodDetailsACSSDebitTransactionType = "business"
    45  	MandatePaymentMethodDetailsACSSDebitTransactionTypePersonal MandatePaymentMethodDetailsACSSDebitTransactionType = "personal"
    46  )
    47  
    48  // The status of the mandate on the Bacs network. Can be one of `pending`, `revoked`, `refused`, or `accepted`.
    49  type MandatePaymentMethodDetailsBACSDebitNetworkStatus string
    50  
    51  // List of values that MandatePaymentMethodDetailsBACSDebitNetworkStatus can take
    52  const (
    53  	MandatePaymentMethodDetailsBACSDebitNetworkStatusAccepted MandatePaymentMethodDetailsBACSDebitNetworkStatus = "accepted"
    54  	MandatePaymentMethodDetailsBACSDebitNetworkStatusPending  MandatePaymentMethodDetailsBACSDebitNetworkStatus = "pending"
    55  	MandatePaymentMethodDetailsBACSDebitNetworkStatusRefused  MandatePaymentMethodDetailsBACSDebitNetworkStatus = "refused"
    56  	MandatePaymentMethodDetailsBACSDebitNetworkStatusRevoked  MandatePaymentMethodDetailsBACSDebitNetworkStatus = "revoked"
    57  )
    58  
    59  // When the mandate is revoked on the Bacs network this field displays the reason for the revocation.
    60  type MandatePaymentMethodDetailsBACSDebitRevocationReason string
    61  
    62  // List of values that MandatePaymentMethodDetailsBACSDebitRevocationReason can take
    63  const (
    64  	MandatePaymentMethodDetailsBACSDebitRevocationReasonAccountClosed         MandatePaymentMethodDetailsBACSDebitRevocationReason = "account_closed"
    65  	MandatePaymentMethodDetailsBACSDebitRevocationReasonBankAccountRestricted MandatePaymentMethodDetailsBACSDebitRevocationReason = "bank_account_restricted"
    66  	MandatePaymentMethodDetailsBACSDebitRevocationReasonBankOwnershipChanged  MandatePaymentMethodDetailsBACSDebitRevocationReason = "bank_ownership_changed"
    67  	MandatePaymentMethodDetailsBACSDebitRevocationReasonCouldNotProcess       MandatePaymentMethodDetailsBACSDebitRevocationReason = "could_not_process"
    68  	MandatePaymentMethodDetailsBACSDebitRevocationReasonDebitNotAuthorized    MandatePaymentMethodDetailsBACSDebitRevocationReason = "debit_not_authorized"
    69  )
    70  
    71  // This mandate corresponds with a specific payment method type. The `payment_method_details` includes an additional hash with the same name and contains mandate information that's specific to that payment method.
    72  type MandatePaymentMethodDetailsType string
    73  
    74  // List of values that MandatePaymentMethodDetailsType can take
    75  const (
    76  	MandatePaymentMethodDetailsTypeACSSDebit     MandatePaymentMethodDetailsType = "acss_debit"
    77  	MandatePaymentMethodDetailsTypeAUBECSDebit   MandatePaymentMethodDetailsType = "au_becs_debit"
    78  	MandatePaymentMethodDetailsTypeBACSDebit     MandatePaymentMethodDetailsType = "bacs_debit"
    79  	MandatePaymentMethodDetailsTypeBLIK          MandatePaymentMethodDetailsType = "blik"
    80  	MandatePaymentMethodDetailsTypeCard          MandatePaymentMethodDetailsType = "card"
    81  	MandatePaymentMethodDetailsTypeLink          MandatePaymentMethodDetailsType = "link"
    82  	MandatePaymentMethodDetailsTypeSEPADebit     MandatePaymentMethodDetailsType = "sepa_debit"
    83  	MandatePaymentMethodDetailsTypeUSBankAccount MandatePaymentMethodDetailsType = "us_bank_account"
    84  )
    85  
    86  // Mandate collection method
    87  type MandatePaymentMethodDetailsUSBankAccountCollectionMethod string
    88  
    89  // List of values that MandatePaymentMethodDetailsUSBankAccountCollectionMethod can take
    90  const (
    91  	MandatePaymentMethodDetailsUSBankAccountCollectionMethodPaper MandatePaymentMethodDetailsUSBankAccountCollectionMethod = "paper"
    92  )
    93  
    94  // The mandate status indicates whether or not you can use it to initiate a payment.
    95  type MandateStatus string
    96  
    97  // List of values that MandateStatus can take
    98  const (
    99  	MandateStatusActive   MandateStatus = "active"
   100  	MandateStatusInactive MandateStatus = "inactive"
   101  	MandateStatusPending  MandateStatus = "pending"
   102  )
   103  
   104  // The type of the mandate.
   105  type MandateType string
   106  
   107  // List of values that MandateType can take
   108  const (
   109  	MandateTypeMultiUse  MandateType = "multi_use"
   110  	MandateTypeSingleUse MandateType = "single_use"
   111  )
   112  
   113  // Retrieves a Mandate object.
   114  type MandateParams struct {
   115  	Params `form:"*"`
   116  	// Specifies which fields in the response should be expanded.
   117  	Expand []*string `form:"expand"`
   118  }
   119  
   120  // AddExpand appends a new field to expand.
   121  func (p *MandateParams) AddExpand(f string) {
   122  	p.Expand = append(p.Expand, &f)
   123  }
   124  
   125  type MandateCustomerAcceptanceOffline struct{}
   126  type MandateCustomerAcceptanceOnline struct {
   127  	// The customer accepts the mandate from this IP address.
   128  	IPAddress string `json:"ip_address"`
   129  	// The customer accepts the mandate using the user agent of the browser.
   130  	UserAgent string `json:"user_agent"`
   131  }
   132  type MandateCustomerAcceptance struct {
   133  	// The time that the customer accepts the mandate.
   134  	AcceptedAt int64                             `json:"accepted_at"`
   135  	Offline    *MandateCustomerAcceptanceOffline `json:"offline"`
   136  	Online     *MandateCustomerAcceptanceOnline  `json:"online"`
   137  	// The mandate includes the type of customer acceptance information, such as: `online` or `offline`.
   138  	Type MandateCustomerAcceptanceType `json:"type"`
   139  }
   140  type MandateMultiUse struct{}
   141  type MandatePaymentMethodDetailsACSSDebit struct {
   142  	// List of Stripe products where this mandate can be selected automatically.
   143  	DefaultFor []MandatePaymentMethodDetailsACSSDebitDefaultFor `json:"default_for"`
   144  	// Description of the interval. Only required if the 'payment_schedule' parameter is 'interval' or 'combined'.
   145  	IntervalDescription string `json:"interval_description"`
   146  	// Payment schedule for the mandate.
   147  	PaymentSchedule MandatePaymentMethodDetailsACSSDebitPaymentSchedule `json:"payment_schedule"`
   148  	// Transaction type of the mandate.
   149  	TransactionType MandatePaymentMethodDetailsACSSDebitTransactionType `json:"transaction_type"`
   150  }
   151  type MandatePaymentMethodDetailsAUBECSDebit struct {
   152  	// The URL of the mandate. This URL generally contains sensitive information about the customer and should be shared with them exclusively.
   153  	URL string `json:"url"`
   154  }
   155  type MandatePaymentMethodDetailsBACSDebit struct {
   156  	// The status of the mandate on the Bacs network. Can be one of `pending`, `revoked`, `refused`, or `accepted`.
   157  	NetworkStatus MandatePaymentMethodDetailsBACSDebitNetworkStatus `json:"network_status"`
   158  	// The unique reference identifying the mandate on the Bacs network.
   159  	Reference string `json:"reference"`
   160  	// When the mandate is revoked on the Bacs network this field displays the reason for the revocation.
   161  	RevocationReason MandatePaymentMethodDetailsBACSDebitRevocationReason `json:"revocation_reason"`
   162  	// The URL that will contain the mandate that the customer has signed.
   163  	URL string `json:"url"`
   164  }
   165  type MandatePaymentMethodDetailsCard struct{}
   166  type MandatePaymentMethodDetailsCashApp struct{}
   167  type MandatePaymentMethodDetailsLink struct{}
   168  type MandatePaymentMethodDetailsPaypal struct {
   169  	// The PayPal Billing Agreement ID (BAID). This is an ID generated by PayPal which represents the mandate between the merchant and the customer.
   170  	BillingAgreementID string `json:"billing_agreement_id"`
   171  	// PayPal account PayerID. This identifier uniquely identifies the PayPal customer.
   172  	PayerID string `json:"payer_id"`
   173  }
   174  type MandatePaymentMethodDetailsSEPADebit struct {
   175  	// The unique reference of the mandate.
   176  	Reference string `json:"reference"`
   177  	// The URL of the mandate. This URL generally contains sensitive information about the customer and should be shared with them exclusively.
   178  	URL string `json:"url"`
   179  }
   180  type MandatePaymentMethodDetailsUSBankAccount struct {
   181  	// Mandate collection method
   182  	CollectionMethod MandatePaymentMethodDetailsUSBankAccountCollectionMethod `json:"collection_method"`
   183  }
   184  type MandatePaymentMethodDetails struct {
   185  	ACSSDebit   *MandatePaymentMethodDetailsACSSDebit   `json:"acss_debit"`
   186  	AUBECSDebit *MandatePaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
   187  	BACSDebit   *MandatePaymentMethodDetailsBACSDebit   `json:"bacs_debit"`
   188  	Card        *MandatePaymentMethodDetailsCard        `json:"card"`
   189  	CashApp     *MandatePaymentMethodDetailsCashApp     `json:"cashapp"`
   190  	Link        *MandatePaymentMethodDetailsLink        `json:"link"`
   191  	Paypal      *MandatePaymentMethodDetailsPaypal      `json:"paypal"`
   192  	SEPADebit   *MandatePaymentMethodDetailsSEPADebit   `json:"sepa_debit"`
   193  	// This mandate corresponds with a specific payment method type. The `payment_method_details` includes an additional hash with the same name and contains mandate information that's specific to that payment method.
   194  	Type          MandatePaymentMethodDetailsType           `json:"type"`
   195  	USBankAccount *MandatePaymentMethodDetailsUSBankAccount `json:"us_bank_account"`
   196  }
   197  type MandateSingleUse struct {
   198  	// The amount of the payment on a single use mandate.
   199  	Amount int64 `json:"amount"`
   200  	// The currency of the payment on a single use mandate.
   201  	Currency Currency `json:"currency"`
   202  }
   203  
   204  // A Mandate is a record of the permission that your customer gives you to debit their payment method.
   205  type Mandate struct {
   206  	APIResource
   207  	CustomerAcceptance *MandateCustomerAcceptance `json:"customer_acceptance"`
   208  	// Unique identifier for the object.
   209  	ID string `json:"id"`
   210  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
   211  	Livemode bool             `json:"livemode"`
   212  	MultiUse *MandateMultiUse `json:"multi_use"`
   213  	// String representing the object's type. Objects of the same type share the same value.
   214  	Object string `json:"object"`
   215  	// The account (if any) that the mandate is intended for.
   216  	OnBehalfOf string `json:"on_behalf_of"`
   217  	// ID of the payment method associated with this mandate.
   218  	PaymentMethod        *PaymentMethod               `json:"payment_method"`
   219  	PaymentMethodDetails *MandatePaymentMethodDetails `json:"payment_method_details"`
   220  	SingleUse            *MandateSingleUse            `json:"single_use"`
   221  	// The mandate status indicates whether or not you can use it to initiate a payment.
   222  	Status MandateStatus `json:"status"`
   223  	// The type of the mandate.
   224  	Type MandateType `json:"type"`
   225  }
   226  
   227  // UnmarshalJSON handles deserialization of a Mandate.
   228  // This custom unmarshaling is needed because the resulting
   229  // property may be an id or the full struct if it was expanded.
   230  func (m *Mandate) UnmarshalJSON(data []byte) error {
   231  	if id, ok := ParseID(data); ok {
   232  		m.ID = id
   233  		return nil
   234  	}
   235  
   236  	type mandate Mandate
   237  	var v mandate
   238  	if err := json.Unmarshal(data, &v); err != nil {
   239  		return err
   240  	}
   241  
   242  	*m = Mandate(v)
   243  	return nil
   244  }