forked from go-packages/paypal
cancel_url
This commit is contained in:
parent
af3e41b8b7
commit
b432df9b39
|
@ -9,10 +9,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateDirectPaypalPayment sends request with payment
|
// CreateDirectPaypalPayment sends request with payment
|
||||||
func (c *Client) CreateDirectPaypalPayment(amount Amount, redirectURI string) (*PaymentResponse, error) {
|
func (c *Client) CreateDirectPaypalPayment(amount Amount, redirectURI string, cancelURI string) (*PaymentResponse, error) {
|
||||||
buf := bytes.NewBuffer([]byte("{\"intent\":\"sale\",\"payer\":{\"payment_method\":\"paypal\"}," +
|
buf := bytes.NewBuffer([]byte("{\"intent\":\"sale\",\"payer\":{\"payment_method\":\"paypal\"}," +
|
||||||
"\"transactions\":[{\"amount\":{\"total\":\"" + strconv.FormatFloat(amount.Total, 'f', 2, 64) +
|
"\"transactions\":[{\"amount\":{\"total\":\"" + strconv.FormatFloat(amount.Total, 'f', 2, 64) +
|
||||||
"\",\"currency\":\"" + amount.Currency + "\"},\"description\":\"logpacker.com\"}],\"redirect_urls\":{\"return_url\":\"" + redirectURI + "\"}}"))
|
"\",\"currency\":\"" + amount.Currency + "\"},\"description\":\"logpacker.com\"}],\"redirect_urls\":{\"return_url\":\"" +
|
||||||
|
redirectURI + "\",\"cancel_url\":\"" + cancelURI + "\"}}"))
|
||||||
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/payment"), buf)
|
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/payment"), buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &PaymentResponse{}, err
|
return &PaymentResponse{}, err
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestCreateDirectPaypalPayment(t *testing.T) {
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CreateDirectPaypalPayment(amount, "http://example.com")
|
_, err := c.CreateDirectPaypalPayment(amount, "http://example.com", "http://example.com")
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("Error must be returned for invalid token")
|
t.Errorf("Error must be returned for invalid token")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user