Sha256: 0278b42f70b9b1e6e2e0ec2b93e5190d2271efb8a8f6f6323be9d9607c9d7c4c
Contents?: true
Size: 851 Bytes
Versions: 8
Compression:
Stored size: 851 Bytes
Contents
require 'webmock_method' require "services/payment_gateway.rb" class PaymentGateway extend WebmockMethod webmock_method :purchase, [:amount, :credit_card], lambda { |binding| template = "#{File.dirname(__FILE__)}/templates/purchase_response.xml.erb" RenderHelper.render :erb, template, binding } do |parent, amount, credit_card| define_attribute(parent, :error, create_error(parent, "Negative amount")) if amount < 0 if credit_card.card_type == "VISA" define_attribute(parent, :success, true) else define_attribute(parent, :success, false) define_attribute(parent, :error_message, "Unsupported Credit Card Type") end end def self.create_error parent, reason define_attribute(parent, :error, Exception.new(reason)) end end
Version data entries
8 entries across 8 versions & 1 rubygems