curl -X POST https://api.paybridgenp.com/v1/webhooks \
-H "Authorization: Bearer sk_test_your_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourapp.com/webhooks/paybridgenp",
"events": ["payment.succeeded", "payment.failed"]
}'const endpoint = await paybridgenp.webhooks.create({
url: "https://yourapp.com/webhooks/paybridgenp",
events: ["payment.succeeded", "payment.failed"],
});
// Save this - shown only once!
console.log(endpoint.signing_secret);import requests
url = "https://api.paybridgenp.com/v1/webhooks"
payload = {
"url": "https://yourapp.com/webhooks/paybridgenp",
"events": ["payment.succeeded", "payment.failed", "payment.refunded"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.paybridgenp.com/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://yourapp.com/webhooks/paybridgenp',
'events' => [
'payment.succeeded',
'payment.failed',
'payment.refunded'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.paybridgenp.com/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://yourapp.com/webhooks/paybridgenp\",\n \"events\": [\n \"payment.succeeded\",\n \"payment.failed\",\n \"payment.refunded\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.paybridgenp.com/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://yourapp.com/webhooks/paybridgenp\",\n \"events\": [\n \"payment.succeeded\",\n \"payment.failed\",\n \"payment.refunded\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paybridgenp.com/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://yourapp.com/webhooks/paybridgenp\",\n \"events\": [\n \"payment.succeeded\",\n \"payment.failed\",\n \"payment.refunded\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "we_01j9x2k3m4n5p6q7r8s9t0u1v2",
"livemode": true,
"url": "https://yourapp.com/webhooks/paybridgenp",
"events": [
"payment.succeeded",
"payment.failed"
],
"enabled": true,
"createdAt": "2023-11-07T05:31:56Z",
"signing_secret": "whsec_live_abc123..."
}{
"error": {
"message": "<string>",
"type": "authentication_error",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}{
"error": {
"message": "<string>",
"type": "authentication_error",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}Register a webhook endpoint
Registers an HTTPS URL to receive PayBridgeNP event notifications.
PayBridgeNP signs every delivery with an HMAC-SHA256 signature using the signing_secret returned here. Save this secret immediately - it is only shown once.
Each delivery carries two headers: X-PayBridgeNP-Signature: t=<unix_seconds>,v1=<hmac_hex> and X-PayBridgeNP-Timestamp. To verify, parse the t and v1 values out of the signature header, compute HMAC-SHA256(signing_secret, "<t>.<raw_request_body>"), and compare the hex digest to v1 in constant time. Reject deliveries whose timestamp is more than ~300 seconds old to guard against replay. The SDKs’ constructEvent() helpers do all of this for you; see the webhook verification guide.
curl -X POST https://api.paybridgenp.com/v1/webhooks \
-H "Authorization: Bearer sk_test_your_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourapp.com/webhooks/paybridgenp",
"events": ["payment.succeeded", "payment.failed"]
}'const endpoint = await paybridgenp.webhooks.create({
url: "https://yourapp.com/webhooks/paybridgenp",
events: ["payment.succeeded", "payment.failed"],
});
// Save this - shown only once!
console.log(endpoint.signing_secret);import requests
url = "https://api.paybridgenp.com/v1/webhooks"
payload = {
"url": "https://yourapp.com/webhooks/paybridgenp",
"events": ["payment.succeeded", "payment.failed", "payment.refunded"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.paybridgenp.com/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://yourapp.com/webhooks/paybridgenp',
'events' => [
'payment.succeeded',
'payment.failed',
'payment.refunded'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.paybridgenp.com/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://yourapp.com/webhooks/paybridgenp\",\n \"events\": [\n \"payment.succeeded\",\n \"payment.failed\",\n \"payment.refunded\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.paybridgenp.com/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://yourapp.com/webhooks/paybridgenp\",\n \"events\": [\n \"payment.succeeded\",\n \"payment.failed\",\n \"payment.refunded\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paybridgenp.com/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://yourapp.com/webhooks/paybridgenp\",\n \"events\": [\n \"payment.succeeded\",\n \"payment.failed\",\n \"payment.refunded\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "we_01j9x2k3m4n5p6q7r8s9t0u1v2",
"livemode": true,
"url": "https://yourapp.com/webhooks/paybridgenp",
"events": [
"payment.succeeded",
"payment.failed"
],
"enabled": true,
"createdAt": "2023-11-07T05:31:56Z",
"signing_secret": "whsec_live_abc123..."
}{
"error": {
"message": "<string>",
"type": "authentication_error",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}{
"error": {
"message": "<string>",
"type": "authentication_error",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}Authorizations
Your PayBridgeNP API key. Obtain one from the dashboard under Settings → API Keys. Prefix: sk_test_ for testing, sk_live_ for production.
Body
Response
Webhook endpoint registered.
"we_01j9x2k3m4n5p6q7r8s9t0u1v2"
true when created with a live key, false for sandbox.
"https://yourapp.com/webhooks/paybridgenp"
Event types this endpoint receives. Empty array = all events.
["payment.succeeded", "payment.failed"]
HMAC-SHA256 signing secret. Only returned once - save it now.
"whsec_live_abc123..."
Was this page helpful?