Last active
December 25, 2019 23:00
-
-
Save Yenwod/a3fa484c4b91429e86f412e535c2487b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'platform-api' | |
namespace :heroku do | |
desc "set test webhook for Stripe based upon review-app url" | |
task update_stripe_test_webhook: :environment do | |
new_webhook_url = "" | |
heroku = PlatformAPI.connect_oauth('the-token-you-generated-via-README-instructions') | |
heroku.app.list.each do |app| | |
if app["name"].include?('vaxcalc-app-pattern-') | |
new_webhook_url = app["web_url"] | |
end | |
end | |
webhook_endpoints = Stripe::WebhookEndpoint.list | |
if webhook_endpoints.first.livemode == false | |
webhook_endpoints.first.url = new_webhook_url + 'stripe-webhook-path-defined-in-routes.rb' | |
webhook_endpoints.first.save | |
else | |
raise "rake task heroku:update_stripe_test_webhook should only work with TEST webhooks!" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment