Cardinal Centinel Gateway Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
credit_card = ActiveMerchant::Billing::CreditCard.new(cc_number, cc_info_hash) | |
gateway = ActiveMerchant::Billing::CardinalCentinelGateway.new( | |
ProcessorId: '123', | |
MerchantId: '456', | |
TransactionPwd: 'p4ssw0rd' | |
) | |
lookup_response = gateway.authorize(amount, credit_card) | |
if lookup_response.enrolled? | |
# redirect the user to the 3d Secure ACS Url via HTTP POST | |
# A common thing to do here that I've seen is render a partial that | |
# is just a form that submits on page load. An example of this form | |
# can be seen in the other file in this gist. | |
form_values = { | |
pa_req: lookup_response.payload, | |
acs_url: lookup_response.acs_url, | |
md: lookup_response.transaction_id, | |
term_url: 'A URL on your server for the bank to redirect to after successful verification' | |
} | |
render 'secure_verify_rediect_form', form_values | |
else | |
# Some other payment flow here | |
end | |
# After the user completes the off site verification, The bank will | |
# send a POST request to the TermUrl you specified above. | |
# This TermUrl will receive the PaRes and MD in the params. | |
# You can complete the final step using these params. | |
auth_response = gateway.secure_verify(params['PaRes'], params['MD']) | |
# Success is determined by the absence of errors as well as | |
# the presnce of a Xid, Cavv and EciFlag | |
if auth_response.success? | |
# handle success | |
else | |
# handle failure | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body onload="document.frmLaunch.submit();"> | |
<form name="frmLaunch" method="POST" action="<%= acs_url %>"> | |
<input type="hidden" name="PaReq" value="<%= pa_req %>"> | |
<input type="hidden" name="TermUrl" value="<%= term_url %>"> | |
<input type="hidden" name="MD" value="<%= md %>"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment