Skip to main content

Server Setup

(We highly recommend using this S2S method for all production activities and functionalities, as it offers greater scalability and enhanced features designed for production environments)

To create a payment intent, send a request to either our sandbox or production endpoint. For detailed information, refer to the API Reference documentation.

Upon successful creation, you will receive a client_secret, which must be provided to the SDK to render it properly.

// Example Usage :- Can be Modified
async function createPaymentIntent(request) {
/* Add respective env enpoints
- Sandbox - https://sandbox-api.doopayment.com
- Prod - https://api.doopayment.com
*/
const url = "https://sandbox-api.doopayment.com";
const apiResponse = await fetch(`${url}/payments`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"api-key": `API_KEY`,
},
body: JSON.stringify(request),
});
const paymentIntent = await apiResponse.json();

if (paymentIntent.error) {
console.error("Error - ", paymentIntent.error);
throw new Error(paymentIntent?.error?.message ?? "Something went wrong.");
}
return paymentIntent;
}

2. Create a payment using Doo Payment Node SDK

(We recommend using this method for local development and quick integration to test various use cases.)

2.1 Install the doopayment-node library

Install the package and import it in your code

npm install @finpoints-tech/doopayment-node

2.2 Create a payment

Before creating a payment, import the hyper dependencies and initialize it with your API key. Get your API key from Doo Payment Merchant Portal.

const hyper = require("@finpoints-tech/doopayment-node")(YOUR_API_KEY);

Add an endpoint on your server that creates a Payment. Creating a Payment helps to establish the intent of the customer to start a payment. It also helps to track the customer’s payment lifecycle, keeping track of failed payment attempts and ensuring the customer is only charged once. Return the client_secret obtained in the response to securely complete the payment on the client.

// Example Usage :- Can be Modified
async function createPaymentIntent(request) {
/* Add respective env enpoints
- Sandbox - https://sandbox-api.doopayment.com
- Prod - https://api.doopayment.com
*/
const url = "https://sandbox-api.doopayment.com";
const apiResponse = await fetch(`${url}/payments`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"api-key": `API_KEY`,
},
body: JSON.stringify(request),
});
const paymentIntent = await apiResponse.json();

if (paymentIntent.error) {
console.error("Error - ", paymentIntent.error);
throw new Error(paymentIntent?.error?.message ?? "Something went wrong.");
}
return paymentIntent;
}

3. Integrate Web SDK

To integrate Web SDK, follow Node And React, Node and HTML and Vanilla JS and REST API Integration.

note

In case your integrating the ExpressCheckout (mentioned later below), instead of creating multiple paymentIntents for the same customer session, you can also use paymentsUpdate API for better analytics.