def testValidHash(self): params = {u'ORDERID': u'13', u'STATUS': u'9', u'CARDNO': u'XXXXXXXXXXXX1111', u'VC': u'NO', u'PAYID': u'8285812', u'CN': u'Kaast Achternaam', u'NCERROR': u'0', u'IP': u'82.139.114.10', u'IPCTY': u'NL', u'CURRENCY': u'EUR', u'CCCTY': u'US', u'AAVCHECK': u'NO', u'BRAND': u'VISA', u'ACCEPTANCE': u'test123', u'ECI': u'7', u'TRXDATE': u'09/24/10', u'AMOUNT': u'6794.81', u'CVCCHECK': u'NO', u'ED': u'0111', u'PM': u'CreditCard'} params['SHASIGN'] = security.OgoneSignature(params, self.settings.HASH_METHOD, self.settings.SHA_POST_SECRET).signature() o = self.ogone(params, settings=self.settings) self.assert_(o.is_valid())
def testForm(self): data = {'orderID': 14, 'ownerstate': u'', 'cn': u'Kaast Achternaam', 'language': 'en_US', 'ownertown': u'Klaas', 'ownercty': u'NL', 'exceptionurl': u'http://127.0.0.1:8000/shop/checkout/ogone/failure/', 'ownerzip': u'Postcode', 'catalogurl': u'http://127.0.0.1:8000/shop/category/', 'currency': u'EUR', 'amount': u'579', 'declineurl': u'http://127.0.0.1:8000/shop/checkout/ogone/failure/', 'homeurl': u'http://127.0.0.1:8000/shop/', 'cancelurl': u'http://127.0.0.1:8000/shop/checkout/ogone/failure/', 'accepturl': u'http://127.0.0.1:8000/shop/checkout/ogone/success/', 'owneraddress': u'Straat', 'com': u'Order #14: Kaast Achternaam', 'email': u'*****@*****.**'} data['PSPID'] = self.settings.PSPID shasign = security.OgoneSignature(data, self.settings.HASH_METHOD, self.settings.SHA_PRE_SECRET).signature() form = self.ogone.get_form(data, settings=self.settings) self.assertEqual(form['SHASign'].field.initial, shasign)
def testParseParams(self): params = {u'ORDERID': u'13', u'STATUS': u'9', u'CARDNO': u'XXXXXXXXXXXX1111', u'VC': u'NO', u'PAYID': u'8285812', u'CN': u'Kaast Achternaam', u'NCERROR': u'0', u'IP': u'82.139.114.10', u'IPCTY': u'NL', u'CURRENCY': u'EUR', u'CCCTY': u'US', u'AAVCHECK': u'NO', u'BRAND': u'VISA', u'ACCEPTANCE': u'test123', u'ECI': u'7', u'TRXDATE': u'09/24/10', u'AMOUNT': u'6794.81', u'CVCCHECK': u'NO', u'ED': u'0111', u'PM': u'CreditCard'} params['SHASIGN'] = security.OgoneSignature(params, self.settings.HASH_METHOD, self.settings.SHA_POST_SECRET).signature() o = self.ogone(params, settings=self.settings) o.parse_params() self.assertEqual(o.get_order_id(), 13) self.assertEqual(o.get_status(), 9) self.assertEqual(o.get_status_description(), 'Payment requested') self.assertEqual(o.get_transaction_date(), datetime.date(2010, 9, 24)) self.assertEqual(o.get_expiry_date(), datetime.date(2011, 1, 1))
def sign(data, hash_method=None, secret=None, out=False, settings=ogone_settings): """ Sign the given data. """ if not hash_method: hash_method = settings.HASH_METHOD if not secret: if out: secret = settings.SHA_POST_SECRET else: secret = settings.SHA_PRE_SECRET return ogone_security.OgoneSignature(data, hash_method=hash_method, secret=secret).signature()