Introduction
This guide explains how to effectively use Two'sPOST /v1/order_intent endpoint. This endpoint allows you to check in advance whether Two is likely to approve a buyer for invoice payment before an actual order is created. Integrating this step can significantly enhance your checkout process by providing early insights into creditworthiness, enabling you to make informed decisions about offering "Pay by Two" as a payment method.Leveraging the order_intent endpoint is a best practice for a smoother buyer experience and more predictable order processing.Why Use Order Intent?
ThePOST /v1/order_intent endpoint serves as a preliminary credit assessment tool. When you send details about a potential buyer and their intended purchase, Two performs a real-time risk evaluation. The core of the response is a boolean (approved: true or approved: false), indicating the likelihood of credit approval for a subsequent, formal order.Key Advantages:
- Enhanced Buyer Experience: By checking credit likelihood upfront, you can conditionally display "Pay by Two." If the intent is not approved, you can hide this option, preventing buyers from selecting a payment method that would ultimately be declined. This avoids a frustrating situation where a buyer completes a checkout, only to have their chosen payment method fail at the final hurdle (the
POST /v1/ordercall). - Reduced Integration Complexity: If an
order_intentisapproved: false, you can guide the buyer to alternative payment methods immediately, rather than creating an order that will beREJECTEDfor credit. As outlined in our Order Creation Path guide, aREJECTEDorder cannot proceed to verification or fulfilment. - Optimized API Usage: Avoids unnecessary
POST /v1/ordercalls for buyers who are unlikely to be approved for credit, streamlining your integration. - Improved Approval Accuracy with Detailed Data: The
order_intentschema mirrors thePOST /v1/orderschema. Providing comprehensive and accurate data—especially detailedline_items,buyer.representativeinformation, and the correctgross_amount—allows Two to perform a more precise assessment, generally leading to more reliable intent responses and higher approval rates for subsequent orders.
Recommended Integration Flow
For the most effective use oforder_intent, consider this sequence in your checkout or order creation process:- Buyer Finalizes Basket: The buyer assembles their cart or order details.
- Gather Intent Data: Collect all necessary information for the
order_intentcall, mirroring what you would send for aPOST /v1/orderrequest. This includes full buyer company details, representative information, complete line items, and accurate total amounts. - Call
POST /v1/order_intent: Send the request to Two. - Evaluate Response & See it in Action:
- If
approved: true: Confidently display "Pay by Two" as a payment option. Store the returnedtracking_id.
- If
approved: false: Hide or disable "Pay by Two" for this transaction and prompt the buyer to select an alternative payment method.
- If
- Proceed to Order Creation (if approved): If the buyer selects "Pay by Two" (after a successful
order_intent), proceed to callPOST /v1/order. Include thetracking_idfrom theorder_intentresponse in yourPOST /v1/orderrequest to link the two.
This flow ensures that an order is only created with Two if there's a high probability of credit approval, leading to a smoother journey for the buyer. This is an example of how to deal with the order intent decision in a standard checkout flow, but this conditional consideration can be extended to however you shape your integration solution.
How to Use the v1/order_intent Endpoint
1. Gather Necessary Information
To make anorder_intent request, you'll need to gather relevant information about the prospective buyer and the potential order. The closer this data matches the eventual POST /v1/order request, the more reliable the intent assessment will be.Key pieces of information include:
- Buyer Details (
buyerobject):company:company_name,organization_number,country_prefix. (Tip: Use Two's Company API to get verified company details first).representative:first_name,last_name,email,phone_number.
- Order Details:
gross_amount: The total amount of the potential order, including all taxes and charges.currency: The currency of the transaction (e.g., "GBP", "USD", "EUR").line_items(Highly Recommended and Crucial for Accuracy): An array of objects, each detailing a product or service. Include fields likename,description,quantity,unit_price,net_amount,tax_amount,tax_rate, andgross_amountfor each item.
- Merchant Information:
merchant_id: Your unique merchant identifier provided by Two.
POST /v1/order_intent API specification for a complete list of required and optional parameters.2. Make the API Request
Construct a JSON request body with the gathered information and send it to thePOST /v1/order_intent endpoint.Example Request Snippet (Conceptual):
{
"gross_amount": "120.00",
"currency": "GBP",
"buyer": {
"company": {
"company_name": "Example Corp Ltd",
"organization_number": "12345678",
"country_prefix": "GB"
},
"representative": {
"first_name": "Jane",
"last_name": "Doe",
"email": "jane.doe@examplecorp.com",
"phone_number": "+447123456789"
}
},
"line_items": [
{
"name": "Premium Widget",
"description": "High-quality widget for industrial use",
"quantity": "2",
"unit_price": "50.00",
"net_amount": "100.00",
"tax_rate": "0.20",
"tax_amount": "20.00",
"gross_amount": "120.00",
"type": "PHYSICAL"
// ... other line item details as per schema
}
],
"merchant_id": "your-unique-merchant-id",
"order_origination": "ONLINE"
}3. Interpret the Response
The API will respond with a JSON object. The most critical field isapproved.approved: true: Indicates that, based on the provided information, Two is likely to approve a formal order for this buyer and amount. You can confidently display "Pay by Two" as a payment option. The response will also include atracking_id. It is crucial to store thistracking_idas it should be passed in the subsequentPOST /v1/orderrequest.approved: false: Suggests that Two is unlikely to approve a formal order under the current conditions. You should hide "Pay by Two" for this transaction and guide the buyer to alternative payment methods.
Example Response Snippet (Conceptual):
{
"approved": true,
"tracking_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"decline_reason": null
}Important Considerations
- Accuracy is Key: The
order_intentassessment is only as good as the data provided. Ensure the information, particularlygross_amount,line_items, andbuyerdetails, accurately reflects the intended order. Discrepancies between theorder_intentand the actualPOST /v1/ordercan lead to different outcomes. - Strong Indicator, Not an Absolute Guarantee: While an
approved: truefromorder_intentis a very reliable signal, the final, binding credit decision is made during thePOST /v1/ordercall. Minor shifts in risk assessment or significant differences between the intent and order data could, in rare cases, change the outcome. - Utilize the
tracking_id: Always pass thetracking_idfrom an approvedorder_intentresponse into the correspondingPOST /v1/orderrequest. This links the preliminary check to the formal order, aiding Two's processes and providing a better audit trail. - Session-Based Assessment: The
order_intentresponse is typically valid for the current checkout session. If significant time passes or details change substantially, it's advisable to make a neworder_intentcall.
Conclusion
Integrating thePOST /v1/order_intent endpoint into your B2B sales process is a strategic move towards a more seamless and reliable checkout experience. It empowers you to proactively manage credit risk, enhance buyer satisfaction by setting clear expectations, and streamline your integration with Two. By following the recommended flow and providing accurate, detailed information, you can leverage order_intent to make "Pay by Two" a more predictable and user-friendly option for your customers.