def test_create(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) merchant = Merchant('test', 'top-secret') amount = Amount(35, 'EUR') name1 = Name('Henk', 'Wijngaarden') shopper = Shopper(12, name1, '*****@*****.**', 'en') name2 = Name('Plat', 'Form') address = Address('s Gravenhekje', '1', 'A', '1011TG', 'Amsterdam', 'NH', 'NL') bill_to = Destination(name2, address) result = self.gateway.create(merchant=merchant, payment_id='123', total_gross_amount=amount, shopper=shopper, bill_to=bill_to, description='Donation', receiptText='Thanks') self.assertEqual(result, { 'order_id': '123-1', 'order_key': 'HAZZAHAZZA' })
def test_status_without_order(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage(PaymentException, 'Missing order_key!'): self.gateway.status(order_key=None)
def test_start_remote_payment(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() payment = DocdataDirectdebitPaymentFactory(order_payment=order_payment) result = self.gateway.start_remote_payment(order_key='123', payment=payment) self.assertEqual(result, 'GHGHGHG')
def test_status(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage(PaymentException, 'Payment not found here...'): self.gateway.status(order_key=123)
def test_start_remote_payment(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() payment = DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage( PaymentException, 'Received unknown reply from DocData. ' 'WebDirect payment not created.'): self.gateway.start_remote_payment(order_key='123', payment=payment)
class DocdataGatewayErrorTestCase(BluebottleTestCase): def test_create(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) merchant = Merchant('test', 'top-secret') amount = Amount(35, 'EUR') name1 = Name('Henk', 'Wijngaarden') shopper = Shopper(12, name1, '*****@*****.**', 'en') name2 = Name('Plat', 'Form') address = Address('s Gravenhekje', '1', 'A', '1011TG', 'Amsterdam', 'NH', 'NL') bill_to = Destination(name2, address) with self.assertRaisesMessage(PaymentException, 'It all went kaboom'): self.gateway.create(merchant=merchant, payment_id='123', total_gross_amount=amount, shopper=shopper, bill_to=bill_to, description='Donation', receiptText='Thanks') def test_start_remote_payment(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() payment = DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage( PaymentException, 'Received unknown reply from DocData. ' 'WebDirect payment not created.'): self.gateway.start_remote_payment(order_key='123', payment=payment) def test_start_remote_payment_without_order(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage(PaymentException, 'Missing order_key!'): self.gateway.start_remote_payment(order_key=None) def test_status(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage(PaymentException, 'Payment not found here...'): self.gateway.status(order_key=123) def test_status_without_order(self, mock_client): credentials = { 'merchant_name': 'test', 'merchant_password': '******', } self.gateway = DocdataClient(credentials) order_payment = OrderPaymentFactory() DocdataDirectdebitPaymentFactory(order_payment=order_payment) with self.assertRaisesMessage(PaymentException, 'Missing order_key!'): self.gateway.status(order_key=None)