lib/active_merchant/billing/gateways/micropayment.rb in activemerchant-1.54.0 vs lib/active_merchant/billing/gateways/micropayment.rb in activemerchant-1.55.0
- old
+ new
@@ -3,59 +3,61 @@
class MicropaymentGateway < Gateway
self.display_name = "micropayment"
self.homepage_url = "https://www.micropayment.de/"
- self.test_url = self.live_url = "https://sipg.micropayment.de/public/creditcard/v1.5.2/nvp/"
+ self.test_url = self.live_url = "https://sipg.micropayment.de/public/creditcardpsp/v1/nvp/"
self.supported_countries = %w(DE)
self.default_currency = "EUR"
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express]
+
def initialize(options={})
requires!(options, :access_key)
super
end
def purchase(amount, payment_method, options={})
post = {}
add_invoice(post, amount, options)
- add_payment_method(post, payment_method)
+ add_payment_method(post, payment_method, options)
add_customer_data(post, options)
- commit("shortTransactionPurchase", post)
+ commit("purchase", post)
end
def authorize(amount, payment_method, options={})
post = {}
add_invoice(post, amount, options)
- add_payment_method(post, payment_method)
+ add_payment_method(post, payment_method, options)
add_customer_data(post, options)
- commit("shortTransactionAuthorization", post)
+ commit("authorize", post)
end
def capture(amount, authorization, options={})
post = {}
add_reference(post, authorization)
add_invoice(post, amount, options)
- commit("transactionCapture", post)
+ commit("capture", post)
end
def void(authorization, options={})
post = {}
add_reference(post, authorization)
- commit("transactionReversal", post)
+ commit("void", post)
end
def refund(amount, authorization, options={})
post = {}
add_reference(post, authorization)
add_invoice(post, amount, options)
- commit("transactionRefund", post)
+ commit("refund", post)
end
def verify(credit_card, options={})
+
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(250, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
@@ -76,17 +78,18 @@
def add_invoice(post, money, options)
if money
post[:amount] = amount(money)
post[:currency] = options[:currency] || currency(money)
end
- post[:project] = options[:project] || "sprdly"
+ post[:project] = options[:project] if options[:project]
end
- def add_payment_method(post, payment_method)
+ def add_payment_method(post, payment_method, options={})
post[:firstname] = payment_method.first_name
post[:surname] = payment_method.last_name
post[:number] = payment_method.number
+ post[:recurring] = 1 if options[:recurring] == true
post[:cvc2] = payment_method.verification_value
post[:expiryYear] = format(payment_method.year, :four_digits)
post[:expiryMonth] = format(payment_method.month, :two_digits)
end
@@ -101,21 +104,21 @@
post[:sessionId] = session_id
post[:transactionId] = transaction_id
end
def commit(action, params)
-
params[:testMode] = 1 if test?
params[:accessKey] = @options[:access_key]
+ params[:apiKey] = @options[:api_key] || "af1fd841af792f4c50131414ff76e004"
response = parse(ssl_post(url(action), post_data(action, params), headers))
Response.new(
succeeded = success_from(response),
message_from(succeeded, response),
response,
- authorization: authorization_from(response),
+ authorization: authorization_from(response, params),
avs_result: AVSResult.new(code: response["some_avs_result_key"]),
cvv_result: CVVResult.new(response["some_cvv_result_key"]),
test: test?
)
end
@@ -157,11 +160,12 @@
def split_authorization(authorization)
authorization.split("|")
end
- def authorization_from(response)
- "#{response["sessionId"]}|#{response["transactionId"]}"
+ def authorization_from(response, request_params)
+ session_id = response["sessionId"] ? response["sessionId"] : request_params[:sessionId]
+ "#{session_id}|#{response["transactionId"]}"
end
end
end
end