def testPayment(self): """ Test the initialize7 and complete methods. """ # Needs credentials to test self.assertTrue(all([MERCHANT_NUMBER, ENCRYPTION_KEY])) service = PayEx(merchant_number=MERCHANT_NUMBER, encryption_key=ENCRYPTION_KEY, production=False) # Initialize a payment response = service.initialize( purchaseOperation='AUTHORIZATION', price='5000', currency='NOK', vat='2500', orderID='test1', productNumber='123', description=u'This is a test. åâaä', clientIPAddress='127.0.0.1', clientIdentifier='USERAGENT=test&username=testuser', additionalValues='PAYMENTMENU=TRUE', returnUrl='http://example.org/return', view='PX', cancelUrl='http://example.org/cancel') # Check the response self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('orderRef' in response) self.assertTrue(response['redirectUrl'].startswith( 'https://test-account.payex.com/MiscUI/PxMenu.aspx')) # Try to complete the order (even if it's not started by user) response = service.complete(orderRef=response['orderRef']) self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'NoRecordFound') # Get the transaction details response = service.get_transaction_details(transactionNumber='0') self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'NoRecordFound') # Try to capture a transaction response = service.capture(transactionNumber='0', amount='1000', vatAmount='250') self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'NoRecordFound') # Try to cancel a transaction response = service.cancel(transactionNumber='1') self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'Error_Generic')
def testPayment(self): """ Test the initialize7 and complete methods. """ # Needs credentials to test self.assertTrue(all([MERCHANT_NUMBER, ENCRYPTION_KEY])) service = PayEx( merchant_number=MERCHANT_NUMBER, encryption_key=ENCRYPTION_KEY, production=False ) # Initialize a payment response = service.initialize( purchaseOperation='AUTHORIZATION', price='5000', currency='NOK', vat='2500', orderID='test1', productNumber='123', description=u'This is a test. åâaä', clientIPAddress='127.0.0.1', clientIdentifier='USERAGENT=test&username=testuser', additionalValues='PAYMENTMENU=TRUE', returnUrl='http://example.org/return', view='PX', cancelUrl='http://example.org/cancel' ) # Check the response self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('orderRef' in response) self.assertTrue(response['redirectUrl'].startswith('https://test-account.payex.com/MiscUI/PxMenu.aspx')) # Try to complete the order (even if it's not started by user) response = service.complete(orderRef=response['orderRef']) self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'NoRecordFound') # Get the transaction details response = service.get_transaction_details(transactionNumber='0') self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'NoRecordFound') # Try to capture a transaction response = service.capture( transactionNumber='0', amount='1000', vatAmount='250' ) self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'NoRecordFound') # Try to cancel a transaction response = service.cancel(transactionNumber='1') self.assertEquals(type(response), XmlDictConfig) self.assertEquals(response['status']['errorCode'], 'Error_Generic')