solidusio-contrib / solidus_paypal_marketplace

BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Create webhook controller #72

Closed DanielePalombo closed 3 years ago

DanielePalombo commented 3 years ago

It would be nice to have one webhook entrypoint controller to serve all the webhooks.

It can execute a specific code based on params[:event_type] received.

Example of payload that we'll receive:

{
  "id": "WH-2WR32451HC0233532-67976317FL4543714",
  "create_time": "2016-08-01T21:41:28Z",
  "resource_type": "merchant-onboarding",
  "event_type": "MERCHANT.ONBOARDING.COMPLETED",
  "resource": {
    .....
  },
  "links": []
}

It would be nice if we provide the ability to call a ServiceObject when exists with the same event_type name

e.g. event_type: MERCHANT.ONBOARDING.COMPLETED

SolidusPaypalMarketplace::Webhooks::MerchantOnboardingCompletedWebhook.call(params['resource'])

It would be also nice to log all the received webhook.

If there is an error when the ServiceObject is executed the transaction should be rolled back and the controller should return 5XX or 4XX