Skip to content

Commit

Permalink
Release 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wallee-deployment-user committed Apr 8, 2024
1 parent ef2a8d3 commit 8df8d13
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 16 deletions.
2 changes: 1 addition & 1 deletion postfinancecheckout/api/charge_flow_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def fetch_charge_flow_payment_page_url_with_http_info(self, space_id, id, **kwar
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/plain;charset=utf-8', 'application/json'])
['application/json', 'text/plain;charset=utf-8'])

# Authentication setting
auth_settings = []
Expand Down
2 changes: 1 addition & 1 deletion postfinancecheckout/api/human_user_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def export_with_http_info(self, request, **kwargs):
body_params = params['request']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/csv', 'application/json;charset=utf-8'])
['application/json;charset=utf-8', 'text/csv'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(
Expand Down
2 changes: 1 addition & 1 deletion postfinancecheckout/api/transaction_iframe_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def javascript_url_with_http_info(self, space_id, id, **kwargs):
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/plain;charset=utf-8', 'application/json'])
['application/json', 'text/plain;charset=utf-8'])

# Authentication setting
auth_settings = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def javascript_url_with_http_info(self, space_id, id, **kwargs):
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/plain;charset=utf-8', 'application/json'])
['application/json', 'text/plain;charset=utf-8'])

# Authentication setting
auth_settings = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def payment_form_url_with_http_info(self, credentials, **kwargs):
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/plain;charset=utf-8', 'application/json'])
['application/json', 'text/plain;charset=utf-8'])

# Authentication setting
auth_settings = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def payment_page_url_with_http_info(self, space_id, id, **kwargs):
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/plain;charset=utf-8', 'application/json'])
['application/json', 'text/plain;charset=utf-8'])

# Authentication setting
auth_settings = []
Expand Down
2 changes: 1 addition & 1 deletion postfinancecheckout/api/transaction_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def export_with_http_info(self, space_id, request, **kwargs):
body_params = params['request']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/csv', 'application/json;charset=utf-8'])
['application/json;charset=utf-8', 'text/csv'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(
Expand Down
6 changes: 3 additions & 3 deletions postfinancecheckout/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Python SDK
OpenAPI spec version: 5.0.0
OpenAPI spec version: 5.1.0
"""

Expand Down Expand Up @@ -68,7 +68,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'postfinancecheckout/5.0.0/python'
self.user_agent = 'postfinancecheckout/5.1.0/python'

def __del__(self):
if self._pool is not None:
Expand Down Expand Up @@ -107,7 +107,7 @@ def __call_api(

# predefined default headers
default_headers = {
'x-meta-sdk-version': '5.0.0',
'x-meta-sdk-version': '5.1.0',
'x-meta-sdk-language': 'python',
'x-meta-sdk-provider': 'PostFinance Checkout',
'x-meta-sdk-language-version': platform.python_version()
Expand Down
4 changes: 2 additions & 2 deletions postfinancecheckout/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ def to_debug_report(self):
return "Python SDK Debug Report:\n"\
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 5.0.0\n"\
"SDK Package Version: 5.0.0".\
"Version of the API: 5.1.0\n"\
"SDK Package Version: 5.1.0".\
format(env=sys.platform, pyversion=sys.version)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = fh.read()

NAME = "postfinancecheckout"
VERSION = "5.0.0"
VERSION = "5.1.0"

REQUIRES = [
"certifi >= 14.05.14",
Expand Down
22 changes: 20 additions & 2 deletions test/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from postfinancecheckout import Configuration

from postfinancecheckout.models import (
AddressCreate,
LineItem,
LineItemType,
TransactionCreate,
Expand All @@ -17,7 +18,22 @@


def get_transaction_create():
address = AddressCreate(
city = "Winterthur",
country = "CH",
email_address = "[email protected]",
family_name = "Customer",
given_name = "Good",
postcode = "8400",
postal_state = "ZH",
organization_name = "Test GmbH",
mobile_phone_number = "+41791234567",
salutation = "Ms"
)

return TransactionCreate(
currency="CHF",
auto_confirmation_enabled=True,
line_items=[
LineItem(
name="Blue T-Shirt",
Expand All @@ -28,8 +44,9 @@ def get_transaction_create():
type=LineItemType.PRODUCT,
)
],
auto_confirmation_enabled=True,
currency="CHF",
billing_address=address,
shipping_address=address,
language="en-GB",
)


Expand All @@ -38,4 +55,5 @@ def get_transaction_create():
)

TEST_CARD_PAYMENT_METHOD_CONFIGURATION_ID = 1352
TEST_ISR_INVOICE_PAYMENT_METHOD_CONFIGURATION_ID = 8656
TEST_CUSTOMER_ID = 7311742
81 changes: 81 additions & 0 deletions test/test_charge_attempt_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import unittest

from constants import (
API_CONFIG,
SPACE_ID,
get_transaction_create,
FAKE_CARD_DATA,
TEST_CARD_PAYMENT_METHOD_CONFIGURATION_ID,
TEST_CUSTOMER_ID,
)

from postfinancecheckout.api import (
TransactionServiceApi,
CardProcessingServiceApi,
ChargeAttemptServiceApi
)
from postfinancecheckout.models import (
TransactionState,
EntityQuery,
EntityQueryFilter,
EntityQueryFilterType,
CriteriaOperator,
TokenizationMode,
TransactionCompletionBehavior,
CustomersPresence,
)

class ChargeAttemptServiceTest(unittest.TestCase):
"""ChargeAttemptServiceApi tests"""

def setUp(self):
self.transaction_service = TransactionServiceApi(API_CONFIG)
self.card_processing_service = CardProcessingServiceApi(API_CONFIG)
self.charge_attempt_service = ChargeAttemptServiceApi(API_CONFIG)

def tearDown(self):
pass

def test_search(self):
"""search() should find charge attempts by given criteria"""

transaction_create = get_transaction_create()
transaction_create.tokenization_mode = TokenizationMode.FORCE_CREATION
transaction_create.customers_presence = CustomersPresence.NOT_PRESENT
transaction_create.completion_behavior = TransactionCompletionBehavior.COMPLETE_DEFERRED

transaction = self.transaction_service.create(
space_id=SPACE_ID, transaction=transaction_create)
transaction_processed = self.card_processing_service.process(
space_id=SPACE_ID,
transaction_id=transaction.id,
payment_method_configuration_id=TEST_CARD_PAYMENT_METHOD_CONFIGURATION_ID,
card_data=FAKE_CARD_DATA,
)

self.assertEqual(
TransactionState.AUTHORIZED,
transaction_processed.state,
"State must be AUTHORIZED",
)

entity_query_filter = EntityQueryFilter(
field_name="charge.transaction.id",
value=transaction.id,
type=EntityQueryFilterType.LEAF,
operator=CriteriaOperator.EQUALS,
)
entity_query = EntityQuery(filter=entity_query_filter)

attempts_found = self.charge_attempt_service.search(
space_id=SPACE_ID, query=entity_query)

self.assertTrue(len(attempts_found) > 0)
for attempt in attempts_found:
self.assertEqual(transaction.id, attempt.linked_transaction)

# TODO write more API tests


if __name__ == "__main__":
unittest.main(failfast=True)
132 changes: 132 additions & 0 deletions test/test_transaction_invoice_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import unittest

from constants import (
API_CONFIG,
SPACE_ID,
get_transaction_create,
FAKE_CARD_DATA,
TEST_CARD_PAYMENT_METHOD_CONFIGURATION_ID,
TEST_ISR_INVOICE_PAYMENT_METHOD_CONFIGURATION_ID,
)

from postfinancecheckout.api import (
TransactionServiceApi,
CardProcessingServiceApi,
TransactionInvoiceServiceApi,
TransactionCompletionServiceApi,
)
from postfinancecheckout.models import (
TransactionState,
TransactionInvoiceState,
EntityQuery,
EntityQueryFilter,
EntityQueryFilterType,
CriteriaOperator,
TokenizationMode,
TransactionCompletionBehavior,
CustomersPresence,
)


class TransactionInvoiceServiceTest(unittest.TestCase):
"""TransactionInvoiceServiceApi tests"""

def setUp(self):
self.transaction_service = TransactionServiceApi(API_CONFIG)
self.transaction_invoice_service = TransactionInvoiceServiceApi(API_CONFIG)
self.transaction_completion_service = TransactionCompletionServiceApi(
API_CONFIG)
self.card_processing_service = CardProcessingServiceApi(API_CONFIG)

def tearDown(self):
pass

def test_search(self):
"""search() should find transaction invoice by a given criteria"""

transaction_create = get_transaction_create()
transaction_create.tokenization_mode = TokenizationMode.FORCE_CREATION
transaction_create.customers_presence = CustomersPresence.NOT_PRESENT
transaction_create.completion_behavior = TransactionCompletionBehavior.COMPLETE_IMMEDIATELY
transaction = self.transaction_service.create(space_id=SPACE_ID, transaction=transaction_create)

transaction_processed = self.card_processing_service.process(
space_id=SPACE_ID,
transaction_id=transaction.id,
payment_method_configuration_id=TEST_CARD_PAYMENT_METHOD_CONFIGURATION_ID,
card_data=FAKE_CARD_DATA,
)

self.assertEqual(
TransactionState.FULFILL,
transaction_processed.state,
"State must be FULFILL",
)

entity_query_filter = EntityQueryFilter(
# linkedTransaction does not work here as criteria
field_name="completion.lineItemVersion.transaction.id",
value=transaction_processed.id,
type=EntityQueryFilterType.LEAF,
operator=CriteriaOperator.EQUALS,
)
entity_query = EntityQuery(filter=entity_query_filter)

invoices_found = self.transaction_invoice_service.search(
space_id=SPACE_ID, query=entity_query)

self.assertTrue(len(invoices_found) > 0,
"Should find invoice", )

for invoice in invoices_found:
self.assertEqual(TransactionInvoiceState.NOT_APPLICABLE, invoice.state,
"Invoice paid by card is expected to be of NOT_APPLICABLE state")



def test_derecognize_transaction_invoice(self):
"""mark_as_derecognized() should derecognize open invoice"""

transaction_create = get_transaction_create()
transaction_create.tokenization_mode = TokenizationMode.FORCE_CREATION
transaction_create.customers_presence = CustomersPresence.NOT_PRESENT
transaction_create.completion_behavior = TransactionCompletionBehavior.COMPLETE_DEFERRED

# we want invoice in OPEN state (OPEN invoices can be derecognized), so we force payment by invoice
transaction_create.allowed_payment_method_configurations = [TEST_ISR_INVOICE_PAYMENT_METHOD_CONFIGURATION_ID]
transaction = self.transaction_service.create(space_id=SPACE_ID, transaction=transaction_create)

transaction_processed = self.transaction_service.process_without_user_interaction(
space_id=SPACE_ID, id=transaction.id)

transaction_completion = self.transaction_completion_service.complete_online(
space_id=SPACE_ID, id=transaction_processed.id)

entity_query_filter = EntityQueryFilter(
field_name="completion.lineItemVersion.transaction.id",
value=transaction_processed.id,
type=EntityQueryFilterType.LEAF,
operator=CriteriaOperator.EQUALS,
)
entity_query = EntityQuery(filter=entity_query_filter)

invoices_found = self.transaction_invoice_service.search(
space_id=SPACE_ID, query=entity_query)

self.assertTrue(len(invoices_found) > 0,
"Should find invoice", )

found_invoice = invoices_found[0]

self.assertEqual(TransactionInvoiceState.OPEN, found_invoice.state,
"Transaction paid by invoice should create invoice in OPEN state" )

derecognized_invoice = self.transaction_invoice_service.mark_as_derecognized(
space_id=SPACE_ID, id=found_invoice.id);

self.assertEqual(TransactionInvoiceState.DERECOGNIZED, derecognized_invoice.state,
"Expected DERECOGNIZED invoice state")


if __name__ == "__main__":
unittest.main(failfast=True)
2 changes: 1 addition & 1 deletion test/test_transaction_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_fetch_one_click_tokens_with_credentials_no_tokens(self):
self.assertEqual(0, len(tokens), "Should be no tokens yet")

def test_fetch_payment_methods_with_credentials(self):
"""fetch_one_click_tokens_with_credentials() should return one-click payment tokens (if any) for provided transaction"""
"""fetch_payment_methods_with_credentials() should return payment methods (if any) for credentials"""

transaction = self.transaction_service.create(
space_id=SPACE_ID, transaction=get_transaction_create())
Expand Down

0 comments on commit 8df8d13

Please sign in to comment.