Payment Pages
The PageResource allows you to create and manage payment pages on your integration. Payment Pages provide a quick and secure way to collect payment for products, subscriptions, or donations without writing any code for the frontend.
Tip: You can also create and manage payment pages directly from your Paystack Dashboard without using the API.
Create Payment Page
Create a payment page on your integration.
$page = paystack()->page()->create([
'name' => 'School Fees Payment',
'description' => 'Payment for First Term Fees - Bright Stars Academy',
'amount' => 500000, // 5,000.00
'metadata' => [
'logo_image' => 'https://your-saas-storage.com/logos/school_a.png',
],
'custom_fields' => [
[
'display_name' => "School Name",
'variable_name' => "school_name",
],
[
'display_name' => "Student Name",
'variable_name' => "student_name",
],
[
'display_name' => "Student Code",
'variable_name' => "student_code",
],
]
]);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name of page. |
description | String | No | A description for this page. |
amount | Integer | No | Amount should be in the subunit of the supported currency. |
currency | String | No | The transaction currency. Defaults to your integration currency. |
slug | String | No | URL slug. Page will be accessible at https://paystack.com/pay/[slug]. |
type | String | No | The type of payment page to create. Options: payment, subscription, product, plan. Defaults to payment. |
plan | String | No | The ID of the plan to subscribe customers to when type is subscription. |
fixed_amount | Boolean | No | Specifies whether to collect a fixed amount. If true, amount must be passed. |
split_code | String | No | The split code of the transaction split. e.g. SPL_98WF13Eb3w. |
metadata | Object | No | Extra data to configure the page (subaccount, logo image, transaction charge). |
redirect_url | String | No | URL to redirect to upon successful payment. |
success_message | String | No | A success message to display after a successful transaction. |
notification_email | String | No | An email address that will receive transaction notifications. |
collect_phone | Boolean | No | Specify whether to collect phone numbers on the payment page. |
custom_fields | Array | No | If you would like to accept custom fields, specify them here. |
List Payment Pages
List payment pages available on your integration.
// List all pages
$pages = paystack()->page()->list();
// Filter pages
$filtered = paystack()->page()->list([
'perPage' => 20,
'page' => 1
]);Fetch Payment Page
Get details of a payment page on your integration.
$idOrSlug = 'buttercup-brunch'; // or Page ID
$details = paystack()->page()->fetch($idOrSlug);Update Payment Page
Update a payment page's details.
$idOrSlug = 'buttercup-brunch';
$updated = paystack()->page()->update($idOrSlug, [
'name' => 'Buttercup Brunch (Updated)',
'active' => true
]);Check Slug Availability
Check if a slug is available for use.
$slug = 'my-custom-slug';
$response = paystack()->page()->checkSlugAvailability($slug);
if ($response['status']) {
// Slug is available
}Redirect to Page
Redirect the user directly to a payment page using its slug. This is useful when you want to send a user to a specific payment page from your controller.
$slug = 'buttercup-brunch';
return paystack()->page()->redirect($slug);Add Products to Page
Add products to a payment page.
$pageId = 12345;
$productIds = [473, 292];
$response = paystack()->page()->addProducts($pageId, $productIds);Use Cases
Payment Pages are versatile and can be used for various scenarios:
- Simple Collections: Create a page with a fixed amount to collect payments for a specific service or item.
- Donations: Create a page with no fixed amount (
amount: null), allowing customers to enter their own amount. - Event Registration: Use
custom_fieldsto collect additional information like "T-shirt Size" or "Dietary Restrictions" along with the payment. - Product Sales: Add products to a page to create a simple storefront.
- Subscription Sign-ups: Create a page linked to a Plan to easily sign up users for recurring billing.
