def testStatelessness(self): """ Test for an earlier bug, did not reset hash for new requests. """ # Needs credentials to test self.assertTrue(all([MERCHANT_NUMBER, ENCRYPTION_KEY])) service = PayEx(merchant_number=MERCHANT_NUMBER, encryption_key=ENCRYPTION_KEY, production=False) # Create an agreement response = service.create_agreement( merchantRef='oneclick', description=u'One-click shopping æøåÆØÅ', purchaseOperation='SALE', maxAmount='100000', ) # Create another agreement response = service.create_agreement( merchantRef='oneclick', description=u'One-click shopping æøåÆØÅ', purchaseOperation='SALE', maxAmount='100000', ) # Ensure that the response is still valid self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('agreementRef' in response)
def testStatelessness(self): """ Test for an earlier bug, did not reset hash for new requests. """ # Needs credentials to test self.assertTrue(all([MERCHANT_NUMBER, ENCRYPTION_KEY])) service = PayEx( merchant_number=MERCHANT_NUMBER, encryption_key=ENCRYPTION_KEY, production=False ) # Create an agreement response = service.create_agreement( merchantRef='oneclick', description=u'One-click shopping æøåÆØÅ', purchaseOperation='SALE', maxAmount='100000', ) # Create another agreement response = service.create_agreement( merchantRef='oneclick', description=u'One-click shopping æøåÆØÅ', purchaseOperation='SALE', maxAmount='100000', ) # Ensure that the response is still valid self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('agreementRef' in response)
def testAgreementHandlers(self): """ Test the various agreement handlers. """ # Needs credentials to test self.assertTrue(all([MERCHANT_NUMBER, ENCRYPTION_KEY])) service = PayEx(merchant_number=MERCHANT_NUMBER, encryption_key=ENCRYPTION_KEY, production=False) # Create an agreement response = service.create_agreement( merchantRef='oneclick', description=u'One-click shopping æøåÆØÅ', purchaseOperation='AUTHORIZATION', maxAmount='100000', ) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('agreementRef' in response) self.assertFalse('existingAgreementRef' in response) agreement_ref = response['agreementRef'] # Initialize the payment response = service.initialize( purchaseOperation='AUTHORIZATION', price='5000', currency='NOK', vat='2500', orderID='test2', productNumber='123', description=u'This is a test with øæå.', clientIPAddress='127.0.0.1', clientIdentifier='USERAGENT=test&username=testuser', additionalValues='PAYMENTMENU=TRUE', returnUrl='http://example.org/return', view='PX', agreementRef=agreement_ref, cancelUrl='http://example.org/cancel') self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('redirectUrl' in response) self.assertTrue(response['orderRef'] in response['redirectUrl']) # 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') # AutoPay with the agreement response = service.autopay(purchaseOperation='SALE', agreementRef=agreement_ref, price='1000', productNumber='123', description=u'This is a test with øæå.', orderId='900') self.assertEquals(response['status']['errorCode'], 'AgreementNotVerified') # Check the agreement response = service.check_agreement(agreementRef=agreement_ref) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertEquals(response['agreementStatus'], '0') # Delete the agreement response = service.delete_agreement(agreementRef=agreement_ref) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK')
def testAgreementHandlers(self): """ Test the various agreement handlers. """ # Needs credentials to test self.assertTrue(all([MERCHANT_NUMBER, ENCRYPTION_KEY])) service = PayEx( merchant_number=MERCHANT_NUMBER, encryption_key=ENCRYPTION_KEY, production=False ) # Create an agreement response = service.create_agreement( merchantRef='oneclick', description=u'One-click shopping æøåÆØÅ', purchaseOperation='AUTHORIZATION', maxAmount='100000', ) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('agreementRef' in response) self.assertFalse('existingAgreementRef' in response) agreement_ref = response['agreementRef'] # Initialize the payment response = service.initialize( purchaseOperation='AUTHORIZATION', price='5000', currency='NOK', vat='2500', orderID='test2', productNumber='123', description=u'This is a test with øæå.', clientIPAddress='127.0.0.1', clientIdentifier='USERAGENT=test&username=testuser', additionalValues='PAYMENTMENU=TRUE', returnUrl='http://example.org/return', view='PX', agreementRef=agreement_ref, cancelUrl='http://example.org/cancel' ) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertTrue('redirectUrl' in response) self.assertTrue(response['orderRef'] in response['redirectUrl']) # 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') # AutoPay with the agreement response = service.autopay( purchaseOperation='SALE', agreementRef=agreement_ref, price='1000', productNumber='123', description=u'This is a test with øæå.', orderId='900' ) self.assertEquals(response['status']['errorCode'], 'AgreementNotVerified') # Check the agreement response = service.check_agreement(agreementRef=agreement_ref) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK') self.assertEquals(response['agreementStatus'], '0') # Delete the agreement response = service.delete_agreement(agreementRef=agreement_ref) self.assertEquals(response['status']['description'], 'OK') self.assertEquals(response['status']['errorCode'], 'OK')