当前位置: 首页>>代码示例>>Golang>>正文


Golang customer.Del函数代码示例

本文整理汇总了Golang中github.com/stripe/stripe-go/customer.Del函数的典型用法代码示例。如果您正苦于以下问题:Golang Del函数的具体用法?Golang Del怎么用?Golang Del使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Del函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestSourceCardGet

func TestSourceCardGet(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Email: "[email protected]",
	}
	customerParams.SetSource(&stripe.CardParams{
		Number: "4242424242424242",
		Month:  "06",
		Year:   "20",
	})
	cust, err := customer.New(customerParams)

	if err != nil {
		t.Error(err)
	}

	source, err := Get(cust.DefaultSource.ID, &stripe.CustomerSourceParams{Customer: cust.ID})

	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, customerParams.Source.Card.Number)
	}

	if target.Brand != card.Visa {
		t.Errorf("Card brand %q does not match expected value\n", target.Brand)
	}

	customer.Del(cust.ID)
}
开发者ID:carriercomm,项目名称:stripe-go,代码行数:33,代码来源:client_test.go

示例2: TestCardUpdate

func TestCardUpdate(t *testing.T) {
	customerParams := &stripe.CustomerParams{}
	customerParams.SetSource(&stripe.CardParams{
		Number: "378282246310005",
		Month:  "06",
		Year:   "20",
		Name:   "Original Name",
	})

	cust, err := customer.New(customerParams)

	if err != nil {
		t.Error(err)
	}

	cardParams := &stripe.CardParams{
		Customer: cust.ID,
		Name:     "Updated Name",
	}

	target, err := Update(cust.DefaultSource.ID, cardParams)

	if err != nil {
		t.Error(err)
	}

	if target.Name != cardParams.Name {
		t.Errorf("Card name %q does not match expected name %q\n", target.Name, cardParams.Name)
	}

	customer.Del(cust.ID)
}
开发者ID:mousadialo,项目名称:stripe-go,代码行数:32,代码来源: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: TestCardList

func TestCardList(t *testing.T) {
	customerParams := &stripe.CustomerParams{}
	customerParams.SetSource(&stripe.CardParams{
		Number: "378282246310005",
		Month:  "06",
		Year:   "20",
	})

	cust, _ := customer.New(customerParams)

	card := &stripe.CardParams{
		Number:   "4242424242424242",
		Month:    "10",
		Year:     "20",
		Customer: cust.ID,
	}

	New(card)

	i := List(&stripe.CardListParams{Customer: cust.ID})
	for i.Next() {
		if i.Card() == nil {
			t.Error("No nil values expected")
		}

		if i.Meta() == nil {
			t.Error("No metadata returned")
		}
	}
	if err := i.Err(); err != nil {
		t.Error(err)
	}

	customer.Del(cust.ID)
}
开发者ID:captain401,项目名称:stripe-go,代码行数:35,代码来源:client_test.go

示例6: TestSubscriptionNew

func TestSubscriptionNew(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, _ := customer.New(customerParams)

	planParams := &stripe.PlanParams{
		ID:       "test",
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	plan.New(planParams)

	subParams := &stripe.SubParams{
		Customer:           cust.ID,
		Plan:               "test",
		Quantity:           10,
		TaxPercent:         20.0,
		BillingCycleAnchor: time.Now().AddDate(0, 0, 12).Unix(),
	}

	target, err := New(subParams)

	if err != nil {
		t.Error(err)
	}

	if target.Plan.ID != subParams.Plan {
		t.Errorf("Plan %v does not match expected plan %v\n", target.Plan, subParams.Plan)
	}

	if target.Quantity != subParams.Quantity {
		t.Errorf("Quantity %v does not match expected quantity %v\n", target.Quantity, subParams.Quantity)
	}

	if target.TaxPercent != subParams.TaxPercent {
		t.Errorf("TaxPercent %f does not match expected TaxPercent %f\n", target.TaxPercent, subParams.TaxPercent)
	}

	if target.PeriodEnd != subParams.BillingCycleAnchor {
		t.Errorf("PeriodEnd %v does not match expected BillingCycleAnchor %v\n", target.PeriodEnd, subParams.BillingCycleAnchor)
	}

	customer.Del(cust.ID)
	plan.Del("test")
}
开发者ID:captain401,项目名称:stripe-go,代码行数:56,代码来源:client_test.go

示例7: createSubItem

func createSubItem(t *testing.T) (*stripe.Sub, *stripe.SubItem, func()) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, err := customer.New(customerParams)
	if err != nil {
		t.Fatalf("customer creation: %s", err)
	}

	planID := fmt.Sprintf("test-%d", rand.Int63())
	planParams := &stripe.PlanParams{
		ID:       planID,
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	p, err := plan.New(planParams)
	if err != nil {
		t.Fatalf("plan creation: %s", err)
	}

	subParams := &stripe.SubParams{
		Customer: cust.ID,
		Items: []*stripe.SubItemsParams{
			{
				Plan:     p.ID,
				Quantity: 1,
			},
		},
	}

	target, err := sub.New(subParams)
	if err != nil {
		t.Fatalf("subscription creation: %s", err)
	}
	if target.Items == nil {
		t.Fatalf("no items for sub %s", target.ID)
	}
	if len(target.Items.Values) != 1 {
		t.Fatalf("missing items: %#v", target)
	}
	return target, target.Items.Values[0], func() {
		sub.Cancel(target.ID, nil)
		plan.Del(p.ID)
		customer.Del(cust.ID)
	}
}
开发者ID:captain401,项目名称:stripe-go,代码行数:56,代码来源:client_test.go

示例8: 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

示例9: TestSubscriptionUpdate

func TestSubscriptionUpdate(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, _ := customer.New(customerParams)

	planParams := &stripe.PlanParams{
		ID:       "test",
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	plan.New(planParams)

	subParams := &stripe.SubParams{
		Customer:    cust.ID,
		Plan:        "test",
		Quantity:    10,
		TrialEndNow: true,
	}

	subscription, _ := New(subParams)
	updatedSub := &stripe.SubParams{
		Customer:   cust.ID,
		NoProrate:  true,
		Quantity:   13,
		TaxPercent: 20.0,
	}

	target, err := Update(subscription.ID, updatedSub)

	if err != nil {
		t.Error(err)
	}

	if target.Quantity != updatedSub.Quantity {
		t.Errorf("Quantity %v does not match expected quantity %v\n", target.Quantity, updatedSub.Quantity)
	}

	if target.TaxPercent != updatedSub.TaxPercent {
		t.Errorf("TaxPercent %f does not match expected tax_percent %f\n", target.TaxPercent, updatedSub.TaxPercent)
	}

	customer.Del(cust.ID)
	plan.Del("test")
}
开发者ID:zkirill,项目名称:stripe-go,代码行数:55,代码来源:client_test.go

示例10: TestSubscriptionCancel

func TestSubscriptionCancel(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, _ := customer.New(customerParams)

	planParams := &stripe.PlanParams{
		ID:       "test",
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	plan.New(planParams)

	subParams := &stripe.SubParams{
		Customer: cust.ID,
		Plan:     "test",
		Quantity: 10,
	}

	subscription, _ := New(subParams)
	s, err := Cancel(subscription.ID, nil)

	if err != nil {
		t.Error(err)
	}

	if s.Canceled == 0 {
		t.Errorf("Subscription.Canceled %v expected to be non 0\n", s.Canceled)
	}

	subscription, _ = New(subParams)
	s, err = Cancel(subscription.ID, &stripe.SubParams{Customer: cust.ID})

	if err != nil {
		t.Error(err)
	}

	if s.Canceled == 0 {
		t.Errorf("Subscription.Canceled %v expected to be non 0\n", s.Canceled)
	}

	customer.Del(cust.ID)
	plan.Del("test")
}
开发者ID:captain401,项目名称:stripe-go,代码行数:54,代码来源:client_test.go

示例11: TestSubscriptionGet

func TestSubscriptionGet(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, _ := customer.New(customerParams)

	planParams := &stripe.PlanParams{
		ID:       "test",
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	plan.New(planParams)

	subParams := &stripe.SubParams{
		Customer: cust.ID,
		Plan:     "test",
		Quantity: 10,
	}

	subscription, _ := New(subParams)
	target, err := Get(subscription.ID, nil)

	if err != nil {
		t.Error(err)
	}

	if target.ID != subscription.ID {
		t.Errorf("Subscription id %q does not match expected id %q\n", target.ID, subscription.ID)
	}

	target, err = Get(subscription.ID, &stripe.SubParams{Customer: cust.ID})

	if err != nil {
		t.Error(err)
	}

	if target.ID != subscription.ID {
		t.Errorf("Subscription id %q does not match expected id %q\n", target.ID, subscription.ID)
	}

	customer.Del(cust.ID)
	plan.Del("test")
}
开发者ID:captain401,项目名称:stripe-go,代码行数:53,代码来源:client_test.go

示例12: ExampleCustomer_delete

func ExampleCustomer_delete() {
	stripe.Key = "sk_key"

	customerDel, err := customer.Del("cus_example_id")

	if err != nil {
		log.Fatal(err)
	}

	if !c.Deleted {
		log.Fatal("Customer doesn't appear deleted while it should be")
	}
}
开发者ID:yoyowallet,项目名称:stripe-go,代码行数:13,代码来源:example_test.go

示例13: TestSubscriptionZeroQuantity

func TestSubscriptionZeroQuantity(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, _ := customer.New(customerParams)

	planParams := &stripe.PlanParams{
		ID:       "test",
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	plan.New(planParams)

	subParams := &stripe.SubParams{
		Customer:       cust.ID,
		Plan:           "test",
		QuantityZero:   true,
		TaxPercentZero: true,
	}

	target, err := New(subParams)

	if err != nil {
		t.Error(err)
	}

	if target.Plan.ID != subParams.Plan {
		t.Errorf("Plan %v does not match expected plan %v\n", target.Plan, subParams.Plan)
	}

	if target.Quantity != 0 {
		t.Errorf("Quantity %v does not match expected quantity %v\n", target.Quantity, 0)
	}

	if target.TaxPercent != 0 {
		t.Errorf("Tax percent %v does not match expected tax percent %v\n", target.TaxPercent, 0)
	}

	customer.Del(cust.ID)
	plan.Del("test")
}
开发者ID:captain401,项目名称:stripe-go,代码行数:51,代码来源:client_test.go

示例14: TestSubscriptionList

func TestSubscriptionList(t *testing.T) {
	customerParams := &stripe.CustomerParams{
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "378282246310005",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	cust, _ := customer.New(customerParams)

	planParams := &stripe.PlanParams{
		ID:       "test",
		Name:     "Test Plan",
		Amount:   99,
		Currency: currency.USD,
		Interval: plan.Month,
	}

	plan.New(planParams)

	subParams := &stripe.SubParams{
		Customer: cust.ID,
		Plan:     "test",
		Quantity: 10,
	}

	for i := 0; i < 5; i++ {
		New(subParams)
	}

	i := List(&stripe.SubListParams{Customer: cust.ID})
	for i.Next() {
		if i.Sub() == nil {
			t.Error("No nil values expected")
		}

		if i.Meta() == nil {
			t.Error("No metadata returned")
		}
	}
	if err := i.Err(); err != nil {
		t.Error(err)
	}

	customer.Del(cust.ID)
	plan.Del("test")
}
开发者ID:zkirill,项目名称:stripe-go,代码行数:50,代码来源:client_test.go

示例15: TestSourceVerify

func TestSourceVerify(t *testing.T) {
	bankAccountParams := &stripe.BankAccountParams{
		Country:  "US",
		Currency: "usd",
		Routing:  "110000000",
		Account:  "000123456789",
	}
	tokenParams := &stripe.TokenParams{
		Bank: bankAccountParams,
	}
	token, err := token.New(tokenParams)

	if err != nil {
		t.Error(err)
		return
	}

	customerParams := &stripe.CustomerParams{}
	customerParams.SetSource(token.ID)

	cust, err := customer.New(customerParams)

	if err != nil {
		t.Error(err)
		return
	}

	amounts := [2]uint8{32, 45}

	verifyParams := &stripe.SourceVerifyParams{
		Customer: cust.ID,
		Amounts:  amounts,
	}

	source, err := Verify(cust.DefaultSource.ID, verifyParams)

	if err != nil {
		t.Error(err)
		return
	}

	target := source.BankAccount

	if target.Status != bankaccount.VerifiedAccount {
		t.Errorf("Status (%q) does not match expected (%q) ", target.Status, bankaccount.VerifiedAccount)
	}

	customer.Del(cust.ID)
}
开发者ID:mousadialo,项目名称:stripe-go,代码行数:49,代码来源:client_test.go


注:本文中的github.com/stripe/stripe-go/customer.Del函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。