Esempio n. 1
0
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)
}
Esempio n. 2
0
func TestTransferToAccount(t *testing.T) {
	chargeParams := &stripe.ChargeParams{
		Amount:   1000,
		Currency: currency.USD,
		Source: &stripe.SourceParams{
			Card: &stripe.CardParams{
				Number: "4000000000000077",
				Month:  "06",
				Year:   "20",
			},
		},
	}

	charge, err := charge.New(chargeParams)
	if err != nil {
		t.Error(err)
	}

	params := &stripe.AccountParams{
		Managed: true,
		Country: "US",
		LegalEntity: &stripe.LegalEntity{
			Type: stripe.Individual,
			DOB: stripe.DOB{
				Day:   1,
				Month: 2,
				Year:  1990,
			},
		},
	}

	acc, err := account.New(params)
	if err != nil {
		t.Error(err)
	}

	transferParams := &stripe.TransferParams{
		Amount:   100,
		Currency: currency.USD,
		Dest:     acc.ID,
		SourceTx: charge.ID,
	}

	target, err := New(transferParams)

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

	if target.Amount != transferParams.Amount {
		t.Errorf("Amount %v does not match expected amount %v\n", target.Amount, transferParams.Amount)
	}

	if target.Currency != transferParams.Currency {
		t.Errorf("Curency %q does not match expected currency %q\n", target.Currency, transferParams.Currency)
	}

	if target.Created == 0 {
		t.Errorf("Created date is not set\n")
	}

	if target.Date == 0 {
		t.Errorf("Date is not set\n")
	}

	if target.SourceTx != transferParams.SourceTx {
		t.Errorf("SourceTx %q does not match expected SourceTx %q\n", target.SourceTx, transferParams.SourceTx)
	}

	if target.Type != StripeAccount {
		t.Errorf("Unexpected type %q\n", target.Type)
	}

	account.Del(acc.ID)
}