1

プロジェクトで単純な Paypal 支払いを作成しようとしていますが、それが機能するかどうかを確認してから、よりカスタム化します。問題は、期待どおりに機能しないことです。(サンドボックスを使用して) 支払いを行うと、myemail-buyer@gmail.com は正常に送金されますが、myemail-facilitator には通知がありません (ただし、お金を受け取りました)。さらに、シグナルが受信されておらずPaypal IPNS、 Django-admin に行がありませんPaypal IPNs

おそらく多くのことが考えられますが、私はdjango-paypalが初めてなので、何が問題なのかわかりません。

開発サーバーを使用していますが、外部からアクセスできます。

見る

def payment(request):
    items = Job.get_unpaid_orders_for_user(request.user)
    table = PaymentTable(items)
    total_price = 0
    payment = Payment.objects.create()
    for item in items:
        if item.invoice.final_price:
            payment.invoices.add(item.invoice)
            total_price += item.invoice.final_price
    payment.total_price = total_price
    payment.save()

    context = {}
    context['items'] = items
    context['table'] = table
    context['total_price'] = total_price

    paypal_dict = {
        "business": "myemail-facilitator@gmail.com",
        "currency_code":"EUR",
        "amount": total_price,
        "item_name": payment.get_desc(),
        "invoice": payment.payment_identifier,
        "notify_url": "http://my_public_ip:8000/" + reverse('paypal-ipn'),
        "return_url": "http://my_public_ip:8000/return",
        "cancel_return": "http://my_public_ip:8000/cancel",
        "custom": "Upgrade all users!",  # Custom command to correlate to some function later (optional)
    }

    form = PayPalPaymentsForm(initial=paypal_dict)
    context["form"]=form
    return render(request, "ordersapp/payment/payment.html", context=context)

ORDERSAPP の MODELS.PY の下部

from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received

def show_me_the_money(sender, **kwargs):
    ipn_obj = sender
    print ipn_obj
    try:
        print ipn_obj.__dict__
    except: print ipn_obj.__dict__()
    if ipn_obj.payment_status == ST_PP_COMPLETED:
        # WARNING !
        # Check that the receiver email is the same we previously
        # set on the business field request. (The user could tamper
        # with those fields on payment form before send it to PayPal)
        if ipn_obj.receiver_email != "receiver_email@example.com":
            # Not a valid payment
            return

        # ALSO: for the same reason, you need to check the amount
        # received etc. are all what you expect.

        # Undertake some action depending upon `ipn_obj`.
        if ipn_obj.custom == "Upgrade all users!":
            # Users.objects.update(paid=True)
            print 'PAYMENT OK'
    else:
        print 'BAD'
        #...

valid_ipn_received.connect(show_me_the_money)

設定.PY

INSTALLED_APPS = (

    'django.contrib.auth',
    'mainapp',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    ....
    ....
    'paypal',
    'paypal.standard.ipn'

)

PAYPAL_RECEIVER_EMAIL = "myemail-facilitator@gmail.com"
PAYPAL_TEST = True
4

0 に答える 0