lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.72.0 vs lib/active_merchant/billing/gateways/adyen.rb in activemerchant-1.73.0
- old
+ new
@@ -142,11 +142,11 @@
requires!(card, :expiryMonth, :expiryYear, :holderName, :number, :cvc)
post[:card] = card
end
def add_references(post, authorization, options = {})
- post[:originalReference] = authorization
+ post[:originalReference] = psp_reference_from(authorization)
post[:reference] = options[:order_id]
end
def parse(body)
return {} if body.blank?
@@ -167,11 +167,11 @@
success = success_from(action, response)
Response.new(
success,
message_from(action, response),
response,
- authorization: authorization_from(response),
+ authorization: authorization_from(action, parameters, response),
test: test?,
error_code: success ? nil : error_code_from(response)
)
end
@@ -205,12 +205,12 @@
when 'capture', 'refund', 'cancel'
response['response'] || response['message']
end
end
- def authorization_from(response)
- response['pspReference']
+ def authorization_from(action, parameters, response)
+ [parameters[:originalReference], response['pspReference']].compact.join("#").presence
end
def init_post(options = {})
{merchantAccount: options[:merchant_account] || @merchant_account}
end
@@ -219,9 +219,13 @@
JSON.generate(parameters)
end
def error_code_from(response)
STANDARD_ERROR_CODE_MAPPING[response['errorCode']]
+ end
+
+ def psp_reference_from(authorization)
+ authorization.nil? ? nil : authorization.split("#").first
end
end
end
end