万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    PayPalとDjango paypal-django

    customが自分のカスタマイズ用のか?

    何も入れないとDBには空っぽ。 f:id:shinriyo:20150317181555p:plain

    @csrf_exempt
    def view_that_asks_for_money(request):
        # url = "http://47cc7e44.ngrok.com"
        url = "http://3ea2346f.ngrok.com"
        # What you want the button to do.
        paypal_dict = {
            "business": settings.PAYPAL_RECEIVER_EMAIL,
            "amount": "10.00",
            "item_name": "name of the item",
            "invoice": "unique-invoice-id23",
            "notify_url": url + reverse('paypal-ipn'),
            "return_url": url + reverse('return-location'),
            "cancel_return": url + reverse('return-location'),
            # for check by show_me_the_money later!!!
            "custom": request.user.id
        }

    ここで設定しておけば出来るかもしれない。

    customを使って、

    @csrf_exempt
    def show_me_the_money(sender, **kwargs):
        ipn_obj = sender
        if ipn_obj.payment_status == ST_PP_COMPLETED:
            # ここで取るぜ!
            user_id = ipn_obj.custom
    
            p = PurchaseHistory(name=user_id, message='ST_PP_COMPLETED')
            p.save()
    
    valid_ipn_received.connect(show_me_the_money)