> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beem.africa/llms.txt
> Use this file to discover all available pages before exploring further.

# Redirect method

> Send customers to Beem's hosted checkout page to complete payment.

With the redirect method, your application requests Beem's checkout page and redirects the customer to a secured payment page hosted by Beem.

See [Request checkout page](/api-reference/payments-checkout/request-checkout-page) for the interactive API reference with all query parameters and response examples.

***

## Step 1 — Request the checkout page

Execute a GET request to `https://checkout.beem.africa/v1/checkout` with your payment details. Authenticate using Basic Auth or an access token — see [Authentication](/guides/payments-checkout/authentication).

<Info>
  Set `sendSource=true` when your backend handles the redirect and you need the checkout URL in the response. Omit it or set `sendSource=false` when the browser should follow the HTTP 302 redirect directly.
</Info>

### Sample request URL

```
https://checkout.beem.africa/v1/checkout?amount=1200&reference_number=SAMPLE-12345&sendSource=true&transaction_id=96f9cc09-afa0-40cf-928a-d7e2b27b2408&mobile=255701000000
```

***

## Sample implementations

<Tabs>
  <Tab title="Node.js">
    ```javascript theme={null}
    const axios = require("axios");
    const https = require("https");
    const btoa = require("btoa");

    const url = "https://checkout.beem.africa/v1/checkout";
    const api_key = "<API_KEY>";
    const secret_key = "<SECRET_KEY>";
    const beem_secure_token = "<SECURE_TOKEN>";

    const payload = {
      headers: {
        "Content-Type": "application/json",
        Authorization: "Basic " + btoa(api_key + ":" + secret_key),
        "beem-secure-token": beem_secure_token,
      },
      params: {
        amount: "<amount>",
        currency: "<currency>",
        email: "<email>",
        reference_number: "<reference_number>",
        mobile: "<mobile>",
        sendSource: "<sendSource>",
        transaction_id: "<transaction_id>",
      },
    };

    function getCheckout() {
      axios
        .get(url, payload, {
          httpsAgent: new https.Agent({ rejectUnauthorized: false }),
        })
        .then((res) => {
          // sendSource: true — redirect using response URL
          if (res.request.responseURL) {
            window.location.href = res.request.responseURL;
          }
          // sendSource: false — HTTP 302 handled automatically
          console.log(res.data);
        })
        .catch((error) => console.error(error.response.data));
    }

    getCheckout();
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    <?php
    $api_key = '<api_key>';
    $secret_key = '<secret_key>';
    $secure_token = '<secure_token>';

    $url = 'https://checkout.beem.africa/v1/checkout';
    $params = http_build_query([
      'amount' => '<amount>',
      'currency' => '<currency>',
      'transaction_id' => '<transaction_id>',
      'reference_number' => '<reference_number>',
      'mobile' => '<mobile>',
      'sendSource' => '<sendSource>',
    ]);

    $ch = curl_init($url . '?' . $params);
    curl_setopt_array($ch, [
      CURLOPT_HTTPGET => true,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER => [
        'Authorization: Basic ' . base64_encode("$api_key:$secret_key"),
        'Content-Type: application/json',
        "beem-secure-token: $secure_token",
      ],
      CURLOPT_SSL_VERIFYHOST => 0,
      CURLOPT_SSL_VERIFYPEER => 0,
    ]);

    $response = curl_exec($ch);
    var_dump($response);
    ?>
    ```
  </Tab>

  <Tab title="GitHub">
    [beem-pay-checkout-api-sample — redirect](https://github.com/beemafrica/beem-pay-checkout-api-sample/tree/master/redirect)
  </Tab>
</Tabs>

***

## Step 2 — Token generation and redirect

After a valid request, Beem generates a secure token and redirects to the checkout page:

```
https://checkout.beem.africa/v1/checkout/page?token=656d9a11-7565-449e-b32a-d081c0c70fcf
```

<Info>
  If **Bank** is selected as the payment method, the loader will not show on the payment page. The user can pay within 24 hours, but the payment session expires after **10 minutes**.
</Info>

If a redirect URL is configured on your route, the customer is redirected there after a successful or failed payment.

<Tip>
  If the customer provides their full name on the checkout page, it appears in the SMS they receive after a successful payment.
</Tip>

***

## Error handling

See [Error codes](/guides/payments-checkout/error-codes) for common failure scenarios. Response schemas and examples are documented on the [Request checkout page](/api-reference/payments-checkout/request-checkout-page) API reference.
