Sha256: d8c8d832be517eacc3a509aedebaf601f25366197f716fcfba57c9492ddfe4d5

Contents?: true

Size: 566 Bytes

Versions: 2

Compression:

Stored size: 566 Bytes

Contents

module StripeLocal
	class PlanSync
		require 'stripe'

		class<<self
			def then_sync from_hash
				Stripe::Plan.create from_hash
			end

			def then_destroy id
				Stripe::Plan.retrieve( id ).delete
			end
		end

		def after_create plan
			attributes = {
				id: plan.id,
				name: plan.name,
				amount: plan.amount,
				currency: 'usd',
				interval: plan.interval,
				interval_count: plan.interval_count,
				trial_period_days: 0
			}
			PlanSync.delay.then_sync attributes
	  end

		def after_destroy plan
			PlanSync.delay.then_destroy plan.id
		end

	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stripe_local-0.2.5 app/callbacks/stripe_local/plan_sync.rb
stripe_local-0.2.4 app/callbacks/stripe_local/plan_sync.rb