Fix authorizations (#119)

Fix authorizations
This commit is contained in:
Eric Lee 2019-09-24 12:34:56 -07:00 committed by Roopak Venkatakrishnan
parent 06a298ef76
commit c4226ce43c
2 changed files with 19 additions and 14 deletions

View File

@ -10,7 +10,7 @@ import (
// Endpoint: GET /v2/payments/authorization/ID
func (c *Client) GetAuthorization(authID string) (*Authorization, error) {
buf := bytes.NewBuffer([]byte(""))
req, err := http.NewRequest("GET", fmt.Sprintf("%s%s%s", c.APIBase, "/v2/payments/authorization/", authID), buf)
req, err := http.NewRequest("GET", fmt.Sprintf("%s%s%s", c.APIBase, "/v2/payments/authorizations/", authID), buf)
auth := &Authorization{}
if err != nil {
@ -40,7 +40,7 @@ func (c *Client) CaptureAuthorization(authID string, paymentCaptureRequest *Paym
// Endpoint: POST /v2/payments/authorization/ID/void
func (c *Client) VoidAuthorization(authID string) (*Authorization, error) {
buf := bytes.NewBuffer([]byte(""))
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/payments/authorization/"+authID+"/void"), buf)
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/payments/authorizations/"+authID+"/void"), buf)
auth := &Authorization{}
if err != nil {
@ -56,7 +56,7 @@ func (c *Client) VoidAuthorization(authID string) (*Authorization, error) {
// Endpoint: POST /v2/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 + `"}}`))
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/payments/authorization/"+authID+"/reauthorize"), buf)
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/payments/authorizations/"+authID+"/reauthorize"), buf)
auth := &Authorization{}
if err != nil {

View File

@ -132,17 +132,17 @@ type (
// Authorization struct
Authorization struct {
Amount *Amount `json:"amount,omitempty"`
CreateTime *time.Time `json:"create_time,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
State string `json:"state,omitempty"`
ParentPayment string `json:"parent_payment,omitempty"`
ID string `json:"id,omitempty"`
ValidUntil *time.Time `json:"valid_until,omitempty"`
Links []Link `json:"links,omitempty"`
ClearingTime string `json:"clearing_time,omitempty"`
ProtectionEligibility string `json:"protection_eligibility,omitempty"`
ProtectionEligibilityType string `json:"protection_eligibility_type,omitempty"`
ID string `json:"id,omitempty"`
CustomID string `json:"custom_id,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
Status string `json:"status,omitempty"`
StatusDetails *CaptureStatusDetails `json:"status_details,omitempty"`
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
CreateTime *time.Time `json:"create_time,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
ExpirationTime *time.Time `json:"expiration_time,omitempty"`
Links []Link `json:"links,omitempty"`
}
// AuthorizeOrderResponse .
@ -183,6 +183,11 @@ type (
FinalCapture bool `json:"final_capture,omitempty"`
}
SellerProtection struct {
Status string `json:"status,omitempty"`
DisputeCategories []string `json:"dispute_categories,omitempty"`
}
// https://developer.paypal.com/docs/api/payments/v2/#definition-capture_status_details
CaptureStatusDetails struct {
Reason string `json:"reason,omitempty"`