djangopfbilling 0.0.5
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
need the Admin app enabled
visit http://127.0.0.1:8000/admin/ to see billing admin
π 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.
https://developers.kakao.com/console/app/364537/config/platform
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.