Commit 93973de1 by Clinton Blackburn Committed by Clinton Blackburn

CyberSource Secure Acceptance config is now optional

The configuration for Secure Acceptance is now optional. However,
settings for one of Secure Acceptance or Silent Order POST are required.

Additionally, the unused receipt_path setting has been removed from both
the CyberSource and PayPal settings.

LEARNER-818
parent 1d307b31
...@@ -61,19 +61,29 @@ class Cybersource(BaseClientSidePaymentProcessor): ...@@ -61,19 +61,29 @@ class Cybersource(BaseClientSidePaymentProcessor):
self.soap_api_url = configuration['soap_api_url'] self.soap_api_url = configuration['soap_api_url']
self.merchant_id = configuration['merchant_id'] self.merchant_id = configuration['merchant_id']
self.transaction_key = configuration['transaction_key'] self.transaction_key = configuration['transaction_key']
self.profile_id = configuration['profile_id']
self.access_key = configuration['access_key']
self.secret_key = configuration['secret_key']
self.payment_page_url = configuration['payment_page_url']
self.send_level_2_3_details = configuration.get('send_level_2_3_details', True) self.send_level_2_3_details = configuration.get('send_level_2_3_details', True)
self.language_code = settings.LANGUAGE_CODE self.language_code = settings.LANGUAGE_CODE
# Secure Acceptance parameters
# NOTE: Silent Order POST is the preferred method of checkout as it allows us to completely control
# the checkout UX. Secure Acceptance, on the other hand, redirects the purchaser to a page controlled
# by CyberSource.
self.profile_id = configuration.get('profile_id')
self.access_key = configuration.get('access_key')
self.secret_key = configuration.get('secret_key')
self.payment_page_url = configuration.get('payment_page_url')
# Silent Order POST parameters # Silent Order POST parameters
self.sop_profile_id = configuration.get('sop_profile_id') self.sop_profile_id = configuration.get('sop_profile_id')
self.sop_access_key = configuration.get('sop_access_key') self.sop_access_key = configuration.get('sop_access_key')
self.sop_secret_key = configuration.get('sop_secret_key') self.sop_secret_key = configuration.get('sop_secret_key')
self.sop_payment_page_url = configuration.get('sop_payment_page_url') self.sop_payment_page_url = configuration.get('sop_payment_page_url')
sa_configured = all((self.access_key, self.payment_page_url, self.profile_id, self.secret_key))
sop_configured = all([self.sop_access_key, self.sop_payment_page_url, self.sop_profile_id, self.sop_secret_key])
assert sop_configured or sa_configured, \
'CyberSource processor must be configured for Silent Order POST and/or Secure Acceptance'
# Apple Pay configuration # Apple Pay configuration
self.apple_pay_enabled = self.site.siteconfiguration.enable_apple_pay self.apple_pay_enabled = self.site.siteconfiguration.enable_apple_pay
self.apple_pay_merchant_identifier = configuration.get('apple_pay_merchant_identifier', '') self.apple_pay_merchant_identifier = configuration.get('apple_pay_merchant_identifier', '')
......
...@@ -85,6 +85,21 @@ class CybersourceTests(CybersourceMixin, PaymentProcessorTestCaseMixin, TestCase ...@@ -85,6 +85,21 @@ class CybersourceTests(CybersourceMixin, PaymentProcessorTestCaseMixin, TestCase
# If this raises an exception, the value is not a valid UUID4. # If this raises an exception, the value is not a valid UUID4.
UUID(actual['transaction_uuid'], version=4) UUID(actual['transaction_uuid'], version=4)
def test_init_without_config(self):
partner_short_code = self.site.siteconfiguration.partner.short_code
payment_processor_config = copy.deepcopy(settings.PAYMENT_PROCESSOR_CONFIG)
for key in ('sop_access_key', 'sop_payment_page_url', 'sop_profile_id', 'sop_secret_key', 'access_key',
'payment_page_url', 'profile_id', 'secret_key'):
del payment_processor_config[partner_short_code][self.processor_name][key]
with override_settings(PAYMENT_PROCESSOR_CONFIG=payment_processor_config):
with self.assertRaisesMessage(
AssertionError,
'CyberSource processor must be configured for Silent Order POST and/or Secure Acceptance'
):
self.processor_class(self.site)
def test_get_transaction_parameters(self): def test_get_transaction_parameters(self):
""" Verify the processor returns the appropriate parameters required to complete a transaction. """ """ Verify the processor returns the appropriate parameters required to complete a transaction. """
# NOTE (CCB): Make a deepcopy of the settings so that we can modify them without affecting the real settings. # NOTE (CCB): Make a deepcopy of the settings so that we can modify them without affecting the real settings.
......
...@@ -112,7 +112,6 @@ PAYMENT_PROCESSOR_CONFIG = { ...@@ -112,7 +112,6 @@ PAYMENT_PROCESSOR_CONFIG = {
'access_key': None, 'access_key': None,
'secret_key': None, 'secret_key': None,
'payment_page_url': None, 'payment_page_url': None,
'receipt_path': PAYMENT_PROCESSOR_RECEIPT_PATH,
'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH, 'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH,
'send_level_2_3_details': True, 'send_level_2_3_details': True,
'apple_pay_merchant_identifier': '', 'apple_pay_merchant_identifier': '',
...@@ -125,7 +124,6 @@ PAYMENT_PROCESSOR_CONFIG = { ...@@ -125,7 +124,6 @@ PAYMENT_PROCESSOR_CONFIG = {
'mode': None, 'mode': None,
'client_id': None, 'client_id': None,
'client_secret': None, 'client_secret': None,
'receipt_path': PAYMENT_PROCESSOR_RECEIPT_PATH,
'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH, 'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH,
'error_path': PAYMENT_PROCESSOR_ERROR_PATH, 'error_path': PAYMENT_PROCESSOR_ERROR_PATH,
}, },
......
...@@ -24,17 +24,10 @@ COMPRESS_ENABLED = False ...@@ -24,17 +24,10 @@ COMPRESS_ENABLED = False
# PAYMENT PROCESSING # PAYMENT PROCESSING
PAYMENT_PROCESSOR_CONFIG = { PAYMENT_PROCESSOR_CONFIG = {
'edx': { 'edx': {
# NOTE: The same profile information is used here to appease the payment processor class.
# Only Silent Order POST is actually used.
'cybersource': { 'cybersource': {
'merchant_id': 'edx_org', 'merchant_id': 'edx_org',
'transaction_key': '/yIJJejEGoNNcecTyxC9ZD0wR2ZjkkKuOaZnq2BGMGIGQIOKA1rBR009OuvKbPW4J1KLb15BMlaoiUXoj/8/Fp6dy33/aHAU0+yGKcEMxyYXQOBPKjuoChIlMRVkrtWZqP9shGxw1jwHNovmGrvd2ULRIn21Rsq6YnHie7lLLRhXyY2MjnFXfv75eH2rFwfi4hBPbVPvx/r8PwgFIh5otAzsgyIlBjaKJkzbNXd5qCOdNFSBcPcJps3YgVH0ASleI/SZp+Ckuyotd+EhzK0tOehPJAm3L03lkPNeFX9lcemuRkeV53V3nvobn3GaX0td4FAEe8CZBn+IpFC2PoK0tw==', 'transaction_key': '/yIJJejEGoNNcecTyxC9ZD0wR2ZjkkKuOaZnq2BGMGIGQIOKA1rBR009OuvKbPW4J1KLb15BMlaoiUXoj/8/Fp6dy33/aHAU0+yGKcEMxyYXQOBPKjuoChIlMRVkrtWZqP9shGxw1jwHNovmGrvd2ULRIn21Rsq6YnHie7lLLRhXyY2MjnFXfv75eH2rFwfi4hBPbVPvx/r8PwgFIh5otAzsgyIlBjaKJkzbNXd5qCOdNFSBcPcJps3YgVH0ASleI/SZp+Ckuyotd+EhzK0tOehPJAm3L03lkPNeFX9lcemuRkeV53V3nvobn3GaX0td4FAEe8CZBn+IpFC2PoK0tw==',
'soap_api_url': 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.115.wsdl', 'soap_api_url': 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.115.wsdl',
'profile_id': '00D31C4B-4E8F-4E9F-A6B9-1DB8C7C86223',
'access_key': '90a39534dc513e8a81222b158378dda1',
'secret_key': 'ff09d545ddbe4f1e908cc47e3cceb30e4e9ff57a1fe0493392b69a0b75f8ac3df7840f89131d46faa4487071d53576d25047ebb39e9b4af18e9fb5ee1d4f1f66fdb711284c844c4c82bd24f168781e786ecf8b2d3dba4ab5b543c188ca5728e00b8ace43cca14cefbb605ecdc0706eda4cd50785d5754fd691426ddff03fcc7b',
'payment_page_url': 'https://testsecureacceptance.cybersource.com/pay',
'receipt_path': PAYMENT_PROCESSOR_RECEIPT_PATH,
'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH, 'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH,
'send_level_2_3_details': True, 'send_level_2_3_details': True,
'sop_profile_id': '00D31C4B-4E8F-4E9F-A6B9-1DB8C7C86223', 'sop_profile_id': '00D31C4B-4E8F-4E9F-A6B9-1DB8C7C86223',
...@@ -46,7 +39,6 @@ PAYMENT_PROCESSOR_CONFIG = { ...@@ -46,7 +39,6 @@ PAYMENT_PROCESSOR_CONFIG = {
'mode': 'sandbox', 'mode': 'sandbox',
'client_id': 'AVcS4ZWEk7IPqaJibex3bCR0_lykVQ2BHdGz6JWVik0PKWGTOQzWMBOHRppPwFXMCPUqRsoBUDSE-ro5', 'client_id': 'AVcS4ZWEk7IPqaJibex3bCR0_lykVQ2BHdGz6JWVik0PKWGTOQzWMBOHRppPwFXMCPUqRsoBUDSE-ro5',
'client_secret': 'EHNgP4mXL5mI54DQI1-EgXo6y0BDUzj5x1_8gQD0dNWSWS6pcLqlmGq8f5En6oos0z2L37a_EJ27mJ_a', 'client_secret': 'EHNgP4mXL5mI54DQI1-EgXo6y0BDUzj5x1_8gQD0dNWSWS6pcLqlmGq8f5En6oos0z2L37a_EJ27mJ_a',
'receipt_path': PAYMENT_PROCESSOR_RECEIPT_PATH,
'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH, 'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH,
'error_path': PAYMENT_PROCESSOR_ERROR_PATH, 'error_path': PAYMENT_PROCESSOR_ERROR_PATH,
}, },
......
...@@ -81,7 +81,6 @@ PAYMENT_PROCESSOR_CONFIG = { ...@@ -81,7 +81,6 @@ PAYMENT_PROCESSOR_CONFIG = {
'access_key': 'fake-access-key', 'access_key': 'fake-access-key',
'secret_key': 'fake-secret-key', 'secret_key': 'fake-secret-key',
'payment_page_url': 'https://replace-me/', 'payment_page_url': 'https://replace-me/',
'receipt_path': PAYMENT_PROCESSOR_RECEIPT_PATH,
'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH, 'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH,
'send_level_2_3_details': True, 'send_level_2_3_details': True,
'sop_profile_id': 'sop-fake-profile-id', 'sop_profile_id': 'sop-fake-profile-id',
...@@ -97,7 +96,6 @@ PAYMENT_PROCESSOR_CONFIG = { ...@@ -97,7 +96,6 @@ PAYMENT_PROCESSOR_CONFIG = {
'mode': 'sandbox', 'mode': 'sandbox',
'client_id': 'fake-client-id', 'client_id': 'fake-client-id',
'client_secret': 'fake-client-secret', 'client_secret': 'fake-client-secret',
'receipt_path': PAYMENT_PROCESSOR_RECEIPT_PATH,
'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH, 'cancel_checkout_path': PAYMENT_PROCESSOR_CANCEL_PATH,
'error_path': PAYMENT_PROCESSOR_ERROR_PATH, 'error_path': PAYMENT_PROCESSOR_ERROR_PATH,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment