Payment Intents
Learn more about the Payment Intent resource
A Payment Intent tracks the customer's payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once.
Create one Payment Intent whenever your customer arrives at your checkout page. Retrieve the Payment Intent later to see the history of payment attempts.
A Payment Intent transitions through multiple statuses throughout its lifetime via Payrex.JS until it creates, at most, one successful payment.
Endpoints
| Endpoint | Name |
|---|---|
| POST /payment_intents | Create payment intent endpoint |
| GET /payment_intents/:id | Retrieve payment intent endpoint |
| POST /payment_intents/:id/cancel | Cancel payment intent endpoint |
| POST /payment_intents/:id/capture | Capture payment intent endpoint |
The PaymentIntent Resource
{
"id": "pi_SJuGtXXC3XNRWpW3W1zQKiLWf67ZC4sX",
"resource": "payment_intent",
"amount": 10000,
"amount_received": 0,
"amount_capturable": 0,
"client_secret": "pi_SJuGtXXC3XNRWpW3W1zQKiLWf67ZC4sX_secret_7KGizzHuLtPtaLwiRMHekBHRUo6yv52r",
"currency": "PHP",
"description" :"",
"last_payment_error": null,
"latest_payment": null,
"livemode": false,
"metadata": null,
"next_action": {
"type": "redirect",
"redirect_url": "https://my-application/redirect"
},
"payment_method_options": {
"card": {
"capture_type" :"automatic",
}
},
"payment_methods": ["card", "gcash"],
"statement_descriptor": null,
"status": "awaiting_payment_method",
"capture_before_at": 1700407880,
"customer": null,
"created_at": 1700407880,
"updated_at": 1700407880
}
Attributes
id string
Unique identifier for the resource. The prefix is pi_.
resource string
Represents the resource's type. The value is payment_intent.
amount string
The amount to be collected by the PaymentIntent. This is a positive integer that your customer will pay in the smallest currency unit, cents. If the customer should pay ₱ 120.50, the amount of the PaymentIntent should be 12050.
The minimum amount is ₱ 20 (2000 in cents) and the maximum amount is ₱ 59,999,999.99 (5999999999 in cents).
amount_received string
The amount already collected by the PaymentIntent. This is a positive integer that your customer paid in the smallest currency unit, cents. If the customer paid ₱ 120.50, the amount_received of the PaymentIntent should be 12050.
The minimum amount is ₱ 20 (2000 in cents) and the maximum amount is ₱ 59,999,999.99 (5999999999 in cents).
This attribute is best used for hold then capture feature of card payment method.
amount_capturable string
The amount that can be captured by the PaymentIntent. This is a positive integer that your customer authorized in the smallest currency unit, cents. If the customer authorized ₱ 120.50, the amount_capturable of the PaymentIntent should be 12050.
The minimum amount is ₱ 20 (2000 in cents) and the maximum amount is ₱ 59,999,999.99 (5999999999 in cents).
This attribute is best used for hold then capture feature of card payment method.
payment_methods array of strings
The list of payment methods allowed to be processed by the PaymentIntent.
statement_descriptor string
Text that appears on the customer's bank statement. This value overrides the merchant account's trade name. For information about requirements, including the 22-character limit, see the Statement Descriptor guide.
status string
The latest status of the Payment Intent. Possible values are awaiting_payment_method, awaiting_next_action, processing, or succeeded.
You can check this guide to see how a Payment Intent transition from one status to another.
client_secret string
The client secret of this Payment Intent used for client-side retrieval using a public API key. The client secret can be used to complete a payment from your client application.
currency string
A three-letter ISO currency code in uppercase. As of the moment, we only support PHP.
description string
An arbitrary string attached to the Payment Intent. Useful reference when viewing paid payments from the PayRex Dashboard.
last_payment_error hash
A hash that describes the last failed payment attempt if there is any. The value is null if there are no failed payments for the Payment Intent.
Show child attributes
last_payment_error.code string
The developer-friendly code why a payment has failed.
last_payment_error.detail string
The human-readable detail why a payment has failed.
latest_payment hash
A Payment resource in a form of hash is returned if there is a complete payment attempt from the customer. The value is null if there are no completed payment attempts.
livemode boolean
The value is true if the resource's mode is live or the value is false if the resource mode is test.
See the mode guide for more details.
metadata hash
A set of key-value pairs attached to the Payment Intent and the resources created by the Payment Intent, e.g., Payment. This is useful for storing additional information about the PaymentIntent.
The value is null if there are no metadata for the Payment Intent.
return_url string
The URL where your customer will be redirected after completing the authentication if they didn't exit or close their browser while authenticating.
next_action hash
If the next_action attribute is present, it tells you what actions you need to take so that your customer can make a payment using the selected method.
Show child attributes
next_action.type string
The type of the next action to perform, The possible value is redirect.
next_action.redirect_url string
The URL for authenticating a payment by redirecting your customer.
payment_method_id string
The latest Payment Method ID of attached to the Payment Intent.
payment_method_options hash
A set of key-value pairs that can modify the behavior of the payment method attached to the payment intent.
Show child attributes
card hash
Show child attribute
capture_type string
Describes the capture_type of a card payment. Possible values are automatic or manual. This is used for hold then capture feature. Please refer to this guide for more details.
allowed_bins array
Restricts the allowed card BINs for a card payment. Please refer to this guide for more details.
allowed_funding array
Restricts the allowed card funding for a card payment. Please refer to this guide for more details.
capture_before_at timestamp
The time when the Payment Intent can be captured.
This attribute is best used for hold then capture feature of card payment method.
customer hash
The Customer resource related to the Payment Intent resource. If the Payment Intent does not have a customer resource, the value is null.
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.