django-yandex-money
ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅Π΅Π°Ρ ΠΎΠ»ΠΎ ΡΡΠ΄Π°
ΠΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ Π΄Π»Ρ ΠΏΠΎ ΠΈΠ½ΡΠ΅Π³ΡΠ°ΡΠΈΠΈ
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
-
Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΏΠ°ΠΊΠ΅Ρ:
pip install django-yandex-money
-
ΠΠΎΠ±Π°Π²ΠΈΡΡ
yandex_money
Π²settings.INSTALLED_APPS
:INSTALLED_APPS = ( ... 'yandex_money', ... )
-
ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠΈΠ½Ρ ΡΠΎΠ½ΠΈΠ·Π°ΡΠΈΡ Ρ ΠΠ:
python manage.py syncdb python manage.py migrate # Π΄Π»Ρ ΡΠ΅Ρ , ΠΊΡΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅Ρ south
-
ΠΠΎΠ±Π°Π²ΠΈΡΡ Π²
urls.py
:urlpatterns = patterns('', # ... url(r'^fail-payment/$', TemplateView.as_view(template_name='fail.html'), name='payment_fail'), url(r'^success-payment/$', TemplateView.as_view(template_name='success.html'), name='payment_success'), url(r'^yandex-money/', include('yandex_money.urls')), )
-
Π£ΠΊΠ°Π·Π°ΡΡ Π² settings ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ:
YANDEX_MONEY_DEBUG = False YANDEX_MONEY_SCID = 12345 YANDEX_MONEY_SHOP_ID = 56789 YANDEX_MONEY_SHOP_PASSWORD = 'password' YANDEX_MONEY_FAIL_URL = 'https://example.com/fail-payment/' YANDEX_MONEY_SUCCESS_URL = 'https://example.com/success-payment/'
-
Π£ΠΊΠ°Π·Π°ΡΡ Π² ΡΠ°Π±ΠΎΡΠ΅ΠΌ Π―Π½Π΄Π΅ΠΊΡ-Π΄Π΅Π½Π΅Π³ ΠΊΠ°Π±ΠΈΠ½Π΅ΡΠ΅ Π½Π°ΡΡΡΠΉΠΎΠΊΠΈ Π΄Π»Ρ ΠΏΡΠΈΠ΅ΠΌΠ° ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠΉ:
- paymentAvisoURL: https://example.com/yandex-money/aviso/
- checkURL: https://example.com/yandex-money/check/
- failURL: https://example.com/fail-payment/
- successURL: https://example.com/success-payment/
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅
ΠΠΎΠ»Π½ΡΠΉ ΠΏΡΠΈΠΌΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ
-
ΠΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΏΠ»Π°ΡΠ΅ΠΆΠ½ΠΎΠΉ ΡΠΎΡΠΌΡ:
# -*- coding: utf-8 -*- from django.views.generic import TemplateView from yandex_money.forms import PaymentForm from yandex_money.models import Payment class OrderPage(TemplateView): template_name = 'order_page.html' def get_context_data(self, **kwargs): payment = Payment(order_amount=123) payment.save() ctx = super(OrderPage, self).get_context_data(**kwargs) ctx['form'] = PaymentForm(instance=payment) return ctx
-
Π¨Π°Π±Π»ΠΎΠ½ ΠΏΠ»Π°ΡΠ΅ΠΆΠ½ΠΎΠΉ ΡΠΎΡΠΌΡ:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> </head> <body> <div style="border: 1px dotted gray; padding: 15px 15px 0; margin: 30px auto; width: 300px;"> <form name="ShopForm" method="POST" action="https://yandex.ru/eshop.xml"> <ul style="list-style: none;"> <li style="margin-bottom: 20px;"> Π‘ΡΠΌΠΌΠ° Π·Π°ΠΊΠ°Π·Π°: <b>{{ form.sum.value }}</b> </li> {{ form.as_ul|safe }} <li style="margin-top: 20px;"> <input type="submit" value="ΠΠΏΠ»Π°ΡΠΈΡΡ"> </li> </ul> </form> </div> </body> </html>