Stripe : Test : Webhook from one env processed by another

You often have environments like staging, qa, development which use the test secrect and publishable keys of Stripe. So you might run in situation when callbacks for one environment is responded success by another environment and it may create problem in testing.

Instead you can pass environment details in meta data and if that callback is not generated for that environment, just raise an exception.

subscription.metadata = {
                          # To enable one env to ignore (not return 200)
                          #  for webhook event of another environment
                          app_environment: Rails.env