payment-merchant-sdk 0.0.2.dev1
Merchant Integration SDK

This SDK is used for supporting merchant integration with GrabPay backend API# Python SDK for Merchant Integration 

## How to use SDK

For using this SDK, you might copy all files in [src](./src) folder and paste it to your project. Then you should import 2 classes ```MerchantIntegrationOnline```, ```MerchantIntegrationOffline``` in ```src``` folder.

### Config environment:

```
- stage : String : "PRD"/"STG"
- country : String : Country code of the merchant location. [Refer](https://countrycode.org/)
- partner_id : String - Unique ID for a partner. Retrieve from Developer Hom
- partner_secret : String - Secret key for a partner. Retrieve from Developer Home
- merchant_id : String - Retrieve from Developer Home.
- terminal_id : String - Retrieve from Developer Home. **Only available for POS (P2M)**
- client_id : String - Retrieve from Developer Home. **Only available for OnA**
- client_secret : String - Retrieve from Developer Home. **Only available for OnA**
- redirect_url : String - The url configured in Developer Home. **Only available for OnA**
```

### How to configure for online

```python
    from MerchantIntegrationOnline import MerchantIntegrationOnline
    callOna = MerchantIntegrationOnline(stage,country,partner_id,partner_secret,merchant_id,client_id,client_secret,redirect_url)
```

### How to configure for offline
```python
    from MerchantIntegrationOffline import MerchantIntegrationOffline
    callPos = MerchantIntegrationOffline(stage,country,partner_id,partner_secret,merchant_id,terminal_id)
```

### Detail for APIs online 

1. Charge Init: 
```python
    respChargeInit = callOna.onaChargeInit(partnerTxID,  partnerGroupTxID, amount, currency, isSync, description, metaInfo, items, shippingDetails,[])
```

2. Create Web Url: 
```python
    respChargeInit = callOna.onaCreateWebUrl(partnerGroupTxID, partnerTxID, amount, description, currency, metaInfo, items, shippingDetails, isSync,[], state)
```

3. get OAuth Token

```python
    respAuthCode = callOna.onaOAuthToken(partnerTxID,code)
```

4. Charge Complete
```python
    respChargeComplete = callOna.onaChargeComplete(partnerTxID,respAuthCode.access_token)
```

5 Get Charge status
```python
    respChargeStatus = callOna.onaGetChargeStatus(partnerTxID, currency, respAuthCode.accessToken)
```

6. refund online
```python
    response = callOna.onaRefund(refundPartnerTxID, amount, origPartnerTxID, description, respAuthCode.accessToken, currency)
```

7. Get Refund Status
```python
    response = callOna.onaGetRefundStatus(partnerTxID, respAuthCode.accessToken, currency)
```

8. Get One time charge status
```python
    response = callOna.onaGetOtcStatus(partnerTxID, respAuthCode.accessToken, currency)
```

### Detail for API offline

1. Create QR Code
```python
    respCreateQRCode= callPos.posCreateQRCode(msgID, partnerTxID, amount, currency)
```

2. Get transaction status:
```python
    resp= callPos.posGetTxnStatus(msgID, partnerTxID, currency)
```

3. cancelTxn
```file
    resp= callPos.posCancel(msgID, partnerTxID, origPartnerTxID, origTxID, currency)
```

4. refund Pos transaction
```file
    resp= callPos.posRefund(msgID, partnerTxID, originTxID, amount, description,currency)
```

5. Get refund transaction status:
```python
    resp= callPos.posGetRefundStatus(msgID, partnerTxID, currency)
```

6. performTxn
```file
    resp= callPos.posPerformQRCode(msgID, partnerTxID, amount, code, currency)
```