diff --git a/README.md b/README.md index 774d02b..f1f9781 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ c.CreateWebhook(paypal.CreateWebhookRequest{ EventTypes: []paypal.WebhookEventType{ paypal.WebhookEventType{ Name: "PAYMENT.AUTHORIZATION.CREATED", - }, + }, }, }) @@ -355,7 +355,6 @@ c.DeleteWebhook("WebhookID") // List registered webhooks c.ListWebhooks(paypal.AncorTypeApplication) - ``` ## How to Contribute diff --git a/types.go b/types.go index e333884..b8fc88c 100644 --- a/types.go +++ b/types.go @@ -1056,19 +1056,33 @@ type ( Links []Link `json:"links"` } - // WebhookEvent struct - WebhookEvent struct { + // Event struct + Event struct { ID string `json:"id"` CreateTime time.Time `json:"create_time"` ResourceType string `json:"resource_type"` EventType string `json:"event_type"` Summary string `json:"summary,omitempty"` - Resource Resource `json:"resource"` Links []Link `json:"links"` EventVersion string `json:"event_version,omitempty"` ResourceVersion string `json:"resource_version,omitempty"` } + AnyEvent struct { + Event + Resource json.RawMessage `json:"resource"` + } + + PaymentPayoutsItemEvent struct { + Event + Resource PayoutItemResponse `json:"resource"` + } + + PaymentPayoutsBatchEvent struct { + Event + Resource PayoutResponse `json:"resource"` + } + // WebhookEventType struct WebhookEventType struct { Name string `json:"name"` @@ -1107,15 +1121,12 @@ type ( SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"` NoteToPayer string `json:"note_to_payer,omitempty"` CustomID string `json:"custom_id,omitempty"` - // merchant-onboarding Resource type - PartnerClientID string `json:"partner_client_id,omitempty"` - MerchantID string `json:"merchant_id,omitempty"` - // Checkout Resource type - Intent string `json:"intent,omitempty"` - PurchaseUnits []*PurchaseUnitRequest `json:"purchase_units,omitempty"` - Payer *PayerWithNameAndPhone `json:"payer,omitempty"` - // Common - Links []Link `json:"links,omitempty"` + PartnerClientID string `json:"partner_client_id,omitempty"` + MerchantID string `json:"merchant_id,omitempty"` + Intent string `json:"intent,omitempty"` + PurchaseUnits []*PurchaseUnitRequest `json:"purchase_units,omitempty"` + Payer *PayerWithNameAndPhone `json:"payer,omitempty"` + Links []Link `json:"links,omitempty"` } CaptureSellerBreakdown struct { diff --git a/webhooks.go b/webhooks.go index 39d0dba..8392208 100644 --- a/webhooks.go +++ b/webhooks.go @@ -89,7 +89,7 @@ func (c *Client) VerifyWebhookSignature(ctx context.Context, httpReq *http.Reque TransmissionSig string `json:"transmission_sig,omitempty"` TransmissionTime string `json:"transmission_time,omitempty"` WebhookID string `json:"webhook_id,omitempty"` - WebhookEvent json.RawMessage `json:"webhook_event"` + Event json.RawMessage `json:"webhook_event"` } // Read the content @@ -107,7 +107,7 @@ func (c *Client) VerifyWebhookSignature(ctx context.Context, httpReq *http.Reque TransmissionSig: httpReq.Header.Get("PAYPAL-TRANSMISSION-SIG"), TransmissionTime: httpReq.Header.Get("PAYPAL-TRANSMISSION-TIME"), WebhookID: webhookID, - WebhookEvent: json.RawMessage(bodyBytes), + Event: json.RawMessage(bodyBytes), } response := &VerifyWebhookResponse{}