Esempio n. 1
0
def transaction_request(req_data):
    token = create_fingerprint(PRIVATE_CERT)
    timestamp = create_timestamp()
    message = "".join([timestamp, req_data['issuer_id'], MERCHANT_ID, SUB_ID,
        req_data['return_url'], req_data['purchase_id'], req_data['amount'],
        CURRENCY, LANGUAGE, req_data['description'], ENTRANCE_CODE])
    token_code = sign_message(PRIVATE_KEY, PRIVATE_KEY_PASS, strip_all(message))
    template = loader.get_template('ideal/trans_req.xml')
    context = Context({
        'timestamp': timestamp,
        'issuer_id': req_data['issuer_id'],
        'merchant_id': MERCHANT_ID,
        'sub_id': SUB_ID,
        'authentication_type': AUTHENTICATION_TYPE,
        'token': token,
        'token_code': token_code,
        'return_url': req_data['return_url'],
        'purchase_id': req_data['purchase_id'],
        'amount': req_data['amount'],
        'currency': CURRENCY,
        'language': LANGUAGE,
        'description': req_data['description'],
        'entrance_code': ENTRANCE_CODE,
        'expiration_period': EXPIRATION_PERIOD
    })
    request_xml = template.render(context)
    response = posthttps(request_xml, *request_params)
    result = parser.parse_response(response, XML_NAMESPACE)
    return result
Esempio n. 2
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
    
Esempio n. 3
0
 def test_parse_dir_res(self):
     fd = open(os.path.join(MODULE_HOME, "dir_res.xml"), "rb")
     resp = fd.read()
     fd.close()
     result = parser.parse_response(resp, namespace=XML_NAMESPACE)
     expected = {
         "acquirerID": "0050",
         "issuers": [{"issuerID": "0151", "issuerList": "Short", "issuerName": "Issuer Simulator"}],
     }
     self.assertEqual(expected, result)
Esempio n. 4
0
 def test_parse_trans_res(self):
     fd = open(os.path.join(MODULE_HOME, "trans_res.xml"), "rb")
     resp = fd.read()
     fd.close()
     result = parser.parse_response(resp, namespace=XML_NAMESPACE)
     expected = {
         "purchaseID": "9459897270157938",
         "transactionID": "1726846372615234",
         "issuerAuthenticationURL": "https://idealtest.rabobank.nl/ideal/issuerSim.do?trxid=1726846372615234&ideal=prob",
         "acquirerID": "0050",
     }
     self.assertEqual(expected, result)
Esempio n. 5
0
 def test_parse_error_res(self):
     fd = open(os.path.join(MODULE_HOME, "error_res.1.xml"), "rb")
     resp = fd.read()
     fd.close()
     result = parser.parse_response(resp, namespace=XML_NAMESPACE)
     expected = {
         "createDateTimeStamp": "2000-12-28T13:59:59.393Z",
         "errorCode": "SE2700",
         "errorMessage": "Invalid electronic signature",
         "errorDetail": None,
         "suggestedAction": None,
         "suggestedExpirationPeriod": None,
         "consumerMessage": "Invalid electronic signature",
     }
     self.assertEqual(expected, result)
Esempio n. 6
0
 def test_parse_status_res(self):
     fd = open(os.path.join(MODULE_HOME, "status_res.xml"), "rb")
     resp = fd.read()
     fd.close()
     result = parser.parse_response(resp, namespace=XML_NAMESPACE)
     expected = {
         "status": "Success",
         "consumerName": None,
         "createDateTimeStamp": "2000-12-28T13:59:59.393Z",
         "fingerprint": None,
         "transactionID": "1726846372615234",
         "consumerAccountNumber": None,
         "consumerCity": "DEN HAAG",
         "signatureValue": None,
     }
     self.assertEqual(expected, result)
Esempio n. 7
0
def directory_request():
    token = create_fingerprint(PRIVATE_CERT)
    timestamp = create_timestamp()
    message = "".join([timestamp, MERCHANT_ID, SUB_ID])
    token_code = sign_message(PRIVATE_KEY, PRIVATE_KEY_PASS, strip_all(message))
    template = loader.get_template('ideal/dir_req.xml')
    context = Context({
        'timestamp': timestamp,
        'merchant_id': MERCHANT_ID,
        'sub_id': SUB_ID,
        'authentication_type': AUTHENTICATION_TYPE,
        'token': token,
        'token_code': token_code
    })
    request_xml = template.render(context)
    response = posthttps(request_xml, *request_params)
    result = parser.parse_response(response, XML_NAMESPACE)
    return result