Pam Willenz

Joined

90 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Stripe Signed Webhooks Discussion

I define @event in the customer_dispute_mailer.rb

class CustomerDisputeMailer < ApplicationMailer

  # Subject can be set in your I18n file at config/locales/en.yml
  # with the following lookup:
  #
  #   en.customer_dispute_mailer.send_admin_customer_dispute.subject
  #
  def send_admin_customer_dispute(event)
    @event = event

    mail(to: "admin@rubythursday.com", subject: "Uh oh, a customer has submitted a dispute", from: "melissa@rubythursday.com")

  end
end

Posted in Stripe Signed Webhooks Discussion

Hi Chris,

I am trying to test (with rspec) a webhook url with a particular event.type in stripe - "charge.dispute.created". I've simulated it on the stripe dashboard test site and the webhook works for my production site but I can't seem to get the spec to pass. I am using the stripe_event gem and strip-ruby-mock gem. I am also using a mailer. All other tests are passing using these gems.

I keep getting '400' instead of '200' for this line:
post '/stripe-web-hooks', params: { id: @event.id }

Here is my spec and my stripe.rb. I'd appreciate any advice.

Pam

require 'rails_helper'
require 'stripe_mock' 

describe "Customer Dispute Events" do

  describe "charge.dispute.created" do 

    before do
      StripeMock.start
      @event = StripeMock.mock_webhook_event('charge.dispute.created')
      #@event = Stripe::Event.retrieve("evt_1EEd1tKGa7MvTac7cvoKcpPk")
      ActionMailer::Base.deliveries.clear
    end

    after do 
      StripeMock.stop
      ActionMailer::Base.deliveries.clear
    end

    it "is successful" do 
      post '/stripe-web-hooks', params: { id: @event.id }
      expect(response.code).to eq "200"
    end

    it "sends an email to the admin" do
      post '/stripe-web-hooks', params: { id: @event.id }
      expect(ActionMailer::Base.deliveries.count).to eq 1
    end
  end
end

Stripe.api_key = ENV["stripe_secret_key"]
StripeEvent.signing_secret = ENV["stripe_signing_key"]

# StripeEvent.configure do |events|

#   events.subscribe 'charge.dispute.created' do |event|


StripeEvent.subscribe 'charge.dispute.created' do |event|
  event.class       #=> Stripe::Event
  event.type        #=> "charge.dispute.created"
  event.data.object #=> #<Stripe::Dispute:0x3fcb34c115f8>
  #end
CustomerDisputeMailer.send_admin_customer_dispute(event).deliver_now
end

Posted in Upgrade to Mojave on Mac OS

thanks, Chris. Do you use Capybara and if not, do you use something else?

Seems like a lot of mix and matching that might break other things.

Posted in Upgrade to Mojave on Mac OS

thanks, Chris, for your quick reply.

One thing I noticed when I previously upgraded was a big issue with Capybara and QT. Do you know if this might be an issue?

Posted in Upgrade to Mojave on Mac OS

Hi Chris - I am running Sierra (not high Sierra) on my fairly new Mac (summer 2017). I need to upgrade to Mojave and am afraid I will break my ruby/rails dev environment (like I did when I upgraded before). I just landed a consulting project and want to do this, troubleshoot everything before I start work.

Can you provide a guide for upgrading versus reinstalling everything or point me to a good tutorial?

thanks,
Pam