Sha256: 174eccd3009df698e13d4c8424aadfc76a91d1241a989610766ebb178d281cdf

Contents?: true

Size: 371 Bytes

Versions: 2

Compression:

Stored size: 371 Bytes

Contents

module Tang
  class UpdateCoupon
    def self.call(coupon)
      if !coupon.valid?
        return coupon
      end

      begin
        c = Stripe::Coupon.retrieve(coupon.stripe_id)
        c.id = coupon.id
        c.save
      rescue Stripe::StripeError => e
        coupon.errors.add(:base, :invalid, message: e.message)
      end

      return coupon
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tang-0.2.2 app/services/tang/update_coupon.rb
tang-0.2.1 app/services/tang/update_coupon.rb