# Create Payment

## Create Payment (Checkout)

> 📘
>
> This call must be performed from your backend server!\
> The Create-checkout-link call requires your **private\_key** (your secret password) which should not be exposed on the client-side.

Learn how to make a [Payment request](https://docs.unipaas.com/reference/websdkpayincontroller_createcheckout).

## Example of a Request Payload for a SaaS Platform:

> 📘
>
> For a SaaS platform, the payload should not include an items array, and the vendor ID must be sent directly as a separate parameter.

```json
{
  "amount": 100,
  "currency": "GBP",
  "vendorId": "66532df5d55926b2b12a874a",
  "reference": "1000456",
  "description": "Service June",
  "email": "test@test.com", //consumer email
  "country": "GB",
  "invoiceUrl": "http://yourcompany.com/invoice.pdf",
  "dueDate": "2020-12-13", //OPTIONAL
  "vatAmount": 19, //OPTIONAL
  "successfulPaymentRedirect": "http://yourcompany.com/redirect", //OPTIONAL
  "paymentMethods": ["bankTransfer"], // creditCard, bankTransfer, directDebit, apm
  "consumer": {
    "name": "Raul Runte",
    "reference": "CON-REF-123",
  }
}

```

## Example of a Request Payload for a Marketplace Platform:

> 📘
>
> For a Marketplace Platform, the vendor ID is included within the items array, allowing for multiple items and vendors, with the payment being split accordingly.

```json
{
  "amount": 100,
  "currency": "GBP",
  "orderId": "1000456",
  "description": "Iphone case",
  "email": "test@test.com",
  "phone": "+447911123456",
  "country": "GB",
 	"reference": "100456",
  "invoiceUrl": "http://yourcompany.com/invoice.pdf",
  "dueDate": "2020-12-13", //OPTIONAL
  "vatAmount": 19, //OPTIONAL
  "successfulPaymentRedirect": "http://yourcompany.com/redirect", //OPTIONAL
  "items": [	
    {
      "name": "Iphone case",
      "amount": 100,
      "vendorId": "5ee8e655a65f08fcd71fe4d9",
      "platformFee": 0,
      "quantity": 1
    }
  ],
  "consumer": {
    "name": "Raul Runte",
		"reference": "CON-REF-123",
  },
  "billingAddress": {
    "firstName": "string",
    "lastName": "string",
    "city": "London",
    "country": "GB",
    "line1": "64 New Cavendish Street",
    "line2": "",
    "postalCode": "W1G 8TB",
    "state": ""
  },
  "shippingSameAsBilling": true,
  "shippingAddress": {
    "firstName": "string",
    "lastName": "string",
    "city": "London",
    "country": "GB",
    "line1": "64 New Cavendish Street",
    "line2": "",
    "postalCode": "W1G 8TB", 
    "state": ""
  },
  
  "metadata": {
    "CustomerID": "457349"
  }
}
```

In the response you will find the **shortLink** field, which contains the URL of the checkout page.

## Optional address fields

We highly recommend you pass information about the consumer's address when creating a checkout. Passing the billing and shipping (for physical goods) addresses will increase the success rate of the transaction.

In case shipping address is not applicable (for non-physical goods), set the `shippingSameAsBilling` flag to `true`.

**Note:** Add a 2-letter ISO `state` code (for customers based in the US, Canada, and India only).
