forked from go-packages/paypal
Merge pull request #107 from roopakv/roopakv/fix_authorize
Add more type definitions & fix capture order
This commit is contained in:
commit
1ac6304458
4
order.go
4
order.go
|
@ -79,8 +79,8 @@ 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) (*Capture, error) {
|
func (c *Client) CaptureOrder(orderID string, captureOrderRequest CaptureOrderRequest) (*CaptureOrderResponse, error) {
|
||||||
capture := &Capture{}
|
capture := &CaptureOrderResponse{}
|
||||||
|
|
||||||
req, err := c.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/checkout/orders/"+orderID+"/capture"), captureOrderRequest)
|
req, err := c.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/checkout/orders/"+orderID+"/capture"), captureOrderRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
52
types.go
52
types.go
|
@ -145,10 +145,20 @@ type (
|
||||||
ProtectionEligibilityType string `json:"protection_eligibility_type,omitempty"`
|
ProtectionEligibilityType string `json:"protection_eligibility_type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuthorizeOrderResponse struct {
|
||||||
|
CreateTime *time.Time `json:"create_time,omitempty"`
|
||||||
|
UpdateTime *time.Time `json:"update_time,omitempty"`
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
Intent string `json:"intent,omitempty"`
|
||||||
|
PurchaseUnits []PurchaseUnitRequest `json:"purchase_units,omitempty"`
|
||||||
|
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// AuthorizeOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_authorize
|
// AuthorizeOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_authorize
|
||||||
AuthorizeOrderRequest struct {
|
AuthorizeOrderRequest struct {
|
||||||
PaymentSource *PaymentSource `json:"payment_source"`
|
PaymentSource *PaymentSource `json:"payment_source,omitempty"`
|
||||||
VaultOnCapture bool `json:"vault_on_capture"`
|
ApplicationContext ApplicationContext `json:"application_context,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
// CaptureOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
||||||
|
@ -454,6 +464,38 @@ type (
|
||||||
UpdateTime *time.Time `json:"update_time,omitempty"`
|
UpdateTime *time.Time `json:"update_time,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CaptureAmount struct
|
||||||
|
CaptureAmount struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapturedPayments has the amounts for a captured order
|
||||||
|
CapturedPayments struct {
|
||||||
|
Captures []CaptureAmount `json:"captures,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapturedPurchaseUnit are purchase units for a captured order
|
||||||
|
CapturedPurchaseUnit struct {
|
||||||
|
Payments *CapturedPayments `json:"payments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PayerWithNameAndPhone struct
|
||||||
|
PayerWithNameAndPhone struct {
|
||||||
|
Name *CreateOrderPayerName `json:"name,omitempty"`
|
||||||
|
EmailAddress string `json:"email_address,omitempty"`
|
||||||
|
Phone *PhoneWithType `json:"phone,omitempty"`
|
||||||
|
PayerID string `json:"payer_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaptureOrderResponse is the response for capture order
|
||||||
|
CaptureOrderResponse struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
|
||||||
|
PurchaseUnits []CapturedPurchaseUnit `json:"purchase_units,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Payer struct
|
// Payer struct
|
||||||
Payer struct {
|
Payer struct {
|
||||||
PaymentMethod string `json:"payment_method"`
|
PaymentMethod string `json:"payment_method"`
|
||||||
|
@ -602,6 +644,12 @@ type (
|
||||||
UpdateTime *time.Time `json:"update_time,omitempty"`
|
UpdateTime *time.Time `json:"update_time,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefundResponse struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Related struct
|
// Related struct
|
||||||
Related struct {
|
Related struct {
|
||||||
Sale *Sale `json:"sale,omitempty"`
|
Sale *Sale `json:"sale,omitempty"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user