本文整理汇总了Golang中github.com/stripe/stripe-go/token.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAccountUpdateWithToken
func TestAccountUpdateWithToken(t *testing.T) {
params := &stripe.AccountParams{
Managed: true,
Country: "CA",
}
acct, _ := New(params)
tokenParams := &stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Routing: "110000000",
Account: "000123456789",
},
}
tok, _ := token.New(tokenParams)
params = &stripe.AccountParams{
ExternalAccount: &stripe.AccountExternalAccountParams{
Token: tok.ID,
},
}
_, err := Update(acct.ID, params)
if err != nil {
t.Error(err)
}
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:29,代码来源:client_test.go
示例2: TestAccountUpdateWithCardToken
func TestAccountUpdateWithCardToken(t *testing.T) {
params := &stripe.AccountParams{
Managed: true,
Country: "US",
}
acct, _ := New(params)
tokenParams := &stripe.TokenParams{
Card: &stripe.CardParams{
Number: "4000056655665556",
Month: "06",
Year: "20",
Currency: "usd",
},
}
tok, _ := token.New(tokenParams)
cardParams := &stripe.CardParams{
Account: acct.ID,
Token: tok.ID,
}
c, err := card.New(cardParams)
if err != nil {
t.Error(err)
}
if c.Currency != currency.USD {
t.Errorf("Currency %v does not match expected value %v\n", c.Currency, currency.USD)
}
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:34,代码来源:client_test.go
示例3: TestBankAccountListByCustomer
func TestBankAccountListByCustomer(t *testing.T) {
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
AccountHolderName: "Jane Austen",
AccountHolderType: "individual",
},
})
if err != nil {
t.Error(err)
}
customerParams := &stripe.CustomerParams{}
customerParams.SetSource(baTok.ID)
cust, _ := customer.New(customerParams)
if err != nil {
t.Error(err)
}
iter := List(&stripe.BankAccountListParams{Customer: cust.ID})
if iter.Err() != nil {
t.Error(err)
}
if !iter.Next() {
t.Errorf("Expected to find one bank account in list\n")
}
Del(cust.DefaultSource.ID, &stripe.BankAccountParams{Customer: cust.ID})
customer.Del(cust.ID)
}
开发者ID:captain401,项目名称:stripe-go,代码行数:33,代码来源:client_test.go
示例4: TestBankAccountDel
func TestBankAccountDel(t *testing.T) {
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
AccountHolderName: "Jane Austen",
AccountHolderType: "individual",
},
})
if err != nil {
t.Error(err)
}
customerParams := &stripe.CustomerParams{}
customerParams.SetSource(baTok.ID)
cust, _ := customer.New(customerParams)
if err != nil {
t.Error(err)
}
baDel, err := Del(cust.DefaultSource.ID, &stripe.BankAccountParams{Customer: cust.ID})
if err != nil {
t.Error(err)
}
if !baDel.Deleted {
t.Errorf("Bank account id %q expected to be marked as deleted on the returned resource\n", baDel.ID)
}
customer.Del(cust.ID)
}
开发者ID:captain401,项目名称:stripe-go,代码行数:33,代码来源:client_test.go
示例5: TestAccountAddExternalAccountsDefault
func TestAccountAddExternalAccountsDefault(t *testing.T) {
params := &stripe.AccountParams{
Managed: true,
Country: "CA",
ExternalAccount: &stripe.AccountExternalAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
},
}
acct, _ := New(params)
ba, err := bankaccount.New(&stripe.BankAccountParams{
AccountID: acct.ID,
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000111111116",
Default: true,
})
if err != nil {
t.Error(err)
}
if ba.Default == false {
t.Error("The new external account should be the default but isn't.")
}
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000333333335",
},
})
if err != nil {
t.Error(err)
}
ba2, err := bankaccount.New(&stripe.BankAccountParams{
AccountID: acct.ID,
Token: baTok.ID,
Default: true,
})
if err != nil {
t.Error(err)
}
if ba2.Default == false {
t.Error("The third external account should be the default but isn't.")
}
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:57,代码来源:client_test.go
示例6: TestSourceBankAccountVerify
func TestSourceBankAccountVerify(t *testing.T) {
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
AccountHolderName: "Jane Austen",
AccountHolderType: "individual",
},
})
if baTok.Bank.AccountHolderName != "Jane Austen" {
t.Errorf("Bank account name %q was not Jane Austen as expected.", baTok.Bank.AccountHolderName)
}
if err != nil {
t.Error(err)
}
customerParams := &stripe.CustomerParams{}
cust, err := customer.New(customerParams)
if err != nil {
t.Error(err)
}
source, err := New(&stripe.CustomerSourceParams{
Customer: cust.ID,
Source: &stripe.SourceParams{
Token: baTok.ID,
},
})
amounts := [2]uint8{32, 45}
verifyParams := &stripe.SourceVerifyParams{
Customer: cust.ID,
Amounts: amounts,
}
sourceVerified, err := Verify(source.ID, verifyParams)
if err != nil {
t.Error(err)
return
}
target := sourceVerified.BankAccount
if target.Status != bankaccount.VerifiedAccount {
t.Errorf("Status (%q) does not match expected (%q) ", target.Status, bankaccount.VerifiedAccount)
}
customer.Del(cust.ID)
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:55,代码来源:client_test.go
示例7: TestSourceBankAccountDel
func TestSourceBankAccountDel(t *testing.T) {
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
AccountHolderName: "Jane Austen",
AccountHolderType: "individual",
},
})
if baTok.Bank.AccountHolderName != "Jane Austen" {
t.Errorf("Bank account name %q was not Jane Austen as expected.", baTok.Bank.AccountHolderName)
}
if err != nil {
t.Error(err)
}
customerParams := &stripe.CustomerParams{}
customer, err := customer.New(customerParams)
if err != nil {
t.Error(err)
}
source, err := New(&stripe.CustomerSourceParams{
Customer: customer.ID,
Source: &stripe.SourceParams{
Token: baTok.ID,
},
})
sourceDel, err := Del(source.ID, &stripe.CustomerSourceParams{Customer: customer.ID})
if !sourceDel.Deleted {
t.Errorf("Source id %q expected to be marked as deleted on the returned resource\n", sourceDel.ID)
}
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:39,代码来源:client_test.go
示例8: TestSourceBankAccountGet
func TestSourceBankAccountGet(t *testing.T) {
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
AccountHolderName: "Jane Austen",
AccountHolderType: "individual",
},
})
if baTok.Bank.AccountHolderName != "Jane Austen" {
t.Errorf("Bank account token name %q was not Jane Austen as expected.", baTok.Bank.AccountHolderName)
}
if err != nil {
t.Error(err)
}
customerParams := &stripe.CustomerParams{}
customer, err := customer.New(customerParams)
if err != nil {
t.Error(err)
}
src, err := New(&stripe.CustomerSourceParams{
Customer: customer.ID,
Source: &stripe.SourceParams{
Token: baTok.ID,
},
})
source, err := Get(src.ID, &stripe.CustomerSourceParams{Customer: customer.ID})
if source.BankAccount.AccountHolderName != "Jane Austen" {
t.Errorf("Bank account name %q was not Jane Austen as expected.", source.BankAccount.Name)
}
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:39,代码来源:client_test.go
示例9: TestBankAccountListByAccount
func TestBankAccountListByAccount(t *testing.T) {
baTok, err := token.New(&stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Currency: "usd",
Routing: "110000000",
Account: "000123456789",
AccountHolderName: "Jane Austen",
AccountHolderType: "individual",
},
})
if err != nil {
t.Error(err)
}
accountParams := &stripe.AccountParams{
Managed: true,
Country: "CA",
ExternalAccount: &stripe.AccountExternalAccountParams{
Token: baTok.ID,
},
}
acct, err := account.New(accountParams)
if err != nil {
t.Error(err)
}
iter := List(&stripe.BankAccountListParams{AccountID: acct.ID})
if iter.Err() != nil {
t.Error(err)
}
if !iter.Next() {
t.Errorf("Expected to find one bank account in list\n")
}
Del(baTok.ID, &stripe.BankAccountParams{AccountID: acct.ID})
account.Del(acct.ID)
}
开发者ID:captain401,项目名称:stripe-go,代码行数:38,代码来源:client_test.go
示例10: TestChargeNewWithToken
func TestChargeNewWithToken(t *testing.T) {
tokenParams := &stripe.TokenParams{
Card: &stripe.CardParams{
Number: "4242424242424242",
Month: "10",
Year: "20",
},
}
tok, _ := token.New(tokenParams)
chargeParams := &stripe.ChargeParams{
Amount: 1000,
Currency: currency.USD,
}
chargeParams.SetSource(tok.ID)
target, err := New(chargeParams)
if err != nil {
t.Error(err)
}
if target.Amount != chargeParams.Amount {
t.Errorf("Amount %v does not match expected amount %v\n", target.Amount, chargeParams.Amount)
}
if target.Currency != chargeParams.Currency {
t.Errorf("Currency %q does not match expected currency %q\n", target.Currency, chargeParams.Currency)
}
if target.Source.Card.ID != tok.Card.ID {
t.Errorf("Card Id %q doesn't match card id %q of token %q", target.Source.Card.ID, tok.Card.ID, tok.ID)
}
}
开发者ID:mousadialo,项目名称:stripe-go,代码行数:36,代码来源:client_test.go
示例11: TestCardNew
func TestCardNew(t *testing.T) {
customerParams := &stripe.CustomerParams{}
customerParams.SetSource(&stripe.CardParams{
Number: "378282246310005",
Month: "06",
Year: "20",
})
cust, _ := customer.New(customerParams)
cardParams := &stripe.CardParams{
Number: "4242424242424242",
Month: "10",
Year: "20",
Customer: cust.ID,
CVC: "1234",
}
target, err := New(cardParams)
if err != nil {
t.Error(err)
}
if target.LastFour != "4242" {
t.Errorf("Unexpected last four %q for card number %v\n", target.LastFour, cardParams.Number)
}
if target.Meta == nil || len(target.Meta) > 0 {
t.Errorf("Unexpected nil or non-empty metadata in card\n")
}
if target.Month != 10 {
t.Errorf("Unexpected expiration month %d for card where we set %q\n", target.Month, cardParams.Month)
}
if target.Year != 2020 {
t.Errorf("Unexpected expiration year %d for card where we set %q\n", target.Year, cardParams.Year)
}
if target.CVCCheck != Pass {
t.Errorf("CVC check %q does not match expected status\n", target.ZipCheck)
}
targetCust, err := customer.Get(cust.ID, nil)
if err != nil {
t.Error(err)
}
if targetCust.Sources.Count != 2 {
t.Errorf("Unexpected number of sources %v\n", targetCust.Sources.Count)
}
targetToken, err := token.New(&stripe.TokenParams{
Card: &stripe.CardParams{
Number: "4000056655665556",
Month: "09",
Year: "2021",
CVC: "123",
},
})
targetCard, err := New(&stripe.CardParams{
Customer: targetCust.ID,
Token: targetToken.ID,
})
if targetCard.LastFour != "5556" {
t.Errorf("Unexpected last four %q for card number %v\n", targetCard.LastFour, cardParams.Number)
}
if targetCard.Month != 9 {
t.Errorf("Unexpected expiration month %d for card where we set %q\n", targetCard.Month, targetToken.Card.Month)
}
if targetCard.Year != 2021 {
t.Errorf("Unexpected expiration year %d for card where we set %q\n", targetCard.Year, targetToken.Card.Year)
}
customer.Del(cust.ID)
}
开发者ID:captain401,项目名称:stripe-go,代码行数:82,代码来源:client_test.go
示例12: TestRecipientNewToken
func TestRecipientNewToken(t *testing.T) {
tokenParams := &stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Routing: "110000000",
Account: "000123456789",
},
}
tok, _ := token.New(tokenParams)
recipientParams := &stripe.RecipientParams{
Name: "Recipient Name",
Type: Individual,
TaxID: "000000000",
Email: "[email protected]",
Desc: "Recipient Desc",
Bank: &stripe.BankAccountParams{
Token: tok.ID,
},
Card: &stripe.CardParams{
Name: "Test Debit",
Number: "4000056655665556",
Month: "10",
Year: "20",
},
}
target, err := New(recipientParams)
if err != nil {
t.Error(err)
}
if target.Name != recipientParams.Name {
t.Errorf("Name %q does not match expected name %q\n", target.Name, recipientParams.Name)
}
if target.Type != recipientParams.Type {
t.Errorf("Type %q does not match expected type %q\n", target.Type, recipientParams.Type)
}
if target.Email != recipientParams.Email {
t.Errorf("Email %q does not match expected email %q\n", target.Email, recipientParams.Email)
}
if target.Desc != recipientParams.Desc {
t.Errorf("Description %q does not match expected description %q\n", target.Desc, recipientParams.Desc)
}
if target.Created == 0 {
t.Errorf("Created date is not set\n")
}
if target.Bank == nil {
t.Errorf("Bank account is not set\n")
}
if target.Bank.Country != tokenParams.Bank.Country {
t.Errorf("Bank country %q does not match expected country %q\n", target.Bank.Country, tokenParams.Bank.Country)
}
if target.Bank.Currency != currency.USD {
t.Errorf("Bank currency %q does not match expected value\n", target.Bank.Currency)
}
if target.Bank.LastFour != "6789" {
t.Errorf("Bank last four %q does not match expected value\n", target.Bank.LastFour)
}
if len(target.Bank.Name) == 0 {
t.Errorf("Bank name is not set\n")
}
if target.Cards == nil || target.Cards.Count != 1 {
t.Errorf("Recipient cards not set\n")
}
if len(target.DefaultCard.ID) == 0 {
t.Errorf("Recipient default card is not set\n")
}
Del(target.ID)
}
开发者ID:mousadialo,项目名称:stripe-go,代码行数:85,代码来源:client_test.go
示例13: TestRecipientUpdateBankAccount
func TestRecipientUpdateBankAccount(t *testing.T) {
tokenParams := &stripe.TokenParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Routing: "110000000",
Account: "000123456789",
},
}
tok, _ := token.New(tokenParams)
recipientParams := &stripe.RecipientParams{
Name: "Original Name",
Type: Individual,
Email: "[email protected]",
Desc: "Original Desc",
}
original, _ := New(recipientParams)
updateParamsToken := &stripe.RecipientParams{
Bank: &stripe.BankAccountParams{
Token: tok.ID,
},
}
target, err := Update(original.ID, updateParamsToken)
if err != nil {
t.Error(err)
}
if target.Bank == nil {
t.Errorf("Bank account is not set\n")
}
if target.Bank.Country != tokenParams.Bank.Country {
t.Errorf("Bank country %q does not match expected country %q\n", target.Bank.Country, tokenParams.Bank.Country)
}
if target.Bank.Currency != currency.USD {
t.Errorf("Bank currency %q does not match expected value\n", target.Bank.Currency)
}
if target.Bank.LastFour != "6789" {
t.Errorf("Bank last four %q does not match expected value\n", target.Bank.LastFour)
}
if len(target.Bank.Name) == 0 {
t.Errorf("Bank name is not set\n")
}
updateParamsBankAccount := &stripe.RecipientParams{
Bank: &stripe.BankAccountParams{
Country: "US",
Routing: "110000000",
Account: "000333333335",
},
}
target2, err := Update(original.ID, updateParamsBankAccount)
if err != nil {
t.Error(err)
}
if target2.Bank == nil {
t.Errorf("Bank account is not set\n")
}
if target2.Bank.Country != tokenParams.Bank.Country {
t.Errorf("Bank country %q does not match expected country %q\n", target2.Bank.Country, tokenParams.Bank.Country)
}
if target2.Bank.Currency != currency.USD {
t.Errorf("Bank currency %q does not match expected value\n", target2.Bank.Currency)
}
if target2.Bank.LastFour != "3335" {
t.Errorf("Bank last four %q does not match expected value\n", target2.Bank.LastFour)
}
if len(target2.Bank.Name) == 0 {
t.Errorf("Bank name is not set\n")
}
Del(target2.ID)
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:88,代码来源:client_test.go
注:本文中的github.com/stripe/stripe-go/token.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论