semvec/pypi-packages huggingface dataset:
django-pf-payment 0.9.6
A Django app to conduct Web-based payment for KakaoPay and KGMobilians.
License: MIT License
Requires Python: >=3.6

# pf_payment

> **pf_payment** is a django-based payment module, which covers KakaoPay and KGMobilians.<br>
> (`pf` stands for plabfootball)<br>

<br>

## 🚀 Quick start

#### 1. install django-pf-payment

```python
pip install django-pf-payment
```

#### It will install following dependencies if not installed

- requests<br>
- user-agent<br>

<br>

#### 2. Add "pf_payment" to your INSTALLED_APPS setting like this

```python
# settings.py
INSTALLED_APPS = [
    ...
    'pf_payment',
]

KAKAOPAY_CID = "Your kakaopay cid"
KAKAOPAY_APP_ADMIN_KEY = "Your kakao app admin key"

===== example ====
HOST_DOMAIN = "www.example.com"
HOST_APPROVAL_URLNAME = "kakao_success"
HOST_CANCEL_URLNAME = "kakao_cancel"
HOST_FAIL_URLNAME = "kakao_fail"
```

<br>

#### 3. Include the `pf_payment` URLconf in your project urls.py like this

```python
path('pf_payment/', include('pf_payment.urls')),
```

<br>

#### 4. Start the development server

- need the Admin app enabled
- visit http://127.0.0.1:8000/admin/ to see payment admin

<br><br>

## 🛠 How to use

```python
from pf_payment.interface import PaymentAction

# 1) KakaoPay
payment = PaymentAction.set_pg("KakaoPay")

# 2) KGMobilians
payment = PaymentAction.set_pg("KGMobilians")


# ready(결제 준비)
response = payment.ready(
    partner_user_id  = partner_user_id,
    partner_order_id = partner_order_id,
    item_name        = item_name,
    total_amount     = total_amount,
    quantity         = quantity,
)

# approve(결제 확정)
response = payment.approve(
    partner_order_id = partner_order_id,
    partner_user_id  = partner_user_id,
    pg_token         = pg_token,
    transaction_id   = transaction_id,
)

# cancel(부분취소/전체취소)
payment.cancel(
    transaction_id = transaction_id,
    cancel_amount  = cancel_amount,
)

# track(결제 상태 추적)
response = payment.track(
    transaction_id= transaction_id
)
```

<br><br>

## ⭐️ Note

### 1. Must implement following API

#### 1) PG calls your success view when PG determines the payment is successful.

- HOST_APPROVAL_URLNAME you wrote in settings.py

#### 2) PG calls your cancel view when PG determines the payment is canceled.

- HOST_CANCEL_URLNAME you wrote in settings.py

#### 3) PG calls your fail view when PG determines the payment is failed.

- HOST_FAIl_URLNAME you wrote in settings.py

<br>

### 2. Register your domain in Kakao developers.

- https://developers.kakao.com/console/app/364537/config/platform