1// Package client provides a Stripe client for invoking APIs across all resources 2package client 3 4import ( 5 stripe "github.com/stripe/stripe-go/v72" 6 "github.com/stripe/stripe-go/v72/account" 7 "github.com/stripe/stripe-go/v72/accountlink" 8 "github.com/stripe/stripe-go/v72/applepaydomain" 9 "github.com/stripe/stripe-go/v72/balance" 10 "github.com/stripe/stripe-go/v72/balancetransaction" 11 "github.com/stripe/stripe-go/v72/bankaccount" 12 billingportalconfiguration "github.com/stripe/stripe-go/v72/billingportal/configuration" 13 billingportalsession "github.com/stripe/stripe-go/v72/billingportal/session" 14 "github.com/stripe/stripe-go/v72/capability" 15 "github.com/stripe/stripe-go/v72/card" 16 "github.com/stripe/stripe-go/v72/charge" 17 checkoutsession "github.com/stripe/stripe-go/v72/checkout/session" 18 "github.com/stripe/stripe-go/v72/countryspec" 19 "github.com/stripe/stripe-go/v72/coupon" 20 "github.com/stripe/stripe-go/v72/creditnote" 21 "github.com/stripe/stripe-go/v72/customer" 22 "github.com/stripe/stripe-go/v72/customerbalancetransaction" 23 "github.com/stripe/stripe-go/v72/discount" 24 "github.com/stripe/stripe-go/v72/dispute" 25 "github.com/stripe/stripe-go/v72/ephemeralkey" 26 "github.com/stripe/stripe-go/v72/event" 27 "github.com/stripe/stripe-go/v72/fee" 28 "github.com/stripe/stripe-go/v72/feerefund" 29 "github.com/stripe/stripe-go/v72/file" 30 "github.com/stripe/stripe-go/v72/filelink" 31 "github.com/stripe/stripe-go/v72/identity/verificationreport" 32 "github.com/stripe/stripe-go/v72/identity/verificationsession" 33 "github.com/stripe/stripe-go/v72/invoice" 34 "github.com/stripe/stripe-go/v72/invoiceitem" 35 "github.com/stripe/stripe-go/v72/issuing/authorization" 36 issuingcard "github.com/stripe/stripe-go/v72/issuing/card" 37 "github.com/stripe/stripe-go/v72/issuing/cardholder" 38 issuingdispute "github.com/stripe/stripe-go/v72/issuing/dispute" 39 "github.com/stripe/stripe-go/v72/issuing/transaction" 40 "github.com/stripe/stripe-go/v72/loginlink" 41 "github.com/stripe/stripe-go/v72/mandate" 42 "github.com/stripe/stripe-go/v72/oauth" 43 "github.com/stripe/stripe-go/v72/order" 44 "github.com/stripe/stripe-go/v72/orderreturn" 45 "github.com/stripe/stripe-go/v72/paymentintent" 46 "github.com/stripe/stripe-go/v72/paymentmethod" 47 "github.com/stripe/stripe-go/v72/paymentsource" 48 "github.com/stripe/stripe-go/v72/payout" 49 "github.com/stripe/stripe-go/v72/person" 50 "github.com/stripe/stripe-go/v72/plan" 51 "github.com/stripe/stripe-go/v72/price" 52 "github.com/stripe/stripe-go/v72/product" 53 "github.com/stripe/stripe-go/v72/promotioncode" 54 "github.com/stripe/stripe-go/v72/radar/earlyfraudwarning" 55 "github.com/stripe/stripe-go/v72/radar/valuelist" 56 "github.com/stripe/stripe-go/v72/radar/valuelistitem" 57 "github.com/stripe/stripe-go/v72/refund" 58 "github.com/stripe/stripe-go/v72/reporting/reportrun" 59 "github.com/stripe/stripe-go/v72/reporting/reporttype" 60 "github.com/stripe/stripe-go/v72/reversal" 61 "github.com/stripe/stripe-go/v72/review" 62 "github.com/stripe/stripe-go/v72/setupattempt" 63 "github.com/stripe/stripe-go/v72/setupintent" 64 "github.com/stripe/stripe-go/v72/sigma/scheduledqueryrun" 65 "github.com/stripe/stripe-go/v72/sku" 66 "github.com/stripe/stripe-go/v72/source" 67 "github.com/stripe/stripe-go/v72/sourcetransaction" 68 "github.com/stripe/stripe-go/v72/sub" 69 "github.com/stripe/stripe-go/v72/subitem" 70 "github.com/stripe/stripe-go/v72/subschedule" 71 "github.com/stripe/stripe-go/v72/taxcode" 72 "github.com/stripe/stripe-go/v72/taxid" 73 "github.com/stripe/stripe-go/v72/taxrate" 74 terminalconnectiontoken "github.com/stripe/stripe-go/v72/terminal/connectiontoken" 75 terminallocation "github.com/stripe/stripe-go/v72/terminal/location" 76 terminalreader "github.com/stripe/stripe-go/v72/terminal/reader" 77 "github.com/stripe/stripe-go/v72/token" 78 "github.com/stripe/stripe-go/v72/topup" 79 "github.com/stripe/stripe-go/v72/transfer" 80 "github.com/stripe/stripe-go/v72/usagerecord" 81 "github.com/stripe/stripe-go/v72/usagerecordsummary" 82 "github.com/stripe/stripe-go/v72/webhookendpoint" 83) 84 85// API is the Stripe client. It contains all the different resources available. 86type API struct { 87 // Account is the client used to invoke /accounts APIs. 88 Account *account.Client 89 // AccountLink is the client used to invoke /account_links APIs. 90 AccountLinks *accountlink.Client 91 // ApplePayDomains is the client used to invoke /apple_pay/domains APIs. 92 ApplePayDomains *applepaydomain.Client 93 // Balance is the client used to invoke /balance APIs. 94 Balance *balance.Client 95 // BalanceTransaction is the client used to invoke /balance_transactions APIs. 96 BalanceTransaction *balancetransaction.Client 97 // BankAccounts is the client used to invoke bank account related APIs. 98 BankAccounts *bankaccount.Client 99 // BillingPortalSessions is the client used to invoke /billing_portal/sessions APIs. 100 BillingPortalSessions *billingportalsession.Client 101 // BillingPortalConfigurations is the client used to invoke /billing_portal/configurations APIs. 102 BillingPortalConfigurations *billingportalconfiguration.Client 103 // Capabilities is the client used to invoke capability related APIs. 104 Capabilities *capability.Client 105 // Cards is the client used to invoke card related APIs. 106 Cards *card.Client 107 // Charges is the client used to invoke /charges APIs. 108 Charges *charge.Client 109 // CheckoutSessions is the client used to invoke /checkout/sessions APIs. 110 CheckoutSessions *checkoutsession.Client 111 // CountrySpec is the client used to invoke /country_specs APIs. 112 CountrySpec *countryspec.Client 113 // Coupons is the client used to invoke /coupons APIs. 114 Coupons *coupon.Client 115 // CreditNotes is the client used to invoke /credit_notes APIs. 116 CreditNotes *creditnote.Client 117 // Customers is the client used to invoke /customers APIs. 118 Customers *customer.Client 119 // CustomerBalanceTransactions is the client used to invoke /customers/balance_transactions APIs. 120 CustomerBalanceTransactions *customerbalancetransaction.Client 121 // Discounts is the client used to invoke discount related APIs. 122 Discounts *discount.Client 123 // Disputes is the client used to invoke /disputes APIs. 124 Disputes *dispute.Client 125 // EphemeralKeys is the client used to invoke /ephemeral_keys APIs. 126 EphemeralKeys *ephemeralkey.Client 127 // Events is the client used to invoke /events APIs. 128 Events *event.Client 129 // Fees is the client used to invoke /application_fees APIs. 130 Fees *fee.Client 131 // FeeRefunds is the client used to invoke /application_fees/refunds APIs. 132 FeeRefunds *feerefund.Client 133 // Files is the client used to invoke the /files APIs. 134 Files *file.Client 135 // FileLinks is the client used to invoke the /file_links APIs. 136 FileLinks *filelink.Client 137 // IdentityVerificationReports is the client used to invoke the /identity/verification_reports APIs. 138 IdentityVerificationReports *verificationreport.Client 139 // IdentityVerificationSessions is the client used to invoke the /identity/verification_sessions APIs. 140 IdentityVerificationSessions *verificationsession.Client 141 // Invoices is the client used to invoke /invoices APIs. 142 Invoices *invoice.Client 143 // InvoiceItems is the client used to invoke /invoiceitems APIs. 144 InvoiceItems *invoiceitem.Client 145 // IssuingAuthorizations is the client used to invoke /issuing/authorizations APIs. 146 IssuingAuthorizations *authorization.Client 147 // IssuingCardholders is the client used to invoke /issuing/cardholders APIs. 148 IssuingCardholders *cardholder.Client 149 // IssuingCards is the client used to invoke /issuing/cards APIs. 150 IssuingCards *issuingcard.Client 151 // IssuingDisputes is the client used to invoke /issuing/disputes APIs. 152 IssuingDisputes *issuingdispute.Client 153 // IssuingTransactions is the client used to invoke /issuing/transactions APIs. 154 IssuingTransactions *transaction.Client 155 // LoginLinks is the client used to invoke login link related APIs. 156 LoginLinks *loginlink.Client 157 // Mandates is the client used to invoke mandates related APIs. 158 Mandates *mandate.Client 159 // OAuth is the client used to invoke /oauth APIs. 160 OAuth *oauth.Client 161 // Orders is the client used to invoke /orders APIs. 162 Orders *order.Client 163 // OrderReturns is the client used to invoke /order_returns APIs. 164 OrderReturns *orderreturn.Client 165 // PaymentIntents is the client used to invoke /payment_intents APIs. 166 PaymentIntents *paymentintent.Client 167 // PaymentMethods is the client used to invoke /payment_methods APIs. 168 PaymentMethods *paymentmethod.Client 169 // PaymentSource is used to invoke customer sources related APIs. 170 PaymentSource *paymentsource.Client 171 // Payouts is the client used to invoke /payouts APIs. 172 Payouts *payout.Client 173 // Persons is the client used to invoke /account/persons APIs. 174 Persons *person.Client 175 // Plans is the client used to invoke /plans APIs. 176 Plans *plan.Client 177 // Prices is the client used to invoke /prices APIs. 178 Prices *price.Client 179 // Products is the client used to invoke /products APIs. 180 Products *product.Client 181 // PromotionCodes is the client used to invoke /promotion_codes APIs. 182 PromotionCodes *promotioncode.Client 183 // RadarEarlyFraudWarnings is the client used to invoke /radar/early_fraud_warnings APIs. 184 RadarEarlyFraudWarnings *earlyfraudwarning.Client 185 // RadarValueLists is the client used to invoke /radar/value_lists APIs. 186 RadarValueLists *valuelist.Client 187 // RadarValueListItems is the client used to invoke /radar/value_list_items APIs. 188 RadarValueListItems *valuelistitem.Client 189 // Refunds is the client used to invoke /refunds APIs. 190 Refunds *refund.Client 191 // ReportRuns is the client used to invoke /reporting/report_runs APIs. 192 ReportRuns *reportrun.Client 193 // ReportTypes is the client used to invoke /reporting/report_types APIs. 194 ReportTypes *reporttype.Client 195 // Reversals is the client used to invoke /transfers/reversals APIs. 196 Reversals *reversal.Client 197 // Reviews is the client used to invoke /reviews APIs. 198 Reviews *review.Client 199 // SetupAttempts is the client used to invoke /setup_attempts APIs. 200 SetupAttempts *setupattempt.Client 201 // SetupIntents is the client used to invoke /setup_intents APIs. 202 SetupIntents *setupintent.Client 203 // SigmaScheduledQueryRuns is the client used to invoke /sigma/scheduled_query_runs APIs. 204 SigmaScheduledQueryRuns *scheduledqueryrun.Client 205 // Skus is the client used to invoke /skus APIs. 206 Skus *sku.Client 207 // Sources is the client used to invoke /sources APIs. 208 Sources *source.Client 209 // SourceTransactions is the client used to invoke source transaction related APIs. 210 SourceTransactions *sourcetransaction.Client 211 // Subscriptions is the client used to invoke /subscriptions APIs. 212 Subscriptions *sub.Client 213 // SubscriptionItems is the client used to invoke subscription's items related APIs. 214 SubscriptionItems *subitem.Client 215 // SubscriptionSchedules is the client used to invoke subscription schedules related APIs. 216 SubscriptionSchedules *subschedule.Client 217 // TaxIDs is the client used to invoke /tax_ids APIs. 218 TaxIDs *taxid.Client 219 // TaxCodes is the client used to invoke /tax_codes APIs. 220 TaxCodes *taxcode.Client 221 // TaxRates is the client used to invoke /tax_rates APIs. 222 TaxRates *taxrate.Client 223 // TerminalConnectionTokens is the client used to invoke /terminal/connectiontokens related APIs. 224 TerminalConnectionTokens *terminalconnectiontoken.Client 225 // TerminalLocations is the client used to invoke /terminal/locations related APIs. 226 TerminalLocations *terminallocation.Client 227 // TerminalReaders is the client used to invoke /terminal/readers related APIs. 228 TerminalReaders *terminalreader.Client 229 // Tokens is the client used to invoke /tokens APIs. 230 Tokens *token.Client 231 // Topups is the client used to invoke /tokens APIs. 232 Topups *topup.Client 233 // Transfers is the client used to invoke /transfers APIs. 234 Transfers *transfer.Client 235 // UsageRecords is the client used to invoke usage record related APIs. 236 UsageRecords *usagerecord.Client 237 // UsageRecordsummaries is the client used to invoke usage record summary related APIs. 238 UsageRecordSummaries *usagerecordsummary.Client 239 // WebhookEndpoints is the client used to invoke usage record related APIs. 240 WebhookEndpoints *webhookendpoint.Client 241} 242 243// Init initializes the Stripe client with the appropriate secret key 244// as well as providing the ability to override the backend as needed. 245func (a *API) Init(key string, backends *stripe.Backends) { 246 if backends == nil { 247 backends = &stripe.Backends{ 248 API: stripe.GetBackend(stripe.APIBackend), 249 Connect: stripe.GetBackend(stripe.ConnectBackend), 250 Uploads: stripe.GetBackend(stripe.UploadsBackend), 251 } 252 } 253 254 a.Account = &account.Client{B: backends.API, Key: key} 255 a.ApplePayDomains = &applepaydomain.Client{B: backends.API, Key: key} 256 a.AccountLinks = &accountlink.Client{B: backends.API, Key: key} 257 a.Balance = &balance.Client{B: backends.API, Key: key} 258 a.BalanceTransaction = &balancetransaction.Client{B: backends.API, Key: key} 259 a.BankAccounts = &bankaccount.Client{B: backends.API, Key: key} 260 a.BillingPortalSessions = &billingportalsession.Client{B: backends.API, Key: key} 261 a.BillingPortalConfigurations = &billingportalconfiguration.Client{B: backends.API, Key: key} 262 a.Capabilities = &capability.Client{B: backends.API, Key: key} 263 a.Cards = &card.Client{B: backends.API, Key: key} 264 a.Charges = &charge.Client{B: backends.API, Key: key} 265 a.CheckoutSessions = &checkoutsession.Client{B: backends.API, Key: key} 266 a.CountrySpec = &countryspec.Client{B: backends.API, Key: key} 267 a.Coupons = &coupon.Client{B: backends.API, Key: key} 268 a.CreditNotes = &creditnote.Client{B: backends.API, Key: key} 269 a.Customers = &customer.Client{B: backends.API, Key: key} 270 a.CustomerBalanceTransactions = &customerbalancetransaction.Client{B: backends.API, Key: key} 271 a.Discounts = &discount.Client{B: backends.API, Key: key} 272 a.Disputes = &dispute.Client{B: backends.API, Key: key} 273 a.EphemeralKeys = &ephemeralkey.Client{B: backends.API, Key: key} 274 a.Events = &event.Client{B: backends.API, Key: key} 275 a.Fees = &fee.Client{B: backends.API, Key: key} 276 a.FeeRefunds = &feerefund.Client{B: backends.API, Key: key} 277 a.Files = &file.Client{B: backends.Uploads, Key: key} 278 a.FileLinks = &filelink.Client{B: backends.API, Key: key} 279 a.IdentityVerificationReports = &verificationreport.Client{B: backends.API, Key: key} 280 a.IdentityVerificationSessions = &verificationsession.Client{B: backends.API, Key: key} 281 a.Invoices = &invoice.Client{B: backends.API, Key: key} 282 a.InvoiceItems = &invoiceitem.Client{B: backends.API, Key: key} 283 a.IssuingAuthorizations = &authorization.Client{B: backends.API, Key: key} 284 a.IssuingCardholders = &cardholder.Client{B: backends.API, Key: key} 285 a.IssuingCards = &issuingcard.Client{B: backends.API, Key: key} 286 a.IssuingDisputes = &issuingdispute.Client{B: backends.API, Key: key} 287 a.IssuingTransactions = &transaction.Client{B: backends.API, Key: key} 288 a.LoginLinks = &loginlink.Client{B: backends.API, Key: key} 289 a.Mandates = &mandate.Client{B: backends.API, Key: key} 290 a.OAuth = &oauth.Client{B: backends.Connect, Key: key} 291 a.OrderReturns = &orderreturn.Client{B: backends.API, Key: key} 292 a.Orders = &order.Client{B: backends.API, Key: key} 293 a.PaymentIntents = &paymentintent.Client{B: backends.API, Key: key} 294 a.PaymentMethods = &paymentmethod.Client{B: backends.API, Key: key} 295 a.PaymentSource = &paymentsource.Client{B: backends.API, Key: key} 296 a.Payouts = &payout.Client{B: backends.API, Key: key} 297 a.Persons = &person.Client{B: backends.API, Key: key} 298 a.Plans = &plan.Client{B: backends.API, Key: key} 299 a.Prices = &price.Client{B: backends.API, Key: key} 300 a.Products = &product.Client{B: backends.API, Key: key} 301 a.PromotionCodes = &promotioncode.Client{B: backends.API, Key: key} 302 a.RadarEarlyFraudWarnings = &earlyfraudwarning.Client{B: backends.API, Key: key} 303 a.RadarValueLists = &valuelist.Client{B: backends.API, Key: key} 304 a.RadarValueListItems = &valuelistitem.Client{B: backends.API, Key: key} 305 a.Refunds = &refund.Client{B: backends.API, Key: key} 306 a.ReportRuns = &reportrun.Client{B: backends.API, Key: key} 307 a.ReportTypes = &reporttype.Client{B: backends.API, Key: key} 308 a.Reversals = &reversal.Client{B: backends.API, Key: key} 309 a.Reviews = &review.Client{B: backends.API, Key: key} 310 a.SetupAttempts = &setupattempt.Client{B: backends.API, Key: key} 311 a.SetupIntents = &setupintent.Client{B: backends.API, Key: key} 312 a.SigmaScheduledQueryRuns = &scheduledqueryrun.Client{B: backends.API, Key: key} 313 a.Skus = &sku.Client{B: backends.API, Key: key} 314 a.Sources = &source.Client{B: backends.API, Key: key} 315 a.SourceTransactions = &sourcetransaction.Client{B: backends.API, Key: key} 316 a.Subscriptions = &sub.Client{B: backends.API, Key: key} 317 a.SubscriptionItems = &subitem.Client{B: backends.API, Key: key} 318 a.SubscriptionSchedules = &subschedule.Client{B: backends.API, Key: key} 319 a.TaxIDs = &taxid.Client{B: backends.API, Key: key} 320 a.TaxCodes = &taxcode.Client{B: backends.API, Key: key} 321 a.TaxRates = &taxrate.Client{B: backends.API, Key: key} 322 a.TerminalConnectionTokens = &terminalconnectiontoken.Client{B: backends.API, Key: key} 323 a.TerminalLocations = &terminallocation.Client{B: backends.API, Key: key} 324 a.TerminalReaders = &terminalreader.Client{B: backends.API, Key: key} 325 a.Tokens = &token.Client{B: backends.API, Key: key} 326 a.Topups = &topup.Client{B: backends.API, Key: key} 327 a.Transfers = &transfer.Client{B: backends.API, Key: key} 328 a.UsageRecords = &usagerecord.Client{B: backends.API, Key: key} 329 a.UsageRecordSummaries = &usagerecordsummary.Client{B: backends.API, Key: key} 330 a.WebhookEndpoints = &webhookendpoint.Client{B: backends.API, Key: key} 331} 332 333// New creates a new Stripe client with the appropriate secret key 334// as well as providing the ability to override the backends as needed. 335func New(key string, backends *stripe.Backends) *API { 336 api := API{} 337 api.Init(key, backends) 338 return &api 339} 340