CheckoutSessions
Learn more about the CheckoutSession resource
A CheckoutSession resource represents a one-time use PayRex-hosted checkout page and will expire at a certain period.
Create a CheckoutSession if you prefer PayRex to provide a Checkout Page for your customer. Create a CheckoutSession and redirect your customer to the url
attribute of a CheckoutSession.
If you prefer full control of the Checkout Page and PayRex will handle the payment processing, please refer to the Elements guide.
Endpoints
POST /checkout_sessions/:id/expire
The CheckoutSession Resource
{
"id": "cs_AbvnRnF9r577BBFFuNsLFvXvLes1CeeS",
"resource": "checkout_session",
"customer_reference_id": null,
"client_secret": "cs_AbvnRnF9r577BBFFuNsLFvXvLes1CeeS_secret_tttefYgf9BgAnuiq9bN8EuwrpUShZU4E",
"status": "active",
"currency": "PHP",
"line_items": [
{
"id": "cs_li_27xaTabzf7pBvpGjFAjHynVHVGbauwFz",
"resource": "checkout_session_line_item",
"name": "Some name",
"amount": 10000,
"quantity": 5,
"description": null,
"image": "https://some-url.com/1.jpg"
},
{
"id": "cs_li_XgdQMVST88szpcjMayDGaE3iGNEJvBx1",
"resource": "checkout_session_line_item",
"name": "Some name",
"amount": 10000,
"quantity": 5,
"description": null,
"image": null
}
],
"livemode": false,
"url": "https://checkout.payrexhq.com/c/cs_AbvnRnF9r577BBFFuNsLFvXvLes1CeeS_secret_tttefYgf9BgAnuiq9bN8EuwrpUShZU4E",
"payment_intent": {
"id": "pi_UDQ5s2yLAeE4h1CJsP9Mm6RYYk7MMnsb",
"amount": 100000,
"capture_type": null,
"client_secret": "pi_UDQ5s2yLAeE4h1CJsP9Mm6RYYk7MMnsb_secret_azBhHvfc17JJUDs8yi94KpMbtv56eQ5D",
"currency": "PHP",
"description": "Some description",
"livemode": false,
"metadata": null,
"next_action": null,
"payment_method_id": null,
"payment_methods": [
"card",
"gcash"
],
"payment_method_options": {
"card": {
"capture_type": "automatic"
}
},
"status": "awaiting_payment_method",
"return_url": null,
"capture_before_at": null,
"created_at": 1721726975,
"updated_at": 1721726975
},
"metadata": null,
"success_url": "http://some-url.com",
"cancel_url": "http://some-url.com",
"payment_methods": [
"card",
"gcash"
],
"description": "Some description",
"submit_type": "pay",
"expires_at": 1721813375,
"created_at": 1721726975,
"updated_at": 1721726975
}
Attributes
id string
Unique identifier for the resource. The prefix is cs_
.
resource string
Represents the resource's type. The value is checkout_session
.
amount string
The final amount to be collected by the CheckoutSession. This is a positive integer your customer will pay in the smallest currency unit, cents. If the customer pays ₱ 120.50, the amount of the CheckoutSession should be 12050.
The CheckoutSession amount
is derived from the sum of all line_items.quantity
* line_items.amount
.
The minimum amount is ₱ 20 (2000 in cents), and the maximum amount is ₱ 59,999,999.99 (5999999999 in cents).
customer_reference_id string
A unique reference of the CheckoutSession aside from the id
attribute. This can be an order ID, a cart ID, or similar, and can be used to reconcile the CheckoutSession with your internal system.
client_secret string
The client secret of the CheckoutSession.
status string
The latest status of the CheckoutSession. Possible values are active
, completed
, or expired
.
currency string
A three-letter ISO currency code in uppercase. As of the moment, we only support PHP.
line_items Array of hash
This attribute holds your customer's list of items to pay.
Show child attributes
id string
Unique identifier for the resource. The prefix is cs_li
.
resource string
Represents the resource's type. The value is checkout_session_line_item
.
name string
The name of the line item. The name attribute describes the line item. It could be a product name or the service that you offer.
amount string
The amount of the line item in a single unit. This could also be considered as a unit price.
This is a positive integer in the smallest currency unit, cents. If the line item should be ₱ 120.50, the amount should be 12050.
quantity string
The quantity of the line item. The quantity will be multiplied by the line_item.amount to compute the final amount of the CheckoutSession.
description string
Additional details of the line_item. If you want to add long details to the line_item, use this attribute.
image string
The image of the line_item. This should be a publicly accessible URL. If this is not provided, PayRex will provide a default image.
livemode boolean
The value is true
if the resource's mode is live or the value is false
if the resource is in test mode.
url string
The URL where your customer will be redirected to complete a payment.
payment_intent PaymentIntent
The PaymentIntent resource created for the CheckoutSession.
metadata hash
A set of key-value pairs attached to the CheckoutSession and the resources created by the CheckoutSession, e.g., PaymentIntent and Payment. This is useful for storing additional information about the CheckoutSession.
success_url string
The URL where your customer will be redirected after a successful payment.
cancel_url string
The URL where your customer will be redirected if they decide not to continue with the payment.
payment_methods array of strings
The list of payment methods allowed to be processed by the CheckoutSession.
description string
An arbitrary string attached to the CheckoutSession. Useful reference when viewing paid Payment from PayRex Dashboard.
submit_type string
This is a string that will show as the text for the pay button of the CheckoutSession. You can use this to customize the action text of the pay button. The default value is pay
.
expires_at timestamp
The time when the CheckoutSession will expire. Once the CheckoutSession expires, your customer can no longer complete the payment.
Measured in seconds since the Unix epoch.
created_at timestamp
The time the resource was created and measured in seconds since the Unix epoch.
updated_at timestamp
The time the resource was updated and measured in seconds since the Unix epoch.