Ejemplo n.º 1
0
func (s Client) Update(id string, params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
	body := &stripe.RequestValues{}
	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
}
Ejemplo n.º 2
0
func (s Client) Get(id string, params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
	var body *stripe.RequestValues
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &stripe.RequestValues{}
		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
}