From b432df9b3988453473a4714def60a41c79fc0b99 Mon Sep 17 00:00:00 2001 From: Aliaksandr Pliutau Date: Fri, 20 Nov 2015 15:01:11 +0700 Subject: [PATCH] cancel_url --- payment.go | 5 +++-- payment_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/payment.go b/payment.go index 2de3277..2c21769 100644 --- a/payment.go +++ b/payment.go @@ -9,10 +9,11 @@ import ( ) // 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\"}," + "\"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) if err != nil { return &PaymentResponse{}, err diff --git a/payment_test.go b/payment_test.go index 5ebe9ec..4926f17 100644 --- a/payment_test.go +++ b/payment_test.go @@ -15,7 +15,7 @@ func TestCreateDirectPaypalPayment(t *testing.T) { Currency: "USD", } - _, err := c.CreateDirectPaypalPayment(amount, "http://example.com") + _, err := c.CreateDirectPaypalPayment(amount, "http://example.com", "http://example.com") if err == nil { t.Errorf("Error must be returned for invalid token")