github.com/stripe/stripe-go/v76@v76.25.0/setupintent/client_test.go (about) 1 package setupintent 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 TestSetupIntentCancel(t *testing.T) { 12 intent, err := Cancel("seti_123", &stripe.SetupIntentCancelParams{ 13 CancellationReason: stripe.String(string(stripe.SetupIntentCancellationReasonRequestedByCustomer)), 14 }) 15 assert.Nil(t, err) 16 assert.NotNil(t, intent) 17 } 18 19 func TestSetupIntentConfirm(t *testing.T) { 20 intent, err := Confirm("seti_123", &stripe.SetupIntentConfirmParams{ 21 ReturnURL: stripe.String("https://stripe.com/return"), 22 }) 23 assert.Nil(t, err) 24 assert.NotNil(t, intent) 25 } 26 27 func TestSetupIntentGet(t *testing.T) { 28 intent, err := Get("seti_123", nil) 29 assert.Nil(t, err) 30 assert.NotNil(t, intent) 31 } 32 33 func TestSetupIntentList(t *testing.T) { 34 i := List(&stripe.SetupIntentListParams{}) 35 36 // Verify that we can get at least one setup intent 37 assert.True(t, i.Next()) 38 assert.Nil(t, i.Err()) 39 assert.NotNil(t, i.SetupIntent()) 40 assert.NotNil(t, i.SetupIntentList()) 41 } 42 43 func TestSetupIntentNew(t *testing.T) { 44 intent, err := New(&stripe.SetupIntentParams{ 45 Customer: stripe.String("cus_123"), 46 PaymentMethodTypes: stripe.StringSlice([]string{ 47 "card", 48 }), 49 }) 50 assert.Nil(t, err) 51 assert.NotNil(t, intent) 52 } 53 54 func TestSetupIntentUpdate(t *testing.T) { 55 intent, err := Update("seti_123", &stripe.SetupIntentParams{ 56 Params: stripe.Params{ 57 Metadata: map[string]string{ 58 "foo": "bar", 59 }, 60 }, 61 }) 62 assert.Nil(t, err) 63 assert.NotNil(t, intent) 64 }