Payfast API的ITN回调:如何在仪表盘生成的HTML代码中集成Notify URL?
Hey there! Adding the Notify URL to your existing Payfast setup is straightforward—you just need to include a hidden input field in the form that your JavaScript function is submitting. Here's how to do it:
Step 1: Locate the Payfast Form in Your HTML
First, find the <form> element linked to the click_8eb310a4f3ae8dcc6556286f70cbd30f function. This form should already have fields like amount, custom, and other required Payfast inputs.
Step 2: Insert the Notify URL Hidden Input
Inside that <form> tag, add a new hidden input named notify_url, with its value set to your actual notification endpoint URL. Here's the code for that input:
<input type="hidden" name="notify_url" value="https://your-domain.com/your-payfast-notification-handler">
Replace the value with your own public URL where Payfast will send payment status updates (like successful or failed transactions).
Example of the Updated Form
If your original form looks like this:
<form id="payfast-checkout" action="https://www.payfast.co.za/eng/process" method="post"> <input type="hidden" name="merchant_id" value="your-merchant-id"> <input type="hidden" name="amount" value="50.00"> <!-- Other existing Payfast fields --> <button type="button" onclick="click_8eb310a4f3ae8dcc6556286f70cbd30f(this.form)">Complete Payment</button> </form>
Your updated form with the Notify URL will look like this:
<form id="payfast-checkout" action="https://www.payfast.co.za/eng/process" method="post"> <input type="hidden" name="merchant_id" value="your-merchant-id"> <input type="hidden" name="amount" value="50.00"> <!-- Added Notify URL field --> <input type="hidden" name="notify_url" value="https://your-domain.com/your-payfast-notification-handler"> <!-- Other existing Payfast fields --> <button type="button" onclick="click_8eb310a4f3ae8dcc6556286f70cbd30f(this.form)">Complete Payment</button> </form>
Quick Notes
- Ensure your Notify URL is publicly accessible (Payfast needs to reach it to send notifications).
- The field name
notify_urlis case-sensitive—don’t misspell it! - If you generate the form dynamically via JavaScript, you can also create this input programmatically inside the
click_8eb310a4f3ae8dcc6556286f70cbd30ffunction before submitting the form.
内容的提问来源于stack exchange,提问作者Itumeleng Masuluke

