mirror of
https://github.com/plutov/paypal.git
synced 2025-01-23 10:21:03 +01:00
#192: refactor Event type
This commit is contained in:
parent
1e23f8dd7d
commit
52acc61786
|
@ -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
|
||||
|
|
35
types.go
35
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 {
|
||||
|
|
|
@ -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{}
|
||||
|
|
Loading…
Reference in New Issue
Block a user