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


Golang stripe-go.RecipientParams类代码示例

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


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

示例1: Update

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

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

		if len(params.Name) > 0 {
			body.Add("name", params.Name)
		}

		if params.Bank != nil {
			if len(params.Bank.Token) > 0 {
				body.Add("bank_account", params.Bank.Token)
			} else {
				params.Bank.AppendDetails(body)
			}
		}

		if len(params.Token) > 0 {
			body.Add("card", params.Token)
		} else if params.Card != nil {
			params.Card.AppendDetails(body, true)
		}

		if len(params.TaxID) > 0 {
			body.Add("tax_id", params.TaxID)
		}

		if len(params.DefaultCard) > 0 {
			body.Add("default_card", params.DefaultCard)
		}

		if len(params.Email) > 0 {
			body.Add("email", params.Email)
		}

		if len(params.Desc) > 0 {
			body.Add("description", params.Desc)
		}

		params.AppendTo(body)
	}

	recipient := &stripe.Recipient{}
	err := c.B.Call("POST", "/recipients/"+id, c.Key, body, commonParams, recipient)

	return recipient, err
}
开发者ID:outdoorsy,项目名称:stripe-go,代码行数:50,代码来源:client.go

示例2: Get

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

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

	recipient := &stripe.Recipient{}
	err := c.B.Call("GET", "/recipients/"+id, c.Key, body, commonParams, recipient)

	return recipient, err
}
开发者ID:outdoorsy,项目名称:stripe-go,代码行数:15,代码来源:client.go

示例3: New

func (c Client) New(params *stripe.RecipientParams) (*stripe.Recipient, error) {
	body := &url.Values{
		"name": {params.Name},
		"type": {string(params.Type)},
	}

	if params.Bank != nil {
		if len(params.Bank.Token) > 0 {
			body.Add("bank_account", params.Bank.Token)
		} else {
			params.Bank.AppendDetails(body)
		}
	}

	if len(params.Token) > 0 {
		body.Add("card", params.Token)
	} else if params.Card != nil {
		params.Card.AppendDetails(body, true)
	}

	if len(params.TaxID) > 0 {
		body.Add("tax_id", params.TaxID)
	}

	if len(params.Email) > 0 {
		body.Add("email", params.Email)
	}

	if len(params.Desc) > 0 {
		body.Add("description", params.Desc)
	}
	params.AppendTo(body)

	recipient := &stripe.Recipient{}
	err := c.B.Call("POST", "/recipients", c.Key, body, &params.Params, recipient)

	return recipient, err
}
开发者ID:outdoorsy,项目名称:stripe-go,代码行数:38,代码来源:client.go


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