mirror of
https://github.com/plutov/paypal.git
synced 2025-02-02 15:10:36 +01:00
Adding a capture auth idempotent function (#142)
* Adding a capture auth idempotent function * refactoring * better name Co-Authored-By: Roopak Venkatakrishnan <roopak.v@gmail.com> * what's in a name Co-authored-by: Roopak Venkatakrishnan <roopak.v@gmail.com>
This commit is contained in:
parent
1fb8e0b1fa
commit
907cf40be1
15
order.go
15
order.go
|
@ -80,6 +80,17 @@ func (c *Client) AuthorizeOrder(orderID string, authorizeOrderRequest AuthorizeO
|
||||||
// CaptureOrder - https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
// CaptureOrder - https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
||||||
// Endpoint: POST /v2/checkout/orders/ID/capture
|
// Endpoint: POST /v2/checkout/orders/ID/capture
|
||||||
func (c *Client) CaptureOrder(orderID string, captureOrderRequest CaptureOrderRequest) (*CaptureOrderResponse, error) {
|
func (c *Client) CaptureOrder(orderID string, captureOrderRequest CaptureOrderRequest) (*CaptureOrderResponse, error) {
|
||||||
|
return c.CaptureOrderWithPaypalRequestId(orderID, captureOrderRequest, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaptureOrder with idempotency - https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
||||||
|
// Endpoint: POST /v2/checkout/orders/ID/capture
|
||||||
|
// https://developer.paypal.com/docs/api/reference/api-requests/#http-request-headers
|
||||||
|
func (c *Client) CaptureOrderWithPaypalRequestId(
|
||||||
|
orderID string,
|
||||||
|
captureOrderRequest CaptureOrderRequest,
|
||||||
|
requestID string,
|
||||||
|
) (*CaptureOrderResponse, error) {
|
||||||
capture := &CaptureOrderResponse{}
|
capture := &CaptureOrderResponse{}
|
||||||
|
|
||||||
c.SetReturnRepresentation()
|
c.SetReturnRepresentation()
|
||||||
|
@ -88,6 +99,10 @@ func (c *Client) CaptureOrder(orderID string, captureOrderRequest CaptureOrderRe
|
||||||
return capture, err
|
return capture, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if requestID != "" {
|
||||||
|
req.Header.Set("PayPal-Request-Id", requestID)
|
||||||
|
}
|
||||||
|
|
||||||
if err = c.SendWithAuth(req, capture); err != nil {
|
if err = c.SendWithAuth(req, capture); err != nil {
|
||||||
return capture, err
|
return capture, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user