當前位置: 首頁>>代碼示例>>Golang>>正文


Golang BankAccountParams.AppendTo方法代碼示例

本文整理匯總了Golang中github.com/stripe/stripe-go.BankAccountParams.AppendTo方法的典型用法代碼示例。如果您正苦於以下問題:Golang BankAccountParams.AppendTo方法的具體用法?Golang BankAccountParams.AppendTo怎麽用?Golang BankAccountParams.AppendTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/stripe/stripe-go.BankAccountParams的用法示例。


在下文中一共展示了BankAccountParams.AppendTo方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: New

func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, error) {

	body := &url.Values{}

	// Use token (if exists) or a dictionary containing a user’s bank account details.
	if len(params.Token) > 0 {
		body.Add("external_account", params.Token)
	} else {
		body.Add("external_account[object]", "bank_account")
		body.Add("external_account[country]", params.Country)
		body.Add("external_account[account_number]", params.Account)
		body.Add("external_account[routing_number]", params.Routing)
		body.Add("external_account[currency]", params.Currency)

		if params.Default {
			body.Add("external_account[default_for_currency]", strconv.FormatBool(params.Default))
		}
	}
	params.AppendTo(body)

	ba := &stripe.BankAccount{}
	err := c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts", params.AccountID), c.Key, body, &params.Params, ba)

	return ba, err
}
開發者ID:outdoorsy,項目名稱:stripe-go,代碼行數:25,代碼來源:client.go

示例2: Update

func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
	var body *stripe.RequestValues
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &stripe.RequestValues{}

		if params.Default {
			body.Add("default_for_currency", strconv.FormatBool(params.Default))
		}

		params.AppendTo(body)
	}

	ba := &stripe.BankAccount{}
	var err error

	if len(params.Customer) > 0 {
		err = c.B.Call("POST", fmt.Sprintf("/customers/%v/bank_accounts/%v", params.Customer, id), c.Key, body, commonParams, ba)
	} else if len(params.AccountID) > 0 {
		err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)
	} else {
		err = errors.New("Invalid bank account params: either Customer or AccountID need to be set")
	}

	return ba, err
}
開發者ID:captain401,項目名稱:stripe-go,代碼行數:28,代碼來源:client.go

示例3: New

func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, error) {

	body := &stripe.RequestValues{}
	isCustomer := len(params.Customer) > 0

	var sourceType string
	if isCustomer {
		sourceType = "source"
	} else {
		sourceType = "external_account"
	}

	// Use token (if exists) or a dictionary containing a user’s bank account details.
	if len(params.Token) > 0 {
		body.Add(sourceType, params.Token)

		if params.Default {
			body.Add("default_for_currency", strconv.FormatBool(params.Default))
		}
	} else {
		body.Add(sourceType+"[object]", "bank_account")
		body.Add(sourceType+"[country]", params.Country)
		body.Add(sourceType+"[account_number]", params.Account)
		body.Add(sourceType+"[currency]", params.Currency)

		if isCustomer {
			body.Add(sourceType+"[account_holder_name]", params.AccountHolderName)
			body.Add(sourceType+"[account_holder_type]", params.AccountHolderType)
		}

		if len(params.Routing) > 0 {
			body.Add(sourceType+"[routing_number]", params.Routing)
		}

		if params.Default {
			body.Add(sourceType+"[default_for_currency]", strconv.FormatBool(params.Default))
		}
	}
	params.AppendTo(body)

	ba := &stripe.BankAccount{}
	var err error
	if isCustomer {
		err = c.B.Call("POST", fmt.Sprintf("/customers/%v/sources", params.Customer), c.Key, body, &params.Params, ba)
	} else {
		err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts", params.AccountID), c.Key, body, &params.Params, ba)
	}

	return ba, err
}
開發者ID:captain401,項目名稱:stripe-go,代碼行數:50,代碼來源:client.go

示例4: Get

func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
	var body *url.Values
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &url.Values{}
		params.AppendTo(body)
	}

	ba := &stripe.BankAccount{}
	err := c.B.Call("GET", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)

	return ba, err
}
開發者ID:outdoorsy,項目名稱:stripe-go,代碼行數:15,代碼來源:client.go

示例5: Update

func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
	var body *url.Values
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &url.Values{}

		if params.Default {
			body.Add("default_for_currency", strconv.FormatBool(params.Default))
		}

		params.AppendTo(body)
	}

	ba := &stripe.BankAccount{}
	err := c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)

	return ba, err
}
開發者ID:outdoorsy,項目名稱:stripe-go,代碼行數:20,代碼來源:client.go

示例6: Get

func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
	var body *stripe.RequestValues
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &stripe.RequestValues{}
		params.AppendTo(body)
	}

	ba := &stripe.BankAccount{}
	var err error

	if len(params.Customer) > 0 {
		err = c.B.Call("GET", fmt.Sprintf("/customers/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)
	} else if len(params.AccountID) > 0 {
		err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)
	} else {
		err = errors.New("Invalid bank account params: either Customer or AccountID need to be set")
	}

	return ba, err
}
開發者ID:captain401,項目名稱:stripe-go,代碼行數:23,代碼來源:client.go


注:本文中的github.com/stripe/stripe-go.BankAccountParams.AppendTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。