diff --git a/authorization.go b/authorization.go index 361f6a0..96a2eb8 100644 --- a/authorization.go +++ b/authorization.go @@ -27,7 +27,7 @@ func (c *Client) GetAuthorization(authID string) (*Authorization, error) { func (c *Client) CaptureAuthorization(authID string, a *Amount, isFinalCapture bool) (*Capture, error) { isFinalStr := strconv.FormatBool(isFinalCapture) - buf := bytes.NewBuffer([]byte("{\"amount\":{\"currency\":\"" + a.Currency + "\",\"total\":\"" + a.Total + "\"},\"is_final_capture\":" + isFinalStr + "}")) + buf := bytes.NewBuffer([]byte(`{"amount":{"currency":"` + a.Currency + `,"total":"` + a.Total + `"},"is_final_capture":` + isFinalStr + `}`)) req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/authorization/"+authID+"/capture"), buf) if err != nil { return &Capture{}, err @@ -56,7 +56,7 @@ func (c *Client) VoidAuthorization(authID string) (*Authorization, error) { // PayPal recommends to reauthorize payment after ~3 days // Endpoint: POST /v1/payments/authorization/ID/reauthorize func (c *Client) ReauthorizeAuthorization(authID string, a *Amount) (*Authorization, error) { - buf := bytes.NewBuffer([]byte("{\"amount\":{\"currency\":\"" + a.Currency + "\",\"total\":\"" + a.Total + "\"}}")) + buf := bytes.NewBuffer([]byte(`{"amount":{"currency":"` + a.Currency + `","total":"` + a.Total + `"}}`)) req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/authorization/"+authID+"/reauthorize"), buf) if err != nil { return &Authorization{}, err diff --git a/billing.go b/billing.go index 5653411..877cd69 100644 --- a/billing.go +++ b/billing.go @@ -46,7 +46,7 @@ func (c *Client) CreateBillingPlan(plan BillingPlan) (*CreateBillingResp, error) // By default, a new plan is not activated // Endpoint: PATCH /v1/payments/billing-plans/ func (c *Client) ActivatePlan(planID string) error { - buf := bytes.NewBuffer([]byte("[{\"op\":\"replace\",\"path\":\"/\",\"value\":{\"state\":\"ACTIVE\"}}]")) + buf := bytes.NewBuffer([]byte(`[{"op":"replace","path":"/","value":{"state":"ACTIVE"}}]`)) req, err := http.NewRequest("PATCH", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/billing-plans/"+planID), buf) if err != nil { return err diff --git a/payment.go b/payment.go index 8bd95ec..fe66071 100644 --- a/payment.go +++ b/payment.go @@ -22,10 +22,10 @@ type CreatePaymentResp struct { // CreatePayment is more common function for any kind of payment // Endpoint: POST /v1/payments/payment func (c *Client) CreateDirectPaypalPayment(amount Amount, redirectURI string, cancelURI string, description string) (*PaymentResponse, error) { - buf := bytes.NewBuffer([]byte("{\"intent\":\"sale\",\"payer\":{\"payment_method\":\"paypal\"}," + - "\"transactions\":[{\"amount\":{\"total\":\"" + amount.Total + - "\",\"currency\":\"" + amount.Currency + "\"},\"description\":\"" + description + "\"}],\"redirect_urls\":{\"return_url\":\"" + - redirectURI + "\",\"cancel_url\":\"" + cancelURI + "\"}}")) + buf := bytes.NewBuffer([]byte(`{"intent":"sale","payer":{"payment_method":"paypal"},` + + `"transactions":[{"amount":{"total":"` + amount.Total + + `","currency":"` + amount.Currency + `"},"description":"` + description + `"}],"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 @@ -68,7 +68,7 @@ func (c *Client) CreatePayment(p Payment) (*CreatePaymentResp, error) { // ExecuteApprovedPayment - Use this call to execute (complete) a PayPal payment that has been approved by the payer. You can optionally update transaction information when executing the payment by passing in one or more transactions. // Endpoint: POST /v1/payments/payment/paymentID/execute func (c *Client) ExecuteApprovedPayment(paymentID string, payerID string) (*ExecuteResponse, error) { - buf := bytes.NewBuffer([]byte("{\"payer_id\":\"" + payerID + "\"}")) + buf := bytes.NewBuffer([]byte(`{"payer_id":"` + payerID + `"}`)) req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/payment/"+paymentID+"/execute"), buf) if err != nil { return &ExecuteResponse{}, err