Metadata-Version: 2.1
Name: geopayment
Version: 0.2
Summary: Python SDK for Georgian Payment Providers
Home-page: https://github.com/Lh4cKg/geopayment
Author: Lasha Gogua
Author-email: gogualasha@gmail.com
License: MIT
Keywords: python,geopayment,payments,sdk,merchant
Platform: OS Independent
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown
Requires-Dist: cryptography (>=2.9.2)
Requires-Dist: pyOpenSSL (>=19.1.0)
Requires-Dist: requests (>=2.24.0)

# About
GeoPayment - Python SDK for Georgian Payment Providers

# Prerequisites
------

`Python >= 3.7.x`   
`cryptography >= 2.9.x`     
`pyOpenSSL >=19.x`


### Quick Start

Install **geopayment** package

```bash
$ pip install geopayment

```    

## Integrate your apps

### For TBCPay module
There are two types of transaction within this system: SMS and DMS.

SMS - is a direct payment method, money is charged in 1 event, as soon as customer enters the credit card details and clicks proceed.

DMS - is a two step method, first event blocks the money on the card (max 30 days), second event captures the money (second event can be carried out when product is shipped to the customer for example).

Every 24 hours, a merchant must close the business day.

##### Generate Certificate from p12
`p12_to_pem` function return certificate from p12 as pem format. returned certificate
contains cert and cert-key.

```python
from geopayment.crypto import p12_to_pem

cert = '/absolute/path/my_cert.p12'
p12_to_pem(cert=cert, password='cert-pass', file_name='out-cert-name', output='/absolute/output/path/')
# result
'out-cert-name.pem'
'out-cert-name-key.pem'
```

##### Initialize Provider Object
```python
from geopayment import TBCProvider

class MyTBCProvider(TBCProvider):

    @property
    def description(self) -> str:
        """default description"""
        return 'mybrand description'

    @property
    def client_ip(self) -> str:
        return 'xx.xx.xx.xx'

    @property
    def merchant_url(self) -> str:
        return 'https://ecommerce.ufc.ge:18443/ecomm2/MerchantHandler'

    @property
    def cert(self):
        return (
            '/absolute/output/path/out-cert-name.pem',
            '/absolute/output/path/out-cert-name-key.pem'         
        )

```

Consider the first type of authorization (SMS authorization)

1. Generate transaction id

    Function name: `get_trans_id`

    input: 

        amount: float, int, deciaml (required)
        currency: int, str (required)
        client_ip_addr: str (optional)
        description: str (optional)
        language: str (optional)

   ```python
    provider = MyTBCProvider()
    result = provider.get_trans_id(amount=23.50, currency='GEL')
    print(result)
    {'TRANSACTION_ID': 'NMQfTRLUTne3eywr9YnAU78Qxxw='}
    print(provider.trans_id)
    NMQfTRLUTne3eywr9YnAU78Qxxw=
    ```

2. Check transaction status

    Function name: `check_trans_status`

    input:

        trans_id: str (required) 
        client_ip_addr: str (optional)


   ```python
    provider = MyTBCProvider()
    result = provider.check_trans_status(trans_id=provider.trans_id)
    print(result)
    {'RESULT': 'OK', 'RESULT_CODE': '000', '3DSECURE': 'ATTEMPTED',
    'CARD_NUMBER': '', 'RRN': '', 'APPROVAL_CODE': ''}
   ```

Consider the type of DMS authorization

1. Generate transaction id with DMS authorization

    Function name: `pre_auth_trans`

    input:

        amount: float, int, decimal (required)
        currency: int, str (required)
        client_ip_addr: str (optional)
        description: str (optional)
        language: str (optional)

    ```python
    provider = MyTBCProvider()
    result = provider.pre_auth_trans(amount=43.20, currency=981)
    print(result)
    {'TRANSACTION_ID': 'NMQfTRLUTne3eywr9YnAU78Qxxw='}
    print(provider.trans_id)
    NMQfTRLUTne3eywr9YnAU78Qxxw=
    ```
2. Commit a transaction generated by DMS authorization

    Function name: `confirm_pre_auth_trans`

    input:

        trans_id: str (required)
        amount: float, int, decimal (required)
        currency: int, str (required)
        client_ip_addr: str (optional)
        description: str (optional)
        language: str (optional)

    ```python
    provider = MyTBCProvider()
    result = provider.confirm_pre_auth_trans(trans_id=provider.trans_id, amount=43.20, currency=981)
    print(result)
    {'RESULT': 'OK', 'RESULT_CODE': '', 'BRN': '' 'APPROVAL_CODE': '', 'CARD_NUMBER': ''}
    ```

Consider other operations, e.g. Reversal, Refund, End of Business Day

1. End of Business Day

    Function name: `end_of_business_day`
    ```python
    provider = MyTBCProvider()
    result = provider.end_of_business_day()
    print(result)
    ```

2. Transaction reversal

    Function name: `reversal_trans`

    input:

        trans_id: str (required)
        amount: float, int, decimal (required)

    ```python
    provider = MyTBCProvider()
    provider.reversal_trans(trans_id=provider.trans_id, amount=12.20)
    {'RESULT': 'OK', 'RESULT_CODE': ''}
    ```

3. Transaction refund

    Function name: `refund_trans`

    input:

        trans_id: str (required)
        amount: float, int, decimal (required)

    ```python
    provider = MyTBCProvider()
    provider.refund_trans(trans_id=provider.trans_id, amount=12.20)
    {'RESULT': '', 'RESULT_CODE': '', 'REFUND_TRANS_ID': ''}
    ```

##### License

Copyright &copy; 2017 Lasha Gogua.

MIT licensed.

