I'm using django-paypal
and paypalrestsdk
to integrate Paypal payment & subscriptions to my website.
I've looked over django-paypal
and other modules but I wasn't able to fully understand the process of handling a webhook.
I'm getting a 405 Error
in my console when I'm completing a payment.
I have successfully created a paypal sandbox account for testing purposes ( two user accounts were automatically created on it for tests ).
In my settings.py
:
PAYPAL_RECEIVER_EMAIL = "the email"
PAYPAL_IDENTITY_TOKEN = "_BB3dqp-crOrUo2uh84g0zN2alX0LwWPAT85r0g-2Eo0"
In my index.html
:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="my_email" id="id_business" />
<input type="hidden" name="amount" value="1" id="id_amount" />
<input type="hidden" name="item_name" value="Subscription Package" id="id_item_name" />
<input type="hidden" name="notify_url" value="website/page" id="id_notify_url" />
<input type="hidden" name="cancel_return" value="website/page" id="id_cancel_return" />
<input type="hidden" name="return" value="website/page" id="id_return_url" />
<input type="hidden" name="invoice" value="UID" id="id_invoice" />
<input type="hidden" name="cmd" value="_xclick" id="id_cmd" />
<input type="hidden" name="charset" value="utf-8" id="id_charset" />
<input type="hidden" name="currency_code" value="USD" id="id_currency_code" />
<input type="hidden" name="no_shipping" value="1" id="id_no_shipping" />
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="Buy it Now" />
</form>
And my views.py
:
class PayPalWebhook(View):
@staticmethod
def post(request):
event_json = json.loads(request.body)
print '=========='
print event_json.type
print '=========='
print event_json
return HttpResponse(status=200)
class PaypalAPI(View):
@staticmethod
def post(request):
pass
- shall I pass anything in my
PaypalAPI
class in order to get my form working as it should ? ( for the moment it correctly sends the payment but it uses the values inside the form parameters and that's not what I want) - how can I get rid of that 405 error ? What am I doing wrong ?( as a mention, I created a webhook in dashboard)
I would just like to see the webhooks in my console, that's all.