Exemplo n.º 1
0
func (s Client) Update(id string, params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
	body := &url.Values{}
	params.Source.AppendDetails(body, false)
	params.AppendTo(body)

	source := &stripe.PaymentSource{}
	var err error

	if len(params.Customer) > 0 {
		err = s.B.Call("POST", fmt.Sprintf("/customers/%v/sources/%v", params.Customer, id), s.Key, body, &params.Params, source)
	} else {
		err = errors.New("Invalid source params: customer needs to be set")
	}

	return source, err
}
Exemplo n.º 2
0
func (s Client) Get(id string, params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
	var body *url.Values
	var commonParams *stripe.Params

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

	source := &stripe.PaymentSource{}
	var err error

	if len(params.Customer) > 0 {
		err = s.B.Call("GET", fmt.Sprintf("/customers/%v/sources/%v", params.Customer, id), s.Key, body, commonParams, source)
	} else {
		err = errors.New("Invalid source params: customer needs to be set")
	}

	return source, err
}