Skip to main content

A Django app to conduct Web-based billing for KakaoPay and KGMobilians.

Project description

pf_billing

pf_billing is a django-based billing module, which covers KakaoPay and KGMobilians.
(pf stands for plabfootball)


🚀 Quick start

1. install django-pf-billing

pip install django-pf-billing

It will install following dependencies if not installed

  • requests
  • user-agent

2. Add "pf_billing" to your INSTALLED_APPS setting like this

# settings.py
INSTALLED_APPS = [
    ...
    'pf_billing',
]

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

3. Run python manage.py migrate to create a Billing model.


4. Start the development server



🛠 How to use

from pf_billing.interface import BillingAction

# 1) KakaoPay
billing = BillingAction.set_pg("KakaoPay")

# 2) KGMobilians
billing = BillingAction.set_pg("KGMobilians")


# ready
response = billing.ready(
    partner_user_id  = "190324",
    partner_order_id = "K202109301340",
    item_name        = "테스트 상품",
    total_amount     = 10000,
    quantity         = 1,
    # 결제 성공 시, 카카오페이 서버에서 운영 중인 서버로 콜백 가능한 엔드포인트
    approval_url     = "http://example.com/billing/result/success",
    # 결제 취소 시, 카카오페이 서버에서 운영 중인 서버로 콜백 가능한 엔드포인트
    cancel_url       = "http://example.com/billing/result/cancel",
    # 결제 실패 시, 카카오페이 서버에서 운영 중인 서버로 콜백 가능한 엔드포인트
    fail_url         = "http://example.com/billing/result/fail",
)

# approve
response = billing.approve(
    partner_user_id  = "190324",
    partner_order_id = "K202109301340",
    pg_token         = "YKDOEKCDKSLKNF",
    transaction_id   = "TID-n3jdks2lajs",
)

# cancel(partial/all)
response = billing.cancel(
    transaction_id = "n3jdks2lajs",
    cancel_amount  = 10000,
)

# track status
response = billing.track(
    transaction_id = "n3jdks2lajs",
)



⭐️ Note

1. Billing Model will be created in your database. Keep in mind that model or db_table name conflict.

2. Register your domain in Kakao developers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-pf-billing-0.0.5.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file django-pf-billing-0.0.5.tar.gz.

File metadata

  • Download URL: django-pf-billing-0.0.5.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for django-pf-billing-0.0.5.tar.gz
Algorithm Hash digest
SHA256 35a635891010040ac44f3b28010351a722a755208ec6135b6c7de91167f9aa2d
MD5 9d75a94b120e4e6476436cc8199cbaf0
BLAKE2b-256 2e73486959acba95d92f315c08ae06d8ba3cd511a3339c4040ed54cc2af73687

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page