def status_request(transaction_id): token = create_fingerprint(PRIVATE_CERT) timestamp = create_timestamp() message = "".join([timestamp, MERCHANT_ID, SUB_ID, transaction_id]) token_code = sign_message(PRIVATE_KEY, PRIVATE_KEY_PASS, strip_all(message)) template = loader.get_template('ideal/status_req.xml') context = Context({ 'timestamp': timestamp, 'merchant_id': MERCHANT_ID, 'sub_id': SUB_ID, 'authentication_type': AUTHENTICATION_TYPE, 'token': token, 'token_code': token_code, 'transaction_id': transaction_id }) status_request = template.render(context) response = posthttps(status_request, *request_params) status = parser.parse_response(response, XML_NAMESPACE) if status.get('errorCode'): return status # verify message certificate = get_certificate_name(status['fingerprint'], CERTIFICATES) if certificate: if verify_message(certificate, strip_all("".join([status['createDateTimeStamp'], status['transactionID'], status['status'], status['consumerAccountNumber']])), status['signatureValue']): return status return False
def test_get_certificate_name(self): cert_name = "ideal.cer" cert_path = os.path.join(MODULE_HOME, cert_name) self.assertEqual( cert_path, security.get_certificate_name("03A07E0584AF7F715CEBD3702477555C52F11AEF", (cert_path,)) )