我是rails世界的新手,我正在为客户设置一个小型rails应用程序。其中一个要求是我想设置一个支付系统用于测试目的。
答案 0 :(得分:2)
对于快速的东西,我会使用Stripe。它具有最小的后端设置,一个宝石,并且(如果您使用TDD)很容易使用给定的测试卡数据创建测试。
(defmulti test-multimethod (fn [keyword] keyword))
(defmethod test-multimethod :foo [a-map]
"foo-method was called")
(defmethod test-multimethod :bar [a-map]
"bar-method was called")
(defmulti perimeter (fn [shape] (:shape-name shape)))
(defmethod perimeter :circle [circle]
(* 2 Math/PI (:radius circle)))
(defmethod perimeter :rectangle [rectangle]
(+ (* 2 (:width rectangle)) (* 2 (:height rectangle))))
(def some-shapes [{:shape-name :circle :radius 4}
{:shape-name :rectangle :width 2 :height 2}])
(defmulti area (fn [shape] (:shape-name shape)))
(defmethod area :circle [circle]
(* Math/PI (:radius circle) (:radius circle)))
(defmethod area :rectangle [rectangle]
(* (:width rectangle) (:height rectangle)))
(defmethod perimeter :square [square]
(* 4 (:side square)))
(defmethod area :square [square]
(* (:side square) (:side square)))
(def more-shapes (conj some-shapes
{:shape-name :square :side 4}))
(for [shape more-shapes] (perimeter shape))
(for [shape more-shapes] (area shape))