lib/active_merchant/billing/gateways/paybox_direct.rb in activemerchant-1.53.0 vs lib/active_merchant/billing/gateways/paybox_direct.rb in activemerchant-1.54.0
- old
+ new
@@ -65,36 +65,44 @@
def authorize(money, creditcard, options = {})
post = {}
add_invoice(post, options)
add_creditcard(post, creditcard)
+ add_amount(post, money, options)
+
commit('authorization', money, post)
end
def purchase(money, creditcard, options = {})
post = {}
add_invoice(post, options)
add_creditcard(post, creditcard)
+ add_amount(post, money, options)
+
commit('purchase', money, post)
end
def capture(money, authorization, options = {})
requires!(options, :order_id)
post = {}
add_invoice(post, options)
+ add_amount(post, money, options)
post[:numappel] = authorization[0,10]
post[:numtrans] = authorization[10,10]
+
commit('capture', money, post)
end
def void(identification, options = {})
requires!(options, :order_id, :amount)
post ={}
add_invoice(post, options)
add_reference(post, identification)
+ add_amount(post, options[:amount], options)
post[:porteur] = '000000000000000'
post[:dateval] = '0000'
+
commit('void', options[:amount], post)
end
def credit(money, identification, options = {})
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
@@ -123,21 +131,24 @@
def add_reference(post, identification)
post[:numappel] = identification[0,10]
post[:numtrans] = identification[10,10]
end
+ def add_amount(post, money, options)
+ post[:montant] = ('0000000000' + (money ? amount(money) : ''))[-10..-1]
+ post[:devise] = CURRENCY_CODES[options[:currency] || currency(money)]
+ end
+
def parse(body)
results = {}
body.split(/&/).each do |pair|
key,val = pair.split(/\=/)
results[key.downcase.to_sym] = CGI.unescape(val) if val
end
results
end
def commit(action, money = nil, parameters = nil)
- parameters[:montant] = ('0000000000' + (money ? amount(money) : ''))[-10..-1]
- parameters[:devise] = CURRENCY_CODES[options[:currency] || currency(money)]
request_data = post_data(action,parameters)
response = parse(ssl_post(test? ? self.test_url : self.live_url, request_data))
response = parse(ssl_post(self.live_url_backup, request_data)) if service_unavailable?(response) && !test?
Response.new(success?(response), message_from(response), response.merge(
:timestamp => parameters[:dateq]),