---
title: Create
slug: payments/KYtw-create
docTags: 
createdAt: 2023-11-28T13:54:32.891Z
---

To create a Checkout URL in Stripe, use the "*CreateCheckoutURL"&#x20;*&#x61;ction. You need to prepare a request object and a list of line items. The request object should include the mode, processorId, and action. See the [Checkout URL - Stripe](docId\:oiusBOfbkCn2aoKTyBDj7) for all required fields.&#x20;

:::hint{type="info"}
Please note that you can only request one Checkout URL at a time.
:::

The *resp* will return a response that includes the new Stripe Checkout URL.



The following is an example of a Checkout URL for Stripe.

:::CodeblockTabs
Request

```apex
Map<String, Object> checkoutMap = new Map<String, Object>();
// /You may only specify one of these parameters: 'customerId', 'customerEmail'
//checkoutMap.put('customerId', stripeCustomerId);
checkoutMap.put('customerEmail', customerEmail);
checkoutMap.put('mode', 'payment');
checkoutMap.put('paymentMethodTypes', new List<String>{'card'});
checkoutMap.put('successUrl', 'https://example.com/success');
checkoutMap.put('cancelUrl', 'https://example.com/cancel');

List<Object> lineItemsList = new List<Object>();
// The line_items parameter is required in payment and subscription mode, it's not required in setup mode   
// amount, quantity, currency and name are required for line item's price_data
// Subscriptions require at least one recurring price or plan to be passed to line_items and quantity

Map<String,Object> lineItemMap1 = new Map<String,Object>();
//lineItemMap1.put('processorPriceId', processorPriceId);
lineItemMap1.put('quantity', 1);
lineItemMap1.put('unitPrice', 100);
lineItemMap1.put('itemCurrency', 'USD');
lineItemMap1.put('name', 'item1');

Map<String,Object> lineItemMap2 = new Map<String,Object>();
//lineItemMap2.put('processorPriceId', processorPriceId);
lineItemMap2.put('quantity', 2);
lineItemMap2.put('unitPrice', 120);
lineItemMap2.put('itemCurrency', 'USD');
lineItemMap2.put('name', 'item2');

lineItemsList.add(lineItemMap1);
lineItemsList.add(lineItemMap2);

checkoutMap.put('lineItems', lineItemsList);    

Map<String,Object> PaymentIntentMetadata = new Map<String,Object>();
PaymentIntentMetadata.put('order_id', 'abc123'); // any key-value pair
checkoutMap.put('payment_intent_metadata', PaymentIntentMetadata);

// Add subscriptionData only in subscription mode
Map<String,Object> subscriptionData = new Map<String,Object>();
//You can only specify one of these parameters: trialEnd, trialPeriodDays.
DateTime dt =  Datetime.newInstance(2022, 8, 30);
//subscriptionData.put('trialEnd', dt);
subscriptionData.put('trialPeriodDays', 2);

Map<String,Object> subscriptonMetadata = new Map<String,Object>();
subscriptonMetadata.put('sub_id', 'test_123'); // any key-value pair
subscriptionData.put('subscriptionMetaData', subscriptonMetadata);

checkoutMap.put('subscriptionData', subscriptionData); 

Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('checkout', new List<Object>{checkoutMap});
String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'CreateCheckoutURL');
reqObj.put('processorId', stripeProcessorOrgId);
reqObj.put('requestJSON', reqJSON);

//  Placing a request to Breadwinner Global API
Map<String, Object> resp = bw_payments.BreadwinnerPaymentsAPI.call(reqObj);
System.debug(resp);

```

Response

```json
{Action=CreateCheckoutURL, Version=1.0, responseJSON={
  "id": "cs_test_b1Bkbh5UEKr9cDaXMWMgo9PMMdbI3VDLkfj5T0vhEjwK8MtKGDh2AdAXLu",
  "object": "checkout.session",
  "after_expiration": {
    "recovery": {
      "allow_promotion_codes": false,
      "enabled": true,
      "expires_at": 1664000753,
      "url": "https://buy.stripe.com/r/test_YWNjdF8xR2I1TE1DRzkzNGZseHJYLF9NSkJ0SGN5T3hrRmdRQ2VkdjVMYVpSclMxT1RaSVhm0100W22hGStn"
    }
  },
  "allow_promotion_codes": null,
  "amount_subtotal": 340,
  "amount_total": 340,
  "automatic_tax": {
    "enabled": false,
    "status": null
  },
  "billing_address_collection": null,
  "cancel_url": "https://example.com/cancel",
  "client_reference_id": null,
  "consent": null,
  "consent_collection": null,
  "currency": "usd",
  "customer": "cus_MGBXfvS5jaq1CD",
  "customer_creation": null,
  "customer_details": null,
  "customer_email": null,
  "expires_at": 1661495152,
  "livemode": false,
  "locale": null,
  "metadata": {},
  "mode": "payment",
  "payment_intent": "pi_3LaZVlCG934flxrX1Mr61HMB",
  "payment_link": null,
  "payment_method_collection": "always",
  "payment_method_options": {},
  "payment_method_types": [
    "card"
  ],
  "payment_status": "unpaid",
  "phone_number_collection": {
    "enabled": false
  },
  "recovered_from": null,
  "setup_intent": null,
  "shipping": null,
  "shipping_address_collection": null,
  "shipping_options": [],
  "shipping_rate": null,
  "status": "expired",
  "submit_type": null,
  "subscription": null,
  "success_url": "https://example.com/success",
  "total_details": {
    "amount_discount": 0,
    "amount_shipping": 0,
    "amount_tax": 0
  },
  "url": null
}, 
statusCode=200, 
timestamp=1661408754570, 
validRequest=true
}


```
:::

