Example #1
0
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
    
Example #2
0
 def test_verify_message(self):
     self.assertEqual(
         True,
         security.verify_message(
             os.path.join(MODULE_HOME, "ideal.cer"),
             "2006-05-10T14:06:52.287Z0050000005922889SuccessP012345678",
             "rlqtzbL5qiIEh4GJB5JmKAOz6aDSY+1NL3y5qigmHj9Fuveyoni5RY78v/tuC76boOqzLuXv6PMA1CYiK1iE7ATfY+/7UlFdc/Qp5qa2ZLjEWa8dAf9e/4KjYmPTNnSdB6VCky0iBUzi54qXwSmqWcuwQE/5pQfod0qYPR2I+8E=",
         ),
     )