forked from go-packages/paypal
#192: refactor Event type
This commit is contained in:
parent
1e23f8dd7d
commit
52acc61786
|
@ -355,7 +355,6 @@ c.DeleteWebhook("WebhookID")
|
||||||
|
|
||||||
// List registered webhooks
|
// List registered webhooks
|
||||||
c.ListWebhooks(paypal.AncorTypeApplication)
|
c.ListWebhooks(paypal.AncorTypeApplication)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to Contribute
|
## How to Contribute
|
||||||
|
|
23
types.go
23
types.go
|
@ -1056,19 +1056,33 @@ type (
|
||||||
Links []Link `json:"links"`
|
Links []Link `json:"links"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebhookEvent struct
|
// Event struct
|
||||||
WebhookEvent struct {
|
Event struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
CreateTime time.Time `json:"create_time"`
|
CreateTime time.Time `json:"create_time"`
|
||||||
ResourceType string `json:"resource_type"`
|
ResourceType string `json:"resource_type"`
|
||||||
EventType string `json:"event_type"`
|
EventType string `json:"event_type"`
|
||||||
Summary string `json:"summary,omitempty"`
|
Summary string `json:"summary,omitempty"`
|
||||||
Resource Resource `json:"resource"`
|
|
||||||
Links []Link `json:"links"`
|
Links []Link `json:"links"`
|
||||||
EventVersion string `json:"event_version,omitempty"`
|
EventVersion string `json:"event_version,omitempty"`
|
||||||
ResourceVersion string `json:"resource_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
|
||||||
WebhookEventType struct {
|
WebhookEventType struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -1107,14 +1121,11 @@ type (
|
||||||
SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"`
|
SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"`
|
||||||
NoteToPayer string `json:"note_to_payer,omitempty"`
|
NoteToPayer string `json:"note_to_payer,omitempty"`
|
||||||
CustomID string `json:"custom_id,omitempty"`
|
CustomID string `json:"custom_id,omitempty"`
|
||||||
// merchant-onboarding Resource type
|
|
||||||
PartnerClientID string `json:"partner_client_id,omitempty"`
|
PartnerClientID string `json:"partner_client_id,omitempty"`
|
||||||
MerchantID string `json:"merchant_id,omitempty"`
|
MerchantID string `json:"merchant_id,omitempty"`
|
||||||
// Checkout Resource type
|
|
||||||
Intent string `json:"intent,omitempty"`
|
Intent string `json:"intent,omitempty"`
|
||||||
PurchaseUnits []*PurchaseUnitRequest `json:"purchase_units,omitempty"`
|
PurchaseUnits []*PurchaseUnitRequest `json:"purchase_units,omitempty"`
|
||||||
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
|
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
|
||||||
// Common
|
|
||||||
Links []Link `json:"links,omitempty"`
|
Links []Link `json:"links,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ func (c *Client) VerifyWebhookSignature(ctx context.Context, httpReq *http.Reque
|
||||||
TransmissionSig string `json:"transmission_sig,omitempty"`
|
TransmissionSig string `json:"transmission_sig,omitempty"`
|
||||||
TransmissionTime string `json:"transmission_time,omitempty"`
|
TransmissionTime string `json:"transmission_time,omitempty"`
|
||||||
WebhookID string `json:"webhook_id,omitempty"`
|
WebhookID string `json:"webhook_id,omitempty"`
|
||||||
WebhookEvent json.RawMessage `json:"webhook_event"`
|
Event json.RawMessage `json:"webhook_event"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the content
|
// Read the content
|
||||||
|
@ -107,7 +107,7 @@ func (c *Client) VerifyWebhookSignature(ctx context.Context, httpReq *http.Reque
|
||||||
TransmissionSig: httpReq.Header.Get("PAYPAL-TRANSMISSION-SIG"),
|
TransmissionSig: httpReq.Header.Get("PAYPAL-TRANSMISSION-SIG"),
|
||||||
TransmissionTime: httpReq.Header.Get("PAYPAL-TRANSMISSION-TIME"),
|
TransmissionTime: httpReq.Header.Get("PAYPAL-TRANSMISSION-TIME"),
|
||||||
WebhookID: webhookID,
|
WebhookID: webhookID,
|
||||||
WebhookEvent: json.RawMessage(bodyBytes),
|
Event: json.RawMessage(bodyBytes),
|
||||||
}
|
}
|
||||||
|
|
||||||
response := &VerifyWebhookResponse{}
|
response := &VerifyWebhookResponse{}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user