Skip to content

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.

php
$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

ParameterTypeRequiredDescription
nameStringYesName of page.
descriptionStringNoA description for this page.
amountIntegerNoAmount should be in the subunit of the supported currency.
currencyStringNoThe transaction currency. Defaults to your integration currency.
slugStringNoURL slug. Page will be accessible at https://paystack.com/pay/[slug].
typeStringNoThe type of payment page to create. Options: payment, subscription, product, plan. Defaults to payment.
planStringNoThe ID of the plan to subscribe customers to when type is subscription.
fixed_amountBooleanNoSpecifies whether to collect a fixed amount. If true, amount must be passed.
split_codeStringNoThe split code of the transaction split. e.g. SPL_98WF13Eb3w.
metadataObjectNoExtra data to configure the page (subaccount, logo image, transaction charge).
redirect_urlStringNoURL to redirect to upon successful payment.
success_messageStringNoA success message to display after a successful transaction.
notification_emailStringNoAn email address that will receive transaction notifications.
collect_phoneBooleanNoSpecify whether to collect phone numbers on the payment page.
custom_fieldsArrayNoIf you would like to accept custom fields, specify them here.

List Payment Pages

List payment pages available on your integration.

php
// 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.

php
$idOrSlug = 'buttercup-brunch'; // or Page ID

$details = paystack()->page()->fetch($idOrSlug);

Update Payment Page

Update a payment page's details.

php
$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.

php
$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.

php
$slug = 'buttercup-brunch';

return paystack()->page()->redirect($slug);

Add Products to Page

Add products to a payment page.

php
$pageId = 12345;
$productIds = [473, 292];

$response = paystack()->page()->addProducts($pageId, $productIds);

Use Cases

Payment Pages are versatile and can be used for various scenarios:

  1. Simple Collections: Create a page with a fixed amount to collect payments for a specific service or item.
  2. Donations: Create a page with no fixed amount (amount: null), allowing customers to enter their own amount.
  3. Event Registration: Use custom_fields to collect additional information like "T-shirt Size" or "Dietary Restrictions" along with the payment.
  4. Product Sales: Add products to a page to create a simple storefront.
  5. Subscription Sign-ups: Create a page linked to a Plan to easily sign up users for recurring billing.

Released under the MIT License.