From b97ec2c1f5aa91007048b7e7dbc7a15eb5045e3d Mon Sep 17 00:00:00 2001 From: Jakub Dubec Date: Wed, 9 Feb 2022 11:15:12 +0100 Subject: [PATCH] Service information in transaction resource --- .gitignore | 1 + CHANGELOG.md | 4 ++ README.md | 110 +++++++++++++++---------------- cheddar/resources/transaction.py | 8 +++ cheddar/version.py | 2 +- 5 files changed, 69 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index abdedbb..3c08e4e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ venv/ .DS_Store? *.DS_Store Thumbs.db +.idea/ diff --git a/CHANGELOG.md b/CHANGELOG.md index ebcf7f2..0e9be86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.7.0 : 09/02/2022 + +Transaction contains information about the service using `Transaction.Service` class. + ## v0.6.2 & v0.6.3: 16/06/2021 Maintenance release – previous version have been yanked and tags removed due to a security issue and diff --git a/README.md b/README.md index cc0a06e..35cc8c7 100644 --- a/README.md +++ b/README.md @@ -89,38 +89,38 @@ variables. If you wish to provide your own, add `payer_ip_address` key with vali First argument is a service provider, which can currently be one of the following: -| Service name | Description | -|:-------------|:------------| -|`cheddar.Service.SPOROPAY`|SporoPay, Slovenská sporiteľňa| -|`cheddar.Service.TATRAPAY`|TatraPay, Tatra banka| -|`cheddar.Service.CARDPAY`|Cardpay, Tatra banka| -|`cheddar.Service.COMFORTPAY`|ComfortPay (periodic payments), Tatra banka| -|`cheddar.Service.EPLATBY`|ePlatby, VÚB| -|`cheddar.Service.ECARD`|eCard, VÚB| -|`cheddar.Service.PAYPAL`|PayPal Payments Standard, PayPal| -|`cheddar.Service.GPWEBPAY`|GP webpay, Global Payments Europe| -|`cheddar.Service.ITERMINAL`|iTerminal, Poštová banka (firstdata.lv backend)| -|`cheddar.Service.ITERMINAL2`|iTerminal, Poštová banka (sia.eu backend)| +| Service name | Description | +|:-----------------------------|:------------------------------------------------| +| `cheddar.Service.SPOROPAY` | SporoPay, Slovenská sporiteľňa | +| `cheddar.Service.TATRAPAY` | TatraPay, Tatra banka | +| `cheddar.Service.CARDPAY` | Cardpay, Tatra banka | +| `cheddar.Service.COMFORTPAY` | ComfortPay (periodic payments), Tatra banka | +| `cheddar.Service.EPLATBY` | ePlatby, VÚB | +| `cheddar.Service.ECARD` | eCard, VÚB | +| `cheddar.Service.PAYPAL` | PayPal Payments Standard, PayPal | +| `cheddar.Service.GPWEBPAY` | GP webpay, Global Payments Europe | +| `cheddar.Service.ITERMINAL` | iTerminal, Poštová banka (firstdata.lv backend) | +| `cheddar.Service.ITERMINAL2` | iTerminal, Poštová banka (sia.eu backend) | Second argument to the function call is an associative array of configuration options. Which options have to be used and which have no effect at all depends on the service provider. The next table lists all possible attributes: -| Attribute name | Data type | Required? | Notes | -|:---------------|:---------:|:---------:|:------| -|`amount`|float|✓|amount required in the specified currency| -|`currency`|string|✓|currency code as in [ISO 4217](http://www.iso.org/iso/home/standards/currency_codes.htm)| -|`variable_symbol`|string|✓| | -|`constant_symbol`|string| | | -|`card_id`|string| |optional card token in periodical payments
_applicable only to ComfortPay transactions_| -|`payer_name`|string|✓|customer’s name| -|`payer_email`|string|✓|customer’s email (which has to be a valid e-mail address)| -|`language`|string| |customer’s language| -|`description`|string| |reference for the customer| -|`return_url` or `callback`|string|✓|URL to return to after the payment
_iTerminal does not use this attribute since you have to set this up once for all transactions in their administration interface_| -|`notification_url`|string| |URL to send notifications to
_required for PayPal transactions_| -|`cpp_logo_image`|string| |header image at PayPal
_applicable only to PayPal transactions_| -|`cpp_cart_border_color`|string| |HEX code of colour at PayPal
_applicable only to PayPal transactions_| -|`periodicity`|integer| |periodicity in days, when the next periodical payment will be automatically executed; default value is 30 days
_applicable only to ComfortPay transactions_| +| Attribute name | Data type | Required? | Notes | +|:---------------------------|:---------:|:---------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `amount` | float | ✓ | amount required in the specified currency | +| `currency` | string | ✓ | currency code as in [ISO 4217](http://www.iso.org/iso/home/standards/currency_codes.htm) | +| `variable_symbol` | string | ✓ | | +| `constant_symbol` | string | | | +| `card_id` | string | | optional card token in periodical payments
_applicable only to ComfortPay transactions_ | +| `payer_name` | string | ✓ | customer’s name | +| `payer_email` | string | ✓ | customer’s email (which has to be a valid e-mail address) | +| `language` | string | | customer’s language | +| `description` | string | | reference for the customer | +| `return_url` or `callback` | string | ✓ | URL to return to after the payment
_iTerminal does not use this attribute since you have to set this up once for all transactions in their administration interface_ | +| `notification_url` | string | | URL to send notifications to
_required for PayPal transactions_ | +| `cpp_logo_image` | string | | header image at PayPal
_applicable only to PayPal transactions_ | +| `cpp_cart_border_color` | string | | HEX code of colour at PayPal
_applicable only to PayPal transactions_ | +| `periodicity` | integer | | periodicity in days, when the next periodical payment will be automatically executed; default value is 30 days
_applicable only to ComfortPay transactions_ | Note that all of the supported currencies are available as a simple constant on `cheddar.Currency` class to make it easier in code. @@ -141,16 +141,16 @@ in the `notification_url` parameter #### Allowed transaction statuses -|Status name|Description| -|:----------|:----------| -|`none`|transaction has been created, but the user has not been redirected to bank’s payment gateway| -|`in_progress`|user has been redirected to bank’s payment gateway| -|`completed`|transaction has been successfully completed| -|`denied` or `rejected`|transaction has been rejected by the bank (the most usual reasons include user error in inputting card details and insufficient funds)| -|`timeout`|special temporary status used only by Tatra banka’s TatraPay service| -|`pending`|special status for PayPal before an IPN notification has resolved the transaction status as either rejected or completed| -|`cancelled`|in case of periodical payments available only with Tatra banka’s ComfortPay service this status means that planned transaction has been cancelled| -|`expired`|old payment without clear result (e.g. user abandoned the payment form while at bank’s gateway)| +| Status name | Description | +|:-----------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------| +| `none` | transaction has been created, but the user has not been redirected to bank’s payment gateway | +| `in_progress` | user has been redirected to bank’s payment gateway | +| `completed` | transaction has been successfully completed | +| `denied` or `rejected` | transaction has been rejected by the bank (the most usual reasons include user error in inputting card details and insufficient funds) | +| `timeout` | special temporary status used only by Tatra banka’s TatraPay service | +| `pending` | special status for PayPal before an IPN notification has resolved the transaction status as either rejected or completed | +| `cancelled` | in case of periodical payments available only with Tatra banka’s ComfortPay service this status means that planned transaction has been cancelled | +| `expired` | old payment without clear result (e.g. user abandoned the payment form while at bank’s gateway) | ### Getting transaction details @@ -162,22 +162,22 @@ payment = client.payments.details(uuid) Afterwards you can inspect the returning object, which contains these properties: -|Property name|Data type|Always present?|Default value|Notes| -|:------------|:-------:|:-------------:|:-----------:|:----| -|`uuid`|string|✓| | | -|`status`|string|✓|none|current transaction status (see the next table)| -|`variable_symbol`|string|✓| |the same as was sent while creating the payment object (see previous section)| -|`constant_symbol`|string|✓|0308|payment for services| -|`amount`|float|✓|0.00|original amount of the transaction| -|`refunded_amount`|float|✓|0.00|refunded amount of the transaction| -|`service_fee_amount`|float|✓|0.00|provision for the transaction in card payments _available when using CardPay / ComfortPay and set up with PGP encrypted statements or PayPal service_| -|`currency`|`Currencies`|✓|EUR|currency of the transaction| -|`periodicity`|integer| |0|number of days in which next payment will be executed| -|`periodicity_no`|integer| |1|number of transaction in order (using the same variable symbol)| -|`charge_on`|`Datetime`| | |when was or should be this transaction executed| -|`card_expire_on`|`Datetime`| |null|date of card expiration _available only when using ComfortPay or VÚB eCard service_| -|`card_no`|string| | |masked card number _available only when using ComfortPay or VÚB eCard service_| -|`transaction_identifier`|string| | |internal transaction identifier of the bank _available only when using CardPay / ComfortPay, TatraPay or VÚB eCard service_| +| Property name | Data type | Always present? | Default value | Notes | +|:-------------------------|:------------:|:---------------:|:-------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------| +| `uuid` | string | ✓ | | | +| `status` | string | ✓ | none | current transaction status (see the next table) | +| `variable_symbol` | string | ✓ | | the same as was sent while creating the payment object (see previous section) | +| `constant_symbol` | string | ✓ | 0308 | payment for services | +| `amount` | float | ✓ | 0.00 | original amount of the transaction | +| `refunded_amount` | float | ✓ | 0.00 | refunded amount of the transaction | +| `service_fee_amount` | float | ✓ | 0.00 | provision for the transaction in card payments _available when using CardPay / ComfortPay and set up with PGP encrypted statements or PayPal service_ | +| `currency` | `Currencies` | ✓ | EUR | currency of the transaction | +| `periodicity` | integer | | 0 | number of days in which next payment will be executed | +| `periodicity_no` | integer | | 1 | number of transaction in order (using the same variable symbol) | +| `charge_on` | `Datetime` | | | when was or should be this transaction executed | +| `card_expire_on` | `Datetime` | | null | date of card expiration _available only when using ComfortPay or VÚB eCard service_ | +| `card_no` | string | | | masked card number _available only when using ComfortPay or VÚB eCard service_ | +| `transaction_identifier` | string | | | internal transaction identifier of the bank _available only when using CardPay / ComfortPay, TatraPay or VÚB eCard service_ | ### Asynchronous transaction notifications @@ -289,4 +289,4 @@ formatter with: --- -© 2021 BACKBONE, s.r.o. +© 2022 BACKBONE, s.r.o. diff --git a/cheddar/resources/transaction.py b/cheddar/resources/transaction.py index 7830b1e..979f68f 100644 --- a/cheddar/resources/transaction.py +++ b/cheddar/resources/transaction.py @@ -4,6 +4,13 @@ class Transaction(object): + + class Service: + def __init__(self, data): + self.name = data.get('name') + self.handle = data.get('handle') + self.provider = data.get('provider') + def __init__(self, data): self.uuid = data['uuid'] self.type = data['type'] @@ -16,6 +23,7 @@ def __init__(self, data): self.amount = data['amount'] self.currency = data["currency"] + self.service = self.Service(data['service']) if 'service' in data else None self.iban = data['iban'] if 'iban' in data else None self.notes = data['notes'] if 'notes' in data else None diff --git a/cheddar/version.py b/cheddar/version.py index df1c617..f406109 100644 --- a/cheddar/version.py +++ b/cheddar/version.py @@ -1 +1 @@ -VERSION = "0.6.3" +VERSION = "0.7.0"