From 35c420876a9abfb9da7fed031118811f2ee10b18 Mon Sep 17 00:00:00 2001 From: Blackfaded Date: Wed, 21 Aug 2024 12:28:09 +0200 Subject: [PATCH 1/6] chore: rename job --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4c578e1..a47305e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,5 +23,5 @@ jobs: run: ./scripts.sh install - name: Run Build run: ./scripts.sh build - - name: Run Tests + - name: Run Publish run: ./scripts.sh publish ${{ secrets.PYPI_TOKEN }} From cc2f8ec267ec87d68742897fe8480318fa343de0 Mon Sep 17 00:00:00 2001 From: Dirk Ehrhardt Date: Wed, 21 Aug 2024 14:11:08 +0200 Subject: [PATCH 2/6] chore: add github release documentation --- README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ac096b..2be9efb 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ Welcome to the Python SDK for the PAYONE Commerce Platform! This repository cont - [Preparing the Release](#preparing-the-release) - [Changelog Generation with Conventional Changelog](#changelog-generation-with-conventional-changelog) - [Merging the Release Branch](#merging-the-release-branch) + - [GitHub Action for Release](#github-action-for-release) + - [Optional: Creating a GitHub Release](#optional-creating-a-github-release) - [License](#license) ## Features @@ -95,6 +97,8 @@ When a client is successfully made a payment via ApplePay it receives a [ApplePa API_KEY=api_key API_SECRET=api_secret MERCHANT_ID=123 COMMERCE_CASE_ID=234 CHECKOUT_ID=345 python3 example/main.py ``` +**[back to top](#table-of-contents)** + ## Contributing We welcome contributions from the community. If you want to contribute, please follow these steps: @@ -164,8 +168,33 @@ After calling the `prepare_release.sh` script, it is recommended to manually tri #### Merging the Release Branch -- Create PR on develop branch -- Merge develop in main branch +- Create PR on `develop` branch +- Merge `develop` in `main` branch + +#### GitHub Action for Release + +After successfully merging all changes to the `main` branch, an admin can trigger a GitHub Action to finalize and publish the release. This action ensures that the release process is automated, consistent, and deploys the new release from the `main` branch. + +**Triggering the GitHub Action**: + +- Only admins can trigger the release action. +- Ensure that all changes are committed to the `main` branch. +- Navigate to the Actions tab on your GitHub repository and manually trigger the release action for the `main` branch. + +#### Optional: Creating a GitHub Release + +Once the release has been published to PyPi, developers can start using the latest version of the SDK. However, if you want to make the release more visible and include detailed release notes, you can optionally create a GitHub release. + +1. **Navigate to the Releases Page**: Go to the "Releases" section of your repository on GitHub. +2. **Draft a New Release**: Click "Draft a new release". +3. **Tag the Release**: Select the version tag that corresponds to the version you just published on npm (e.g., `v0.1.0`). +4. **Release Title**: Add a descriptive title for the release (e.g., `v0.1.0 - Initial Release`). +5. **Auto-Generated Release Notes**: GitHub can automatically generate release notes based on merged pull requests and commit history. You can review these notes, adjust the content, and highlight important changes. +6. **Publish the Release**: Once you're satisfied with the release notes, click "Publish release". + +Creating a GitHub release is optional, but it can provide additional context and visibility for your users. For detailed guidance, refer to the [GitHub documentation on managing releases](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository). + +**[back to top](#table-of-contents)** ## License From ebdae42561c980a022650fef5154b84fe853379c Mon Sep 17 00:00:00 2001 From: Dirk Ehrhardt Date: Thu, 22 Aug 2024 10:19:51 +0200 Subject: [PATCH 3/6] docs: add contributing guidelines and update readme --- CONTRIBUTING.md | 36 ++++++++++++++++++++++++++++ README.md | 62 ++++++++++++++++++------------------------------- 2 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..120c82b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,36 @@ +# Contributing to the PAYONE Commerce Platform Python SDK + +Thank you for considering contributing to the PAYONE Commerce Platform Python SDK! We appreciate your efforts to help improve this project. Below are guidelines for contributing. + +## How to Contribute + +### Pull Requests + +We welcome pull requests! Please follow these steps to submit one: + +1. **Fork** the repository and create your branch from `main`. +2. **Install** any dependencies and ensure the project builds and passes tests. + + ```sh + # setup python environment + ./scripts.sh setup + # install deps + ./scripts.sh install + # build + ./scripts.sh build + ``` + +3. **Develop** your changes. +4. **Test** your changes thoroughly. + ```sh + ./scripts.sh test + ``` +5. **Write** clear, concise, and self-explanatory commit messages. +6. **Open** a pull request with a clear title and description of what your change does. + +### Reporting Bugs + +If you encounter any bugs, please report them using one of the following methods: + +1. **Issue Tracker**: Submit an issue through our [issues tracker](https://github.com/PAYONE-GmbH/PCP-ServerSDK-python/issues/new). +2. **Security Issues**: For security-related issues, please contact our IT support via email at tech.support@payone.com with a clear subject line indicating that it is a security issue. This ensures that the issue will be visible to and handled by the PAYONE tech support team. diff --git a/README.md b/README.md index 2be9efb..e5198a0 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,18 @@ Welcome to the Python SDK for the PAYONE Commerce Platform! This repository cont - [Features](#features) - [Installation](#installation) - [Usage](#usage) + - [General](#general) - [Error Handling](#error-handling) - [Client Side](#client-side) - [Apple Pay](#apple-pay) - [Demo App](#demo-app) - [Contributing](#contributing) - - [Build the library](#build-the-library) - - [Run tests](#run-tests) - - [Releasing the library](#releasing-the-library) - - [Preparing the Release](#preparing-the-release) - - [Changelog Generation with Conventional Changelog](#changelog-generation-with-conventional-changelog) - - [Merging the Release Branch](#merging-the-release-branch) - - [GitHub Action for Release](#github-action-for-release) - - [Optional: Creating a GitHub Release](#optional-creating-a-github-release) +- [Releasing the library](#releasing-the-library) + - [Preparing the Release](#preparing-the-release) + - [Changelog Generation with Conventional Changelog](#changelog-generation-with-conventional-changelog) + - [Merging the Release Branch](#merging-the-release-branch) + - [GitHub Action for Release](#github-action-for-release) + - [Optional: Creating a GitHub Release](#optional-creating-a-github-release) - [License](#license) ## Features @@ -40,8 +39,12 @@ Welcome to the Python SDK for the PAYONE Commerce Platform! This repository cont python3 -m pip install "pcp_serversdk_python" ``` +**[back to top](#table-of-contents)** + ## Usage +### General + To use this SDK you need to construct a `CommunicatorConfiguration` which encapsulate everything needed to connect to the PAYONE Commerce Platform. ```python @@ -91,7 +94,9 @@ When a client is successfully made a payment via ApplePay it receives a [ApplePa # TODO ``` -### Run the example app +**[back to top](#table-of-contents)** + +## Demo App ```sh API_KEY=api_key API_SECRET=api_secret MERCHANT_ID=123 COMMERCE_CASE_ID=234 CHECKOUT_ID=345 python3 example/main.py @@ -101,36 +106,13 @@ API_KEY=api_key API_SECRET=api_secret MERCHANT_ID=123 COMMERCE_CASE_ID=234 CHECK ## Contributing -We welcome contributions from the community. If you want to contribute, please follow these steps: - -Fork the repository. -Create a new branch (`git checkout -b feature/feature-branch`). -Make your changes. -Commit your changes (`git commit -am 'feat: add new feature'`). -Push to the branch (`git push origin feature/feature-branch`). -Create a new Pull Request. -Please make sure to follow the coding standards and write appropriate tests for your changes. - -### Build the library +See [Contributing](./CONTRIBUTING.md) -```sh -# setup python environment -./scripts.sh setup -# install deps -./scripts.sh install -# build -./scripts.sh build -``` - -### Run tests - -```sh -./scripts.sh test -``` +**[back to top](#table-of-contents)** -### Releasing the library +## Releasing the library -#### Preparing the Release +### Preparing the Release - Checkout develop branch - Create release branch (release/0.1.0) @@ -145,7 +127,7 @@ git checkout -b release/0.1.0 ./prepare-release.sh ``` -#### Changelog Generation with Conventional Changelog +### Changelog Generation with Conventional Changelog After calling the `prepare_release.sh` script, it is recommended to manually trigger the changelog generation script (which uses [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog)). @@ -166,12 +148,12 @@ After calling the `prepare_release.sh` script, it is recommended to manually tri ``` - Review and commit the updated changelog before proceeding with the release. -#### Merging the Release Branch +### Merging the Release Branch - Create PR on `develop` branch - Merge `develop` in `main` branch -#### GitHub Action for Release +### GitHub Action for Release After successfully merging all changes to the `main` branch, an admin can trigger a GitHub Action to finalize and publish the release. This action ensures that the release process is automated, consistent, and deploys the new release from the `main` branch. @@ -181,7 +163,7 @@ After successfully merging all changes to the `main` branch, an admin can trigge - Ensure that all changes are committed to the `main` branch. - Navigate to the Actions tab on your GitHub repository and manually trigger the release action for the `main` branch. -#### Optional: Creating a GitHub Release +### Optional: Creating a GitHub Release Once the release has been published to PyPi, developers can start using the latest version of the SDK. However, if you want to make the release more visible and include detailed release notes, you can optionally create a GitHub release. From 91cf4d6f3a694e2916a93c36060a8636a0fa989f Mon Sep 17 00:00:00 2001 From: Dirk Ehrhardt Date: Thu, 22 Aug 2024 11:17:11 +0200 Subject: [PATCH 4/6] chore: add handling for "return" field in model --- pcp_serversdk_python/models/RefundRequest.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pcp_serversdk_python/models/RefundRequest.py b/pcp_serversdk_python/models/RefundRequest.py index 2740e06..9a3d5be 100644 --- a/pcp_serversdk_python/models/RefundRequest.py +++ b/pcp_serversdk_python/models/RefundRequest.py @@ -10,7 +10,22 @@ class RefundRequest: amountOfMoney: Optional[PositiveAmountOfMoney] = None references: Optional[PaymentReferences] = None - # TODO: Check if this works for the reserved word - return_: Optional[ReturnInformation] = field( + # "return" is a reserved keyword in Python, so we need to use a different name for the field: + return_info: Optional[ReturnInformation] = field( default=None, metadata={"name": "return"} ) + + # To adhere to the PAYONE API Schema, we need to use the name "return" externally. + # However, to avoid conflicts with Python's reserved keyword "return", + # we use "return_info" internally while mapping it to "return" for external interactions: + def __post_init__(self): + if self.return_info is not None: + setattr(self, "return", self.return_info) + + def to_dict(self): + result = { + "amountOfMoney": self.amountOfMoney, + "references": self.references, + "return": self.return_info, + } + return result From 98c72c41bf42cd82cbde5d27f6334a324fc7267c Mon Sep 17 00:00:00 2001 From: Dirk Ehrhardt Date: Thu, 22 Aug 2024 11:25:38 +0200 Subject: [PATCH 5/6] chore: update file name for apple pay transformer --- .../transformer/{Applepay.py => ApplepayTransformer.py} | 0 pcp_serversdk_python/transformer/__init__.py | 2 +- .../{test_Applepay.py => test_ApplepayTransformer.py} | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename pcp_serversdk_python/transformer/{Applepay.py => ApplepayTransformer.py} (100%) rename tests/transformer/{test_Applepay.py => test_ApplepayTransformer.py} (97%) diff --git a/pcp_serversdk_python/transformer/Applepay.py b/pcp_serversdk_python/transformer/ApplepayTransformer.py similarity index 100% rename from pcp_serversdk_python/transformer/Applepay.py rename to pcp_serversdk_python/transformer/ApplepayTransformer.py diff --git a/pcp_serversdk_python/transformer/__init__.py b/pcp_serversdk_python/transformer/__init__.py index 5e4cc4d..0554770 100644 --- a/pcp_serversdk_python/transformer/__init__.py +++ b/pcp_serversdk_python/transformer/__init__.py @@ -1,4 +1,4 @@ -from .Applepay import ( +from .ApplepayTransformer import ( transform_apple_pay_payment_to_mobile_payment_method_specific_input, ) diff --git a/tests/transformer/test_Applepay.py b/tests/transformer/test_ApplepayTransformer.py similarity index 97% rename from tests/transformer/test_Applepay.py rename to tests/transformer/test_ApplepayTransformer.py index 77759c8..7397883 100644 --- a/tests/transformer/test_Applepay.py +++ b/tests/transformer/test_ApplepayTransformer.py @@ -6,7 +6,7 @@ MobilePaymentMethodSpecificInput, Network, ) -from pcp_serversdk_python.transformer.Applepay import ( +from pcp_serversdk_python.transformer.ApplepayTransformer import ( network_from_string, transform_apple_pay_payment_to_mobile_payment_method_specific_input, version_from_string, From cad0caeae8a87a127cc5d8b4361ffb3d40701177 Mon Sep 17 00:00:00 2001 From: Dirk Ehrhardt Date: Thu, 22 Aug 2024 11:41:13 +0200 Subject: [PATCH 6/6] docs: add apple pay transformer usage to readme --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e5198a0..c08a939 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,23 @@ For most [payment methods](https://docs.payone.com/pcp/commerce-platform-payment When a client is successfully made a payment via ApplePay it receives a [ApplePayPayment](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment). This structure is accessible as the `ApplePayPayment` class. You can use the `ApplePayTransformer` to map an `ApplePayPayment` to a `MobilePaymentMethodSpecificInput` which can be used for payment executions or order requests. The transformer has a static method `transformApplePayPaymentToMobilePaymentMethodSpecificInput()` which takes an `ApplePayPayment` and returns a `MobilePaymentMethodSpecificInput`. The transformer does not check if the response is complete, if anything is missing the field will be set to `null`. ```python -# TODO +from pcp_serversdk_python.models import ApplePayPayment, MobilePaymentMethodSpecificInput +from pcp_serversdk_python.transformer.ApplepayTransformer import transform_apple_pay_payment_to_mobile_payment_method_specific_input +import json + +class App: + def get_json_string_from_request_somehow(self): + # Communicate with the client... + message = "" + return message + + def prepare_payment_for_apple_pay_payment(self): + payment_json = self.get_json_string_from_request_somehow() + payment = ApplePayPayment(**json.loads(payment_json)) + input = transform_apple_pay_payment_to_mobile_payment_method_specific_input(payment) + # Wrap the input into a larger request and send to the PCP API + # ... + ... ``` **[back to top](#table-of-contents)**