Facilitate the process of gathering payments on your website by utilizing the simplest method available.
With Inline you have the possibility to process transactions in several ways:
- Make a redirection after initiating the transaction
- Display directly the payment interface on the same page to your customer with a Popup
The process entails:
- Requesting the creation of a payment utilizing your server and specifying payment details.
- We furnish you with a payment page link, which directs your customer to complete payment.
- Once the transaction is finalized, the customer is redirected to your page.
Step 1: Collect payment information
In order to commence the transaction, certain information such as
reference, etc., must be queued. Email and amount are mandatory. Additional information can be passed using the metadata object field.
Customer details may be obtained from a pre-existing database, session/cookie or form submission, as demonstrated in the example below.
<form action="/process-payment" method="POST"> <input type="hidden" name="user_email" value="firstname.lastname@example.org"> <input type="hidden" name="amount" value="1000"> <input type="hidden" name="cart_reference" value="cart_12dh3ds6hs2s8sha"> <button type="submit" name="make_payment" id="make-payment" title="Make payment">Make payment</button> </form>
Step 2: Initialize payment
Upon a customer selecting the payment action button, initiate a transaction through submission of a POST request to our API, specifically directed to the Initialize Notch Pay Payment API endpoint, which should include relevant parameters such as email, amount, currency and any additional requisite parameters.
amountfield must be consistent with the currency you wish to use. If for example you use XAF, this value must not contain a decimal value
cart_referenceobtained from the aforementioned form served as our
referencefor the transaction. It is recommended that a unique transaction identifier from your system is utilized as the reference instead.
callbackwas established within the payment data array.
- In the event that a callback URL is not specified on the dashboard or within the code, users will not be redirected to your site subsequent to payment.
- Test transactions may employ test callback URLs, while live transactions can utilize live callback URLs.
$url = "https://api.notchpay.co/payments/initialize"; $fields = [ 'email' => "email@example.com", 'amount' => "1000", 'currency' => "XAF", 'description' => "Payment description", // this field is optional 'reference' => 'your_unique_reference' // this param is optional but recommended ]; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Authorization: PUBLIC_KEY", "Cache-Control: no-cache", )); //So that curl_exec returns the contents of the cURL; rather than echoing it curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); echo $result;
Step 3: Verify Transaction
Notch Pay redirects the user to a
callback with the transaction reference appended in the URL after a successful transaction. For instance, http://your_website.com/afterpayment_callback.php?trxref=YOUR_REFERENCE&reference=NOTCHPAY_REFERENCE&status=PAYMENT_STATUS
Retrieve the reference from the URL parameter to call the verify endpoint to confirm the transaction status. Verify transactions before delivering value since simply visiting the callback does not prove transaction success. To learn more, check out verification reference. Note that for verification you should use Notch Pay
reference not your
Bonus: Handle Webhook
Upon the successful completion of a payment, Notch Pay will transmit a
payment.complete webhook event to the designated webhook URL that you have provided. Additional information regarding the usage and implementation of webhooks is available for your reference.