def test_get_signed_purchase_params(self): params = get_signed_purchase_params(self.order, callback_url=self.CALLBACK_URL) # Check the callback URL override self.assertEqual(params["override_custom_receipt_page"], self.CALLBACK_URL) # Parameters determined by the order model self.assertEqual(params["amount"], "10.00") self.assertEqual(params["currency"], "usd") self.assertEqual(params["orderNumber"], "OrderId: {order_id}".format(order_id=self.order.id)) self.assertEqual(params["reference_number"], self.order.id) # Parameters determined by the Django (test) settings self.assertEqual(params["access_key"], "0123456789012345678901") self.assertEqual(params["profile_id"], "edx") # Some fields will change depending on when the test runs, # so we just check that they're set to a non-empty string self.assertGreater(len(params["signed_date_time"]), 0) self.assertGreater(len(params["transaction_uuid"]), 0) # Constant parameters self.assertEqual(params["transaction_type"], "sale") self.assertEqual(params["locale"], "en") self.assertEqual(params["payment_method"], "card") self.assertEqual( params["signed_field_names"], ",".join( [ "amount", "currency", "orderNumber", "access_key", "profile_id", "reference_number", "transaction_type", "locale", "signed_date_time", "signed_field_names", "unsigned_field_names", "transaction_uuid", "payment_method", "override_custom_receipt_page", "override_custom_cancel_page", ] ), ) self.assertEqual(params["unsigned_field_names"], "") # Check the signature self.assertEqual(params["signature"], self._signature(params))
def test_get_signed_purchase_params(self): params = get_signed_purchase_params(self.order, callback_url=self.CALLBACK_URL) # Check the callback URL override self.assertEqual(params['override_custom_receipt_page'], self.CALLBACK_URL) # Parameters determined by the order model self.assertEqual(params['amount'], '10.00') self.assertEqual(params['currency'], 'usd') self.assertEqual(params['orderNumber'], 'OrderId: {order_id}'.format(order_id=self.order.id)) self.assertEqual(params['reference_number'], self.order.id) # Parameters determined by the Django (test) settings self.assertEqual(params['access_key'], '0123456789012345678901') self.assertEqual(params['profile_id'], 'edx') # Some fields will change depending on when the test runs, # so we just check that they're set to a non-empty string self.assertGreater(len(params['signed_date_time']), 0) self.assertGreater(len(params['transaction_uuid']), 0) # Constant parameters self.assertEqual(params['transaction_type'], 'sale') self.assertEqual(params['locale'], 'en') self.assertEqual(params['payment_method'], 'card') self.assertEqual( params['signed_field_names'], ",".join([ 'amount', 'currency', 'orderNumber', 'access_key', 'profile_id', 'reference_number', 'transaction_type', 'locale', 'signed_date_time', 'signed_field_names', 'unsigned_field_names', 'transaction_uuid', 'payment_method', 'override_custom_receipt_page', 'override_custom_cancel_page', ])) self.assertEqual(params['unsigned_field_names'], '') # Check the signature self.assertEqual(params['signature'], self._signature(params))
def test_get_signed_purchase_params(self): params = get_signed_purchase_params(self.order, callback_url=self.CALLBACK_URL) # Check the callback URL override self.assertEqual(params['override_custom_receipt_page'], self.CALLBACK_URL) # Parameters determined by the order model self.assertEqual(params['amount'], '10.00') self.assertEqual(params['currency'], 'usd') self.assertEqual(params['orderNumber'], 'OrderId: {order_id}'.format(order_id=self.order.id)) self.assertEqual(params['reference_number'], self.order.id) # Parameters determined by the Django (test) settings self.assertEqual(params['access_key'], '0123456789012345678901') self.assertEqual(params['profile_id'], 'edx') # Some fields will change depending on when the test runs, # so we just check that they're set to a non-empty string self.assertGreater(len(params['signed_date_time']), 0) self.assertGreater(len(params['transaction_uuid']), 0) # Constant parameters self.assertEqual(params['transaction_type'], 'sale') self.assertEqual(params['locale'], 'en') self.assertEqual(params['payment_method'], 'card') self.assertEqual( params['signed_field_names'], ",".join([ 'amount', 'currency', 'orderNumber', 'access_key', 'profile_id', 'reference_number', 'transaction_type', 'locale', 'signed_date_time', 'signed_field_names', 'unsigned_field_names', 'transaction_uuid', 'payment_method', 'override_custom_receipt_page', 'override_custom_cancel_page', ]) ) self.assertEqual(params['unsigned_field_names'], '') # Check the signature self.assertEqual(params['signature'], self._signature(params))