# Collections/Payins -  Redirect

Environment Urls

```
Sandbox: https://devbox.paydestal.com/pay
Prod:    https://api.paydestal.com/pay
```

* Virtual Accounts
* Card Processing
* USSD Processing
* Pay Redirect&#x20;

## Payment Redirect

You can call the [Initialize Transaction](https://docs.paydestal.com/paydestal/collections-payins-redirect) Endpoint  from your server to generate a checkout link, then redirect your users to the link so they can pay. After payment is made, the users are returned to your provided link in  the callbackUrl\
Default currency is presumed NGN except when specified differently.

```html


< <form id="paymentForm" action="/saveAndPay" method="POST">
    <input type="hidden" name="customerEmail" id="customerEmail">
    <input type="hidden" name="amount" id="amount">
    <input type="hidden" name="reference" id="reference">
    <button type="submit" name="payBtn" id="pay-now" title="Pay now">Pay now</button>
  </form>

  <script>
     
    const email = "cust@email.com";  
    const amount = 4500;  
    const reference = "23445yyt";  

    // Populate the hidden input fields with values
    document.getElementById('customerEmail').value = email;
    document.getElementById('amount').value = amount;
    document.getElementById('reference').value = reference;
  </script>
```

<pre class="language-javascript"><code class="lang-javascript"><strong>
</strong><strong>
</strong><strong>Form-Data Request 
</strong>
<strong>const axios = require('axios');
</strong>
const url = "{baseUrl}/api/v1/transaction/initialize";

const data = {
  customerEmail: "cust@email.com",
  amount: "4500",
  callbackUrl: "https://pay.tech/callback",

};

axios.post(url, data, {
  headers: {
    Authorization: "Bearer {your client secret}",
    "Cache-Control": "no-cache",
     "Content-Type: "multipart/form-data" 
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error('Error:', error.response ? error.response.data : error.message);
});




JSON Payload Request

if you prefer to make a json request instead of the form-data above, the endpoint to call is the one used in the snippet below:-


const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer {{your client secret}}");
<strong>
</strong>
const raw = JSON.stringify({
  "amount": 4500,
  "customerEmail": "cust@email.com",
  "callbackUrl": "https: //pay.tech/callback",
  "reference": "3t4t4gthty754433455y5"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("{{baseUrl}}/pay/api/v1/transaction/initializer", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));



</code></pre>

```json
{
  "responseCode": "201",
  "responseMessage": "Payment Order Created Successfully!",
  "data": {
    "amount": 4500.0,
    "customerEmail": "cust@email.com",
    "currency": "NGN",
    "reference": "06962146778",
    "redirectUrl": "https://checkout.paydestal.com/charge/06962146778",
    "callbackUrl": "https://paydestal.com",
    "paymentStatus": "STARTED"
  },
  "success": true
}
```
