Metadata-Version: 2.1
Name: paytring
Version: 1.0.3
Summary: A SDK which helps to create, fetch or refund an order on Paytring
Home-page: https://github.com/paytring/python-sdk
Author: Paytirng
Author-email: developer@paytring.com
License: MIT
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt

# Paytring\Python
---
### Installation
---
The source code is currently hosted on GitHub at : https://github.com/paytring/python-sdk

Binary installers for the latest released version are available at the Python Package Index (PyPI)

```
pip install paytring
```

## Set-Up Environment Variables
---
```
import  os
    os.environ['key'] = "your_key"
    os.environ['secret'] = "your_secret"
```
## Usage
---
```
from paytring.client import Order
```

#### Create Instance
```
order = Order()
```

## Create Order
---
##### Input Parameter

- Receipt ID(string)
- Amount(string)
- Callback Url(string)
- Customer Info ( Dictionary )
- Currency (String : INR or USD)

###### Optional Parameters

- PG (String)
- PG Pool ID (String)


#### Methods

```python
customer_info = {
    "cname": "test",
    "email": "abc@gmail.com" -> it will be baseEncode256,
    "phone": "phone"
}


order.create(
    receipt_id,
    amount,
    callback_url,
    customer_info,
    currrency,
    pg(optioanl),
    pg_pool_id(optional)
)
```

#### Response

```
{
"status": true,
"url": "www.makepayment.com",
"order_id": "365769619161481216"
}
```

## Fetch Order
---
##### Input Paramete

- Order ID(string)

#### Methods
```

order.fetch(
    order_id
)
```

### Response
```
{
    "status": true,
    "order": {
        "order_id": "489651149222183338",
        "receipt_id": "testmode323",
        "pg_transaction_id": "489651179018519803",
        "amount": 100,
        "currency": "INR",
        "pg": "RazorPay",
        "method": "UPI",
        "order_status": "success",
        "unmapped_status": "captured",
        "customer": {
            "name": "sudeep",
            "email": "sudeep@yopmail.com",
            "phone": "8960444555"
        },
        "notes": {
            "udf1": "",
            "udf2": "",
            "udf3": "",
            "udf4": "",
            "udf5": "",
            "udf6": "",
            "udf8": "",
            "udf9": "",
            "udf10": ""
        },
        "billing_address": {
            "firstname": "",
            "lastname": "",
            "phone": "",
            "line1": "",
            "line2": "",
            "city": "",
            "state": "",
            "country": "",
            "zipcode": ""
        },
        "shipping_address": {
            "firstname": "",
            "lastname": "",
            "phone": "",
            "line1": "",
            "line2": "",
            "city": "",
            "state": "",
            "country": "",
            "zipcode": ""
        },
        "additional_charges": 0,
        "mdr": ""
    }
}
```

## Fetch Order By Receipt-ID
---
#### Input Paramete

- Receipt ID(string)

#### Methods
```

order.fetch_by_receipt_id(
    receipt_id
)
```

### Response
```
{
    "status": true,
    "order": {
        "order_id": "489651149222183338",
        "receipt_id": "testmode323",
        "pg_transaction_id": "489651179018519803",
        "amount": 100,
        "currency": "INR",
        "pg": "RazorPay",
        "method": "UPI",
        "order_status": "success",
        "unmapped_status": "captured",
        "customer": {
            "name": "sudeep",
            "email": "sudeep@yopmail.com",
            "phone": "8960444555"
        },
        "notes": {
            "udf1": "",
            "udf2": "",
            "udf3": "",
            "udf4": "",
            "udf5": "",
            "udf6": "",
            "udf8": "",
            "udf9": "",
            "udf10": ""
        },
        "billing_address": {
            "firstname": "",
            "lastname": "",
            "phone": "",
            "line1": "",
            "line2": "",
            "city": "",
            "state": "",
            "country": "",
            "zipcode": ""
        },
        "shipping_address": {
            "firstname": "",
            "lastname": "",
            "phone": "",
            "line1": "",
            "line2": "",
            "city": "",
            "state": "",
            "country": "",
            "zipcode": ""
        },
        "additional_charges": 0,
        "mdr": ""
    }
}
```

## Refund Order
---
##### Input Paramete

- Order ID(string)

#### Methods
```

order.refund(
    order_id
)
```

### Response

#### Success Response
```
{
    "status": true,
    "message": "Refund has been initiated"
}
```
#### Error Response 
```
{
    "status": false,
    "error": {
        "message": "error message here",
        "code": 204
    }
}
```

