示例#1
0
func TestBitcoinTransactionList(t *testing.T) {
	bitcoinReceiverParams := &stripe.BitcoinReceiverParams{
		Amount:   1000,
		Currency: currency.USD,
		Email:    "*****@*****.**",
		Desc:     "some details",
	}

	r, _ := bitcoinreceiver.New(bitcoinReceiverParams)

	params := &stripe.BitcoinTransactionListParams{
		Receiver: r.ID,
	}
	params.Filters.AddFilter("limit", "", "5")
	params.Single = true

	i := List(params)
	for i.Next() {
		if i.BitcoinTransaction() == 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)
	}
}
示例#2
0
func TestChargeSourceForBitcoinReceiver(t *testing.T) {
	bitcoinReceiverParams := &stripe.BitcoinReceiverParams{
		Amount:   1000,
		Currency: currency.USD,
		Email:    "*****@*****.**",
		Desc:     "some details",
	}

	receiver, _ := bitcoinreceiver.New(bitcoinReceiverParams)

	chargeParams := &stripe.ChargeParams{
		Amount:   1000,
		Currency: currency.USD,
		Email:    "*****@*****.**",
	}

	chargeParams.SetSource(receiver.ID)

	ch, _ := New(chargeParams)

	if len(ch.ID) == 0 {
		t.Error("ID is nil for Charge")
	}

	if ch.Source == nil {
		t.Error("Source is nil for Charge, should be BitcoinReceiver property")
	}

	if ch.Source.Type != stripe.PaymentSourceBitcoinReceiver {
		t.Error("Source Type for Charge created by BitcoinReceiver should be `bitcoin_receiver`")
	}

	rreceiver := ch.Source.BitcoinReceiver

	if len(rreceiver.ID) == 0 {
		t.Error("Source ID is nil for Charge `source` BitcoinReceiver property")
	}

	if rreceiver.Amount == 0 {
		t.Error("Amount is empty for Charge `source` BitcoinReceiver property")
	}

	if rreceiver.Display() != "Filled bitcoin receiver (1000/1000 usd)" {
		t.Error("Display value did not match expectation")
	}
}