func TestSourceNew(t *testing.T) { customerParams := &stripe.CustomerParams{} cust, err := customer.New(customerParams) if err != nil { t.Error(err) } sourceParams := &stripe.CustomerSourceParams{ Customer: cust.ID, } sourceParams.SetSource(&stripe.CardParams{ Number: "4242424242424242", Month: "10", Year: "20", CVC: "1234", }) source, err := New(sourceParams) if err != nil { t.Error(err) } target := source.Card if target.LastFour != "4242" { t.Errorf("Unexpected last four %q for card number %v\n", target.LastFour, sourceParams.Source.Card.Number) } if target.CVCCheck != card.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 != 1 { t.Errorf("Unexpected number of sources %v\n", targetCust.Sources.Count) } customer.Del(cust.ID) }
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.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) } customer.Del(cust.ID) }