Sha256: 2a1c66a00a4f381d2a29fee12801a1805c818ab3e2122bee336be2f9ee165135

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

namespace :workarea do
  namespace :paypal do
    desc 'Register webhook listeners for PayPal'
    task create_webhooks: :environment do
      puts 'Unsubscribing existing webhooks...'
      webhooks = Workarea::Paypal.gateway.list_webhooks.result.webhooks


      webhooks.each do |webhook|
        begin
          Workarea::Paypal.gateway.delete_webhook(webhook.id)
        rescue Workarea::Paypal::Gateway::RequestError => e
          puts "Webhook deletion #{id} failed. #{e.message}"
        end
      end

      puts 'Subscribing to PayPal webhook events...'
      Workarea::Paypal.gateway.create_webhook(
        url: Workarea::Storefront::Engine.routes.url_helpers.paypal_event_url(
          host: Workarea.config.host
        ),
        event_types: Workarea.config.default_webhook_events
      )

      puts 'completed successfully!'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-paypal-3.0.1 lib/tasks/workarea/create_webhooks.rake
workarea-paypal-3.0.0 lib/tasks/workarea/create_webhooks.rake