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.2.tar.gz (8.6 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.2-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for payple_hj3415-0.1.2.tar.gz
Algorithm Hash digest
SHA256 26a78b16a15d648eb974da640c43f4389fea33b444c44e5492f564f426278219
MD5 c49feaf30106ac0c56e650636e0d4f1e
BLAKE2b-256 e761af126d2231881c90f97ff7e1cf7a669a2b1b99f3c52cf65213a5fdbf7984

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for payple_hj3415-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7861bd84dc1a04bfe23f9bf73fe4e1d9d817b4a5c37ffb97c545d15e0a549803
MD5 7cbd639af9cb4e3d8b14ee51d5904ab2
BLAKE2b-256 6a341535c29b968fb2a229d0a3def263bf87c6245f0c4ae74b2c3c2cec45a819

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