你好,我有给定的代码如何改变轨道response.message
def create_profile(payment)
return unless payment.source.gateway_customer_profile_id.nil?
options = {
email: payment.order.email,
login: preferred_secret_key,
}.merge! address_for(payment)
source = update_source!(payment.source)
if source.number.blank? && source.gateway_payment_profile_id.present?
creditcard = source.gateway_payment_profile_id
else
creditcard = source
end
response = provider.store(creditcard, options)
if response.success?
cc_type=payment.source.cc_type
response_cc_type = response.params['sources']['data'].first['brand']
cc_type = CARD_TYPE_MAPPING[response_cc_type] if CARD_TYPE_MAPPING.include?(response_cc_type)
payment.source.update_attributes!({
cc_type: cc_type, # side-effect of update_source!
gateway_customer_profile_id: response.params['id'],
gateway_payment_profile_id: response.params['default_source'] || response.params['default_card']
})
else
payment.send(:gateway_error, response.message)
end
end
我需要response.message改变消息,使用response = [ { message: "fraud card"} ].to_json
我试过,但它给错误`
undefined method `message' for "[{"message":"fraud card"}]":String
我还曾试图response.message = 'fraud error'
,仍然提示错误。我得到的回应是:
params:
error:
message: Your card was declined.
type: card_error
code: card_declined
decline_code: fraudulent
charge: ch_1AgncyJEfCzWOpKDdoxn1x1R
message: Your card was declined.
success: false
test: false
authorization: ch_1AgncyJEfCzWOpKDdoxn1x1R
fraud_review:
error_code: card_declined
emv_authorization:
avs_result:
code:
message:
street_match:
postal_match:
cvv_result:
code:
message:
现在,我的要求是,以检查是否decline_code是欺诈比我的消息应该是fraud error
。请让我知道如何改变这一点。
行的事response.message返回一个字符串?是否响应对象有消息二传手(我猜没有)? –