Skip to main content

payple-hj3415 is the program for using payple

Project description

payple-hj3415

전자결제시스템. 현재는 네이버페이만 가능하게 설정함 payple_hj3415 앱 - 실제 결제 api로 배포앱 orders - 테스트용 주문앱

.env 환경변수 구성

PAYPLE_ENV=demo         # demo | live
PAYPLE_CST_ID=test
PAYPLE_CUST_KEY=abcd1234567890
PAYPLE_CLIENT_KEY=test_DF55F29DA654A8CBC0F0A9DD4B556486
PAYPLE_REFERER=http://127.0.0.1:8000    # 로컬 개발 중이면 http://127.0.0.1:8000 로 두고, 정식 테스트계정/운영에선 등록 도메인으로 변경

프로젝트 urls.py 구성

# myproject/urls.py
from django.urls import path, include
urlpatterns = [
    path("payple/", include(("payple_hj3415.urls", "payple_hj3415"), namespace="payple_hj3415")),
]

프로젝트 setting.py 구성

INSTALLED_APPS = [
    ...,
    'payple_hj3415',
]

import os
# --- 페이플 설정(테스트 기본값; 운영은 환경변수로 교체) ---
PAYPLE = {
    "ENV": os.getenv("PAYPLE_ENV", "demo"),
    "CST_ID": os.getenv("PAYPLE_CST_ID", "test"),
    "CUST_KEY": os.getenv("PAYPLE_CUST_KEY", "abcd1234567890"),
    "CLIENT_KEY": os.getenv("PAYPLE_CLIENT_KEY", "test_DF55F29DA654A8CBC0F0A9DD4B556486"),
    "REFERER": os.getenv("PAYPLE_REFERER", "http://127.0.0.1:8000"),
}

다른 앱에서 사용하는 방법(예시)

주문모델구성

# orders/models.py
from django.db import models

class Order(models.Model):
    title = models.CharField(max_length=200)               # 예: "테스트 상품"
    amount = models.PositiveIntegerField()                 # KRW(원) 기준 정수 금액
    status = models.CharField(max_length=20, default="PENDING")  # PENDING/PAID/FAILED 등
    created_at = models.DateTimeField(auto_now_add=True)

뷰에서order 넘기기

# orders/views.py
from django.shortcuts import render, get_object_or_404
from .models import Order

def order_detail(request, order_id):
    order = get_object_or_404(Order, pk=order_id)
    # (보안) 본인 주문인지 확인하는 로직 권장
    return render(request, "orders/order_detail.html", {"order": order})

템플릿에서 사용

{# orders/templates/orders/order_detail.html #}
{% load payple_tags %}
{% url 'orders:done' order.id as done_url %}
{% url 'orders:fail' order.id as fail_url %}

<a class="btn btn-primary"
   href="{% payple_start_url order.id order.amount order.title done_url fail_url %}">
  결제하기
</a>

urls.py 구성

# orders/urls.py
from django.urls import path
from . import views
app_name = "orders"

urlpatterns = [
    path("<int:order_id>/", views.order_detail, name="detail"),
    path("<int:order_id>/done/", views.order_done, name="done"),
    path("<int:order_id>/fail/", views.order_fail, name="fail"),
]

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

payple_hj3415-0.1.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

payple_hj3415-0.1.1-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file payple_hj3415-0.1.1.tar.gz.

File metadata

  • Download URL: payple_hj3415-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for payple_hj3415-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0896a140f9aa30b92637d38111b8a79f8489869e8d4b593d7b703e8653a58eaa
MD5 f03f61745d2422b7580de8c5668f9f84
BLAKE2b-256 ec114b15c87b52139432fc5ae2d27ed8dbb842ef85b7e6d431eec6c82241cf40

See more details on using hashes here.

File details

Details for the file payple_hj3415-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for payple_hj3415-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 48b67ef30754b5adb725a81b7cbba97c025031d93e2ba99bde5f108281152e07
MD5 27548c0920b8e00a272e1a6520f70d56
BLAKE2b-256 c6fdc108c7628dc7495abd909768dfc9ac6b048e8a2984e3350f1ef0cbef31af

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