github.com/stripe/stripe-go/v76@v76.25.0/token/client_test.go (about) 1 package token 2 3 import ( 4 "testing" 5 6 assert "github.com/stretchr/testify/require" 7 stripe "github.com/stripe/stripe-go/v76" 8 _ "github.com/stripe/stripe-go/v76/testing" 9 ) 10 11 func TestTokenGet(t *testing.T) { 12 token, err := Get("tok_123", nil) 13 assert.Nil(t, err) 14 assert.NotNil(t, token) 15 } 16 17 func TestTokenNew_WithBankAccount(t *testing.T) { 18 token, err := New(&stripe.TokenParams{ 19 BankAccount: &stripe.BankAccountParams{ 20 Country: stripe.String("US"), 21 RoutingNumber: stripe.String("110000000"), 22 AccountNumber: stripe.String("000123456789"), 23 }, 24 }) 25 assert.Nil(t, err) 26 assert.NotNil(t, token) 27 } 28 29 func TestTokenNew_WithCard(t *testing.T) { 30 token, err := New(&stripe.TokenParams{ 31 Card: &stripe.CardParams{ 32 Number: stripe.String("4242424242424242"), // raw PAN as we're testing token creation 33 ExpMonth: stripe.String("10"), 34 ExpYear: stripe.String("20"), 35 }, 36 }) 37 assert.Nil(t, err) 38 assert.NotNil(t, token) 39 } 40 41 func TestTokenNew_WithPII(t *testing.T) { 42 token, err := New(&stripe.TokenParams{ 43 PII: &stripe.TokenPIIParams{ 44 IDNumber: stripe.String("000000000"), 45 }, 46 }) 47 assert.Nil(t, err) 48 assert.NotNil(t, token) 49 } 50 51 func TestTokenNew_SharedCustomerCard(t *testing.T) { 52 params := &stripe.TokenParams{ 53 Card: &stripe.CardParams{ 54 ID: "card_123", 55 }, 56 Customer: stripe.String("cus_123"), 57 } 58 params.SetStripeAccount("acct_123") 59 token, err := New(params) 60 assert.Nil(t, err) 61 assert.NotNil(t, token) 62 } 63 64 func TestTokenNew_WithAccount(t *testing.T) { 65 token, err := New(&stripe.TokenParams{ 66 Account: &stripe.TokenAccountParams{ 67 Individual: &stripe.PersonParams{ 68 FirstName: stripe.String("Jane"), 69 LastName: stripe.String("Doe"), 70 }, 71 TOSShownAndAccepted: stripe.Bool(true), 72 }, 73 }) 74 assert.Nil(t, err) 75 assert.NotNil(t, token) 76 } 77 78 func TestTokenNew_WithPerson(t *testing.T) { 79 token, err := New(&stripe.TokenParams{ 80 Person: &stripe.PersonParams{ 81 FirstName: stripe.String("Jane"), 82 LastName: stripe.String("Doe"), 83 Relationship: &stripe.PersonRelationshipParams{ 84 Owner: stripe.Bool(true), 85 }, 86 }, 87 }) 88 assert.Nil(t, err) 89 assert.NotNil(t, token) 90 }