Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into main #8

Merged
merged 6 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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 [email protected] 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.
105 changes: 66 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +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)
- [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
Expand All @@ -38,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
Expand Down Expand Up @@ -86,47 +91,44 @@ 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
# ...
...
```

### 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
```

## 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.
**[back to top](#table-of-contents)**

### Build the library
## Contributing

```sh
# setup python environment
./scripts.sh setup
# install deps
./scripts.sh install
# build
./scripts.sh build
```
See [Contributing](./CONTRIBUTING.md)

### Run tests
**[back to top](#table-of-contents)**

```sh
./scripts.sh test
```
## Releasing the library

### Releasing the library

#### Preparing the Release
### Preparing the Release

- Checkout develop branch
- Create release branch (release/0.1.0)
Expand All @@ -141,7 +143,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)).

Expand All @@ -162,10 +164,35 @@ 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

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).

- Create PR on develop branch
- Merge develop in main branch
**[back to top](#table-of-contents)**

## License

Expand Down
19 changes: 17 additions & 2 deletions pcp_serversdk_python/models/RefundRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pcp_serversdk_python/transformer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .Applepay import (
from .ApplepayTransformer import (
transform_apple_pay_payment_to_mobile_payment_method_specific_input,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down