Skip to content

Commit

Permalink
Service information in transaction resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibyx committed Feb 9, 2022
1 parent f15d0a0 commit b97ec2c
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ venv/
.DS_Store?
*.DS_Store
Thumbs.db
.idea/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
110 changes: 55 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br>_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<br>_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<br>_required for PayPal transactions_|
|`cpp_logo_image`|string| |header image at PayPal<br>_applicable only to PayPal transactions_|
|`cpp_cart_border_color`|string| |HEX code of colour at PayPal<br>_applicable only to PayPal transactions_|
|`periodicity`|integer| |periodicity in days, when the next periodical payment will be automatically executed; default value is 30 days<br>_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<br>_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<br>_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<br>_required for PayPal transactions_ |
| `cpp_logo_image` | string | | header image at PayPal<br>_applicable only to PayPal transactions_ |
| `cpp_cart_border_color` | string | | HEX code of colour at PayPal<br>_applicable only to PayPal transactions_ |
| `periodicity` | integer | | periodicity in days, when the next periodical payment will be automatically executed; default value is 30 days<br>_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.
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -289,4 +289,4 @@ formatter with:

---

&copy; 2021 BACKBONE, s.r.o.
&copy; 2022 BACKBONE, s.r.o.
8 changes: 8 additions & 0 deletions cheddar/resources/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cheddar/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.6.3"
VERSION = "0.7.0"

0 comments on commit b97ec2c

Please sign in to comment.