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

Develop #14

Merged
merged 7 commits into from
Jan 22, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ on:
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install setuptools
run: ./scripts.sh setup
- name: Install dependencies
run: ./scripts.sh install
- name: Run Lint
run: ./scripts.sh lint
- name: Run Build
run: ./scripts.sh build
- name: Run Tests
run: ./scripts.sh test

sonar:
runs-on: ubuntu-22.04
needs: [test]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ from pcp_serversdk_python import CommunicatorConfiguration, CheckoutApiClient
commerceCaseClient = CommerceCaseApiClient(communicatorConfiguration)
```

All payloads and reponses are availabe as java classes within the `com.payone.commerce.platform.lib.models.*` package. The serialization and deserialization is handled by the SDK internally. For example, to create an empty commerce case you can pass a `CreateCommerceCaseRequest` instance:
All payloads and reponses are availabe as python classes within the `pcp_serversdk_python.models` package. The serialization and deserialization is handled by the SDK internally. For example, to create an empty commerce case you can pass a `CreateCommerceCaseRequest` instance:

```python
createCommerceCaseRequest = CreateCommerceCaseRequest()
Expand Down Expand Up @@ -115,7 +115,7 @@ class App:
## 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
API_KEY=api_key API_SECRET=api_secret MERCHANT_ID=123 COMMERCE_CASE_ID=234 CHECKOUT_ID=345 ./scripts.sh run
```

**[back to top](#table-of-contents)**
Expand All @@ -137,32 +137,30 @@ See [Contributing](./CONTRIBUTING.md)
git checkout -b release/0.1.0
```

- Run prepare-release.sh script to set correct version
- Run `scripts.sh` script to set correct version

```sh
./prepare-release.sh
./scripts.sh version 0.1.0
```

### 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)).
When calling the `./scripts.sh version` script, the changelog will now be generated automatically using [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog).

1. **Conventional Commit Messages**:

- Ensure all commit messages follow the conventional commit format, which helps in automatic changelog generation.
- Ensure all commit messages follow the conventional commit format, which is crucial for automatic changelog generation.
- Commit messages should be in the format: `type(scope): subject`.

2. **Enforcing Commit Messages**:

- We enforce conventional commit messages using [Lefthook](https://github.com/evilmartians/lefthook) with [commitlint](https://github.com/conventional-changelog/commitlint).
- This setup ensures that all commit messages are validated before they are committed.

3. **Generate Changelog**:
- Run the changelog generation script to update the `CHANGELOG.md` file:
```sh
npm run changelog
```
- Review and commit the updated changelog before proceeding with the release.
3. **Automatic Changelog Generation**:

- The `./scripts.sh version` script will automatically generate and update the `CHANGELOG.md` file.
- After running the script, review the updated changelog to ensure accuracy before proceeding with the release.

### Merging the Release Branch

Expand Down
5 changes: 3 additions & 2 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# "any.go":
# runner: go run
commit-msg:
scripts:
parallel: true
commands:
commitlint:
runner: npx commitlint --edit
run: npx commitlint --edit $1
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pcp-serversdk-java",
"name": "pcp-serversdk-python",
"version": "1.0.0",
"type": "commonjs",
"scripts": {
Expand Down
25 changes: 14 additions & 11 deletions pcp_serversdk_python/transformer/ApplepayTransformer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from ..models import (
ApplePaymentDataTokenHeaderInformation,
ApplePaymentDataTokenInformation,
ApplePaymentTokenVersion,
ApplePayPayment,
MobilePaymentMethodSpecificInput,
Network,
PaymentProduct320SpecificInput,
)


Expand Down Expand Up @@ -32,15 +35,15 @@ def transform_apple_pay_payment_to_mobile_payment_method_specific_input(
paymentProductId=302,
publicKeyHash=header.get("publicKeyHash"),
ephemeralKey=header.get("ephemeralPublicKey"),
paymentProduct302SpecificInput={
"network": network_from_string(paymentMethod.get("network", "")),
"token": {
"version": version_from_string(paymentData.get("version", "")),
"signature": paymentData.get("signature"),
"header": {
"transactionId": header.get("transactionId"),
"applicationData": header.get("applicationData"),
},
},
},
paymentProduct302SpecificInput=PaymentProduct320SpecificInput(
network=network_from_string(paymentMethod.get("network", "")),
token=ApplePaymentDataTokenInformation(
version=version_from_string(paymentData.get("version", "")),
signature=paymentData.get("signature"),
header=ApplePaymentDataTokenHeaderInformation(
transactionId=header.get("transactionId"),
applicationData=header.get("applicationData"),
),
),
),
)
5 changes: 5 additions & 0 deletions scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ publish() {
echo "Upload complete."
}

run() {
echo "Running the package..."
python3 example/main.py
}

# Check the first argument passed to the script
case "$1" in
setup)
Expand Down
25 changes: 14 additions & 11 deletions tests/transformer/test_ApplepayTransformer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import pytest

from pcp_serversdk_python.models import (
ApplePaymentDataTokenHeaderInformation,
ApplePaymentDataTokenInformation,
ApplePaymentTokenVersion,
ApplePayPayment,
MobilePaymentMethodSpecificInput,
Network,
PaymentProduct320SpecificInput,
)
from pcp_serversdk_python.transformer.ApplepayTransformer import (
network_from_string,
Expand Down Expand Up @@ -53,17 +56,17 @@ def test_transform_apple_pay_payment_to_mobile_payment_method_specific_input():
paymentProductId=302,
publicKeyHash="publicKeyHash123",
ephemeralKey="ephemeralPublicKey123",
paymentProduct302SpecificInput={
"network": Network.VISA,
"token": {
"version": ApplePaymentTokenVersion.EC_V1,
"signature": "signature123",
"header": {
"transactionId": "transactionId123",
"applicationData": "applicationData123",
},
},
},
paymentProduct302SpecificInput=PaymentProduct320SpecificInput(
network=Network.VISA,
token=ApplePaymentDataTokenInformation(
version=ApplePaymentTokenVersion.EC_V1,
signature="signature123",
header=ApplePaymentDataTokenHeaderInformation(
transactionId="transactionId123",
applicationData="applicationData123",
),
),
),
)

result = transform_apple_pay_payment_to_mobile_payment_method_specific_input(
Expand Down
Loading