3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/services/payola/create_sale.rb', line 3
def self.call(params)
product = params[:product]
affiliate = params[:affiliate]
coupon = params[:coupon]
Payola::Sale.new do |s|
s.product = product
s.email = params[:stripeEmail]
s.stripe_token = params[:stripeToken]
s.affiliate_id = affiliate.try(:id)
s.currency = product.respond_to?(:currency) ? product.currency : Payola.default_currency
s.signed_custom_fields = params[:signed_custom_fields]
if coupon
s.coupon = coupon
s.amount = product.price * (1 - s.coupon.percent_off / 100.0)
else
s.amount = product.price
end
end
end
|