def test_find_transaction_multiple_resources_error(self):
        responses.add(
            responses.GET, self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_multiple.xml'),
            status=200, content_type='application/xml')

        with self.assertRaises(MultipleResourcesError):
            Transaction.find('TEST-TRANSACTION-ID', self.api)
Exemple #2
0
    def test_find_transaction_multiple_resources_error(self):
        responses.add(
            responses.POST,
            self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_multiple.xml'),
            status=200,
            content_type='application/xml')

        with self.assertRaises(MultipleResourcesError):
            Transaction.find('TEST-TRANSACTION-ID', self.api)
    def test_find_transaction_multiple_resources_error(self):
        responses.add(
            responses.POST,
            self.get_api_url("API/payments"),
            body=self.load_xml_response("200_find_transaction_multiple.xml"),
            status=200,
            content_type="application/xml",
        )

        with self.assertRaises(MultipleResourcesError):
            Transaction.find("TEST-TRANSACTION-ID", self.api)
Exemple #4
0
    def test_charge_subscription_single(self):
        responses.add(
            responses.POST,
            self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200,
            content_type='application/xml')

        # Note, this transaction technically isn't a valid subscription,
        # but it will do
        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        responses.add(
            responses.POST,
            self.get_api_url('API/chargeSubscription'),
            body=self.load_xml_response('200_charge_subscription_single.xml'),
            status=200,
            content_type='application/xml')

        callback = transaction.charge_subscription(amount=13.95)

        self.assertIsInstance(callback, Callback)

        self.assertEqual(len(callback.transactions()), 2)
        for transaction in callback.transactions():
            self.assertIsInstance(transaction, Transaction)
    def test_charge_subscription_single(self):
        responses.add(
            responses.POST,
            self.get_api_url("API/payments"),
            body=self.load_xml_response("200_find_transaction_single.xml"),
            status=200,
            content_type="application/xml",
        )

        # Note, this transaction technically isn't a valid subscription,
        # but it will do
        transaction = Transaction.find("TEST-TRANSACTION-ID", self.api)

        responses.add(
            responses.POST,
            self.get_api_url("API/chargeSubscription"),
            body=self.load_xml_response("200_charge_subscription_single.xml"),
            status=200,
            content_type="application/xml",
        )

        callback = transaction.charge_subscription(amount=13.95)

        self.assertIsInstance(callback, Callback)

        self.assertEqual(len(callback.transactions()), 2)
        for transaction in callback.transactions():
            self.assertIsInstance(transaction, Transaction)
    def test_find_transaction_success(self):
        responses.add(
            responses.GET, self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200, content_type='application/xml')

        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        # Test both for unpacking of single values and nested structures
        self.assertEqual(transaction.card_status, 'Valid')
        self.assertEqual(
            transaction.payment_nature_service['supports_refunds'], True)
    def test_find_transaction_success(self):
        responses.add(
            responses.POST,
            self.get_api_url("API/payments"),
            body=self.load_xml_response("200_find_transaction_single.xml"),
            status=200,
            content_type="application/xml",
        )

        transaction = Transaction.find("TEST-TRANSACTION-ID", self.api)

        # Test both for unpacking of single values and nested structures
        self.assertEqual(transaction.card_status, "Valid")
        self.assertEqual(transaction.payment_nature_service["supports_refunds"], True)
Exemple #8
0
    def test_find_transaction_success(self):
        responses.add(
            responses.POST,
            self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200,
            content_type='application/xml')

        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        # Test both for unpacking of single values and nested structures
        self.assertEqual(transaction.card_status, 'Valid')
        self.assertEqual(
            transaction.payment_nature_service['supports_refunds'], True)
    def test_release_reservation(self):
        responses.add(
            responses.GET, self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200, content_type='application/xml')

        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        responses.add(
            responses.GET, self.get_api_url('API/releaseReservation'),
            body=self.load_xml_response('200_release_reservation.xml'),
            status=200, content_type='application/xml')

        callback = transaction.release()

        self.assertEqual(callback.result, 'Success')
        self.assertEqual(len(callback.transactions()), 1)
    def test_capture_transaction_simple(self):
        responses.add(
            responses.GET, self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200, content_type='application/xml')

        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        self.assertEqual(transaction.captured_amount, 0.0)

        responses.add(
            responses.GET, self.get_api_url('API/captureReservation'),
            body=self.load_xml_response('200_capture_response.xml'),
            status=200, content_type='application/xml')

        transaction = transaction.capture()

        self.assertEqual(transaction.captured_amount, 13.29)
Exemple #11
0
    def test_release_reservation(self):
        responses.add(
            responses.POST,
            self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200,
            content_type='application/xml')

        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        responses.add(
            responses.POST,
            self.get_api_url('API/releaseReservation'),
            body=self.load_xml_response('200_release_reservation.xml'),
            status=200,
            content_type='application/xml')

        callback = transaction.release()

        self.assertEqual(callback.result, 'Success')
        self.assertEqual(len(callback.transactions()), 1)
Exemple #12
0
    def test_capture_transaction_simple(self):
        responses.add(
            responses.POST,
            self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200,
            content_type='application/xml')

        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        self.assertEqual(transaction.captured_amount, 0.0)

        responses.add(responses.POST,
                      self.get_api_url('API/captureReservation'),
                      body=self.load_xml_response('200_capture_response.xml'),
                      status=200,
                      content_type='application/xml')

        callback = transaction.capture()

        self.assertEqual(callback.transactions()[0].captured_amount, 13.29)
    def test_reserve_subscription_single(self):
        responses.add(
            responses.GET, self.get_api_url('API/payments'),
            body=self.load_xml_response('200_find_transaction_single.xml'),
            status=200, content_type='application/xml')

        # Note, this transaction technically isn't a valid subscription,
        # but it will do
        transaction = Transaction.find('TEST-TRANSACTION-ID', self.api)

        responses.add(
            responses.GET, self.get_api_url('API/reserveSubscriptionCharge'),
            body=self.load_xml_response('200_charge_subscription_single.xml'),
            status=200, content_type='application/xml')

        callback = transaction.reserve_subscription_charge(amount=13.95)

        self.assertIsInstance(callback, Callback)

        self.assertEqual(len(callback.transactions()), 2)
        for transaction in callback.transactions():
            self.assertIsInstance(transaction, Transaction)
    def test_release_reservation(self):
        responses.add(
            responses.POST,
            self.get_api_url("API/payments"),
            body=self.load_xml_response("200_find_transaction_single.xml"),
            status=200,
            content_type="application/xml",
        )

        transaction = Transaction.find("TEST-TRANSACTION-ID", self.api)

        responses.add(
            responses.POST,
            self.get_api_url("API/releaseReservation"),
            body=self.load_xml_response("200_release_reservation.xml"),
            status=200,
            content_type="application/xml",
        )

        callback = transaction.release()

        self.assertEqual(callback.result, "Success")
        self.assertEqual(len(callback.transactions()), 1)
    def test_capture_transaction_simple(self):
        responses.add(
            responses.POST,
            self.get_api_url("API/payments"),
            body=self.load_xml_response("200_find_transaction_single.xml"),
            status=200,
            content_type="application/xml",
        )

        transaction = Transaction.find("TEST-TRANSACTION-ID", self.api)

        self.assertEqual(transaction.captured_amount, 0.0)

        responses.add(
            responses.POST,
            self.get_api_url("API/captureReservation"),
            body=self.load_xml_response("200_capture_response.xml"),
            status=200,
            content_type="application/xml",
        )

        callback = transaction.capture()

        self.assertEqual(callback.transactions()[0].captured_amount, 13.29)
}

res.create(**params)


print "--- RESERVATION ---"
print res.success
print res.error_message


print "--- CAPTURE ---"
#parse transaction from reservation response object
transaction = res.__data__.values()[1]["transaction"]

#find existing transaction on payment gateway by transaciton id
trans = Transaction.find(transaction['transaction_id'],api=api)
print trans


#define params for advanced transaction - can be empty
transParams = {
    'transaction_id': transaction["transaction_id"],
    'reconciliation_identifier': transaction["shop_order_id"],
    'invoice_number': transaction["shop_order_id"],
    'orderLines': [
        {
            'description': 'Description of the order line',
            'itemId': '123456',
            'quantity': 1,
            'unitPrice': 500,
            'taxAmount': 1000,
    if path.endswith("/python-client-library"):
        sdkPathExists=True
if sdkPathExists is False:
    print "Path to python-client-library does not exist, update your environment variable, or put sys.path.append('/absolute_path_to/python-cliend-library') before including altapay sdk modules"
    sys.exit()

from altapay import API, UpdateOrder, Transaction

api = API(mode='test',account='shop api', password='******',  url='http://gateway.dev.earth.pensio.com/merchant/')


# CAPTURE: ======================================================================

paymentId = "117" # PUT A PAYMENT ID FROM A PREVIOUSLY CREATED ORDER HERE

transaction = Transaction.find(paymentId, api)

capture = transaction.capture()

if capture.error_code == 0 and capture.result == 'Success':
    print ("Successful capture!")
else:
    print "capture Error code: " + str(capture.error_code)
    print "capture Error message: " + capture.error_message
    print "capture Result: " + capture.result
    print "capture Merchant error message: " + capture.merchant_error_message

# UPDATE ORDER: ==================================================================

update_order = UpdateOrder(api = api)