braintree vs paypal-rest-sdk vs razorpay vs square vs stripe
Payment Gateway Server SDKs for Frontend Integration
braintreepaypal-rest-sdkrazorpaysquarestripe

Payment Gateway Server SDKs for Frontend Integration

These libraries are official server-side Node.js SDKs used to securely communicate with payment providers. While frontend developers do not install them in the browser, architects must understand them because they define the API contracts β€” such as Payment Intents, Orders, or Client Tokens β€” that the frontend application consumes to process transactions safely.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
braintree0333368 kB104 months agoMIT
paypal-rest-sdk0---8 years agoSEE LICENSE IN https://github.com/paypal/PayPal-node-SDK/blob/master/LICENSE
razorpay0237326 kB126a year agoMIT
square011111.7 MB14 days agoMIT
stripe04,42614.7 MB4518 days agoMIT

Payment Gateway Server SDKs: Architecture & Integration Flows

These five packages are server-side Node.js libraries that act as the secure bridge between your backend and payment providers. As a frontend architect, you won't install these in the browser β€” instead, your backend team uses them to create secure sessions that your frontend code consumes. Let's compare how each library shapes the integration flow.

πŸ”‘ Initialization & Configuration

Every SDK requires authentication keys, but the setup pattern varies slightly. All require keeping secret keys on the server β€” never expose them to the client.

stripe uses a global configuration object.

// stripe
const Stripe = require('stripe');
const stripe = Stripe('sk_test_...');

braintree requires a gateway instance with merchant details.

// braintree
const braintree = require('braintree');
const gateway = new braintree.BraintreeGateway({
  environment: braintree.Environment.Sandbox,
  merchantId: '...',
  publicKey: '...',
  privateKey: '...'
});

paypal-rest-sdk uses a configuration object for OAuth.

// paypal-rest-sdk
const paypal = require('paypal-rest-sdk');
paypal.configure({
  mode: 'sandbox',
  client_id: '...',
  client_secret: '...'
});

razorpay initializes with key and secret.

// razorpay
const Razorpay = require('razorpay');
const instance = new Razorpay({
  key_id: 'rzp_test_...',
  key_secret: '...'
});

square uses an OAuth client or access token.

// square
const { Client } = require('square');
const client = new Client({
  accessToken: '...',
  environment: 'sandbox'
});

πŸ›’ Creating a Transaction Session

This is the most critical step for frontend architects. The server creates a session (Intent, Order, Token), and the ID is passed to the frontend to complete the payment.

stripe creates a Payment Intent.

// stripe
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000,
  currency: 'usd',
  payment_method_types: ['card']
});
// Send paymentIntent.client_secret to frontend

braintree generates a Client Token.

// braintree
const result = await gateway.clientToken.generate({});
// Send result.clientToken to frontend

paypal-rest-sdk creates a Payment object.

// paypal-rest-sdk
const create_payment_json = {
  intent: 'sale',
  payer: { payment_method: 'paypal' },
  transactions: [{ amount: { total: '20.00', currency: 'USD' } }]
};
payment.create(create_payment_json, function (error, payment) {
  // Send payment.id to frontend
});

razorpay creates an Order.

// razorpay
const order = await instance.orders.create({
  amount: 2000,
  currency: 'INR',
  receipt: 'receipt#1'
});
// Send order.id to frontend

square creates an Order.

// square
const { ordersApi } = client;
const order = await ordersApi.createOrder({
  idempotencyKey: 'unique-key',
  order: {
    lineItems: [{ name: 'Item', quantity: '1', basePriceMoney: { amount: 2000, currency: 'USD' } }]
  }
});
// Send order.id to frontend

πŸ–₯️ Frontend Handoff Pattern

Once the server creates the session, the frontend uses its own specific SDK (not these server packages) to complete the transaction. The data passed from server to client differs.

stripe passes client_secret to confirm the intent on the client.

// Frontend uses @stripe/stripe-js
stripe.confirmCardPayment(clientSecret, {
  payment_method: { card: cardElement }
});

braintree passes clientToken to initialize the drop-in UI.

// Frontend uses braintree-web
braintree.dropin.create({
  authorization: clientToken,
  container: '#dropin-container'
});

paypal-rest-sdk passes paymentID to execute the payment.

// Frontend uses paypal-js
actions.order.capture().then(function(details) {
  // Call backend to execute payment with paymentID
});

razorpay passes order_id to open the checkout modal.

// Frontend uses razorpay-js
var options = { key: 'rzp_test_...', amount: 2000, order_id: orderId };
var rzp = new Razorpay(options);
rzp.open();

square passes orderId to the payment form.

// Frontend uses @square/web-sdk
const card = await payments.card();
await card.attach('#card-container');
const result = await card.tokenize();
// Send result.token to backend to complete payment against orderId

⚠️ Deprecation & Maintenance Status

Maintenance status is a critical risk factor for long-term projects.

stripe, braintree, square, and razorpay are actively maintained.

// All four receive regular updates for security and new features
// Check npm page for latest version dates

paypal-rest-sdk is officially deprecated.

// paypal-rest-sdk
// WARNING: This package is no longer maintained.
// Migration path: Use @paypal/paypal-server-sdk or direct API calls

πŸ“Š Summary: Key Differences

Featurestripebraintreepaypal-rest-sdkrazorpaysquare
Session TypePayment IntentClient TokenPayment IDOrder IDOrder ID
Frontend SDK@stripe/stripe-jsbraintree-webpaypal-jsrazorpay-js@square/web-sdk
Region FocusGlobalGlobalGlobalIndia/AsiaUS/UK/CA
Statusβœ… Activeβœ… Active❌ Deprecatedβœ… Activeβœ… Active
ComplexityMediumMediumLow (Legacy)LowMedium

πŸ’‘ Final Recommendation

stripe is the safest default choice for most global applications due to its robust documentation and flexible Payment Intent flow. It balances security with developer experience effectively.

braintree is the strong alternative if you need deep PayPal integration alongside credit cards without managing two separate providers.

razorpay is the mandatory choice for businesses targeting Indian customers due to localized payment support.

square is best for omnichannel retailers who need to sync online payments with physical inventory and POS systems.

paypal-rest-sdk should be avoided in all new development. If you encounter it in an existing codebase, plan a migration to the newer PayPal server SDK or direct API integration to ensure security compliance.

How to Choose: braintree vs paypal-rest-sdk vs razorpay vs square vs stripe

  • braintree:

    Choose braintree if you need a PayPal-owned solution that supports a wide range of payment methods including credit cards, PayPal, and Venmo. It is ideal for projects requiring a hosted fields approach or complex vaulting features where the server generates a client token for the browser SDK.

  • paypal-rest-sdk:

    Do NOT choose paypal-rest-sdk for new projects as it is officially deprecated. Instead, evaluate the newer @paypal/paypal-server-sdk or direct REST API usage. Only consider this legacy package if maintaining an older system that cannot be refactored immediately.

  • razorpay:

    Choose razorpay if your primary market is India or South Asia, where it offers localized payment methods like UPI and Net Banking. It follows a simple Order-based flow that is easy to integrate with custom checkout forms and supports international cards.

  • square:

    Choose square if you operate in regions where Square is dominant (US, UK, Canada, etc.) and need tight integration with point-of-sale hardware or inventory systems. It is suitable for omnichannel businesses that require syncing online and in-person payment data.

  • stripe:

    Choose stripe if you need a global payment infrastructure with extensive documentation and a highly flexible frontend SDK. It is the best fit for startups and enterprises alike that require support for subscriptions, complex tax calculations, and a wide array of local payment methods.

README for braintree

Braintree Node library

The Braintree Node library provides integration access to the Braintree Gateway.

Please Note

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our technical documentation for more information.

Installation

  • npm install braintree
  • var braintree = require('braintree')

Dependencies

  • node >= 10

Versions

Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our developer docs.

Major version numberStatusReleasedDeprecatedUnsupported
3.x.xActiveSeptember 2020TBATBA
2.x.xInactiveFebruary 2017September 2022September 2023

Links

Updating from an Inactive, Deprecated, or Unsupported version of this SDK? Check our Migration Guide for tips.

Quick Start

var braintree = require("braintree");

var gateway = new braintree.BraintreeGateway({
  environment: braintree.Environment.Sandbox,
  merchantId: "your_merchant_id",
  publicKey: "your_public_key",
  privateKey: "your_private_key",
});

gateway.transaction.sale(
  {
    amount: "5.00",
    paymentMethodNonce: "nonce-from-the-client",
    options: {
      submitForSettlement: true,
    },
  },
  function (err, result) {
    if (err) {
      console.error(err);
      return;
    }

    if (result.success) {
      console.log("Transaction ID: " + result.transaction.id);
    } else {
      console.error(result.message);
    }
  }
);

Promises

You can also use Promises instead of callbacks.

var braintree = require("braintree");

var gateway = new braintree.BraintreeGateway({
  environment: braintree.Environment.Sandbox,
  merchantId: "your_merchant_id",
  publicKey: "your_public_key",
  privateKey: "your_private_key",
});

gateway.transaction
  .sale({
    amount: "5.00",
    paymentMethodNonce: "nonce-from-the-client",
    options: {
      submitForSettlement: true,
    },
  })
  .then(function (result) {
    if (result.success) {
      console.log("Transaction ID: " + result.transaction.id);
    } else {
      console.error(result.message);
    }
  })
  .catch(function (err) {
    console.error(err);
  });

Almost all methods that uses a callback can alternatively use a Promise. The only exceptions are gateway.merchantAccount.all or any of the search methods because they return a stream if no callback is provided.

Documentation

Developing (Docker)

The Makefile and Dockerfile will build an image containing the dependencies and drop you to a terminal where you can run tests.

make

Tests

The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake (rake test:unit) or npm (npm test).

License

See the LICENSE file.