-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cyber source rest store unstore #4709
base: master
Are you sure you want to change the base?
Conversation
CybersourceRest: adding gateway Summary: ------------------------------ Adding CybersourceRest gateway with authorize and purchase calls. GWI-474 Remote Test: ------------------------------ Finished in 3.6855 seconds. 6 tests, 17 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit Tests: ------------------------------ Finished in 35.528692 seconds. 5441 tests, 77085 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed RuboCop: ------------------------------ 760 files inspected, no offenses detected
…hant/active_merchant into CyberSourceREST_store_unstore
post[:buyerInformation][:merchantCustomerId] = options[:customer_id] | ||
post[:buyerInformation][:email] = options[:email].presence || '[email protected]' | ||
add_code(post, options) | ||
post[:merchantDefinedInformation] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that this is twice (82 and 86 have the same merchantDefinedInformation
definition)
when /payments/ | ||
response['status'] == 'AUTHORIZED' | ||
else | ||
!response['id'].nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we use response['id'].present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments
else | ||
return response['id'].present? unless http_method == :delete | ||
|
||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def message_from(response) | ||
return response['status'] if success_from(response) | ||
def message_from(action, response, http_method) | ||
return response['status'] if success_from(action, response, http_method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of recalling the succes_from method, it is possible to use the call in the commit method.
def commit
# commit code
succeeded = success_from(action, response, http_method)
Response.new(
succeeded,
message_from(response, succeeded)
# other response fields
error_code: error_code_from(response, succeeded)
)
# other commit code
end
def message_from(response, succeeded)
return response['status'] if succeeded
response['errorInformation']['message']
end
def error_code_from(response, succeeded)
response['errorInformation']['reason'] unless succeeded
end
Marking this "of interest" before a cleanup of stale PRs |
CyberSourceREST: Add Store and Unstore methods
To store a payment method in CyberSource the Token management system(TMS) provides
the customer, InstrumentIdentifier and PaymentInstrument endpoints.
Sending a purchase request can be done with the customer_id returned by the customer endpoint once a paymentInstrument and an instrumentIdentifier are created.