0.2.8 • Published 5 months ago

bc-payments-sdk v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

BetterCommerce Payments NodeJS SDK

BetterCommerce's Payments NodeJS SDK is a complete solution for storefront clients that integrate payments. bc-payments-sdk is a single point interface for storefront clients for interacting with payment gateways.

Supported Payment Providers

It integrates SDK APIs for the following providers:

Payment GatewayImplementation Approach
PayPalClient-side Modal Widget
CheckoutClient-side Frame Widget
StripeClient-side Frame Widget
ClearPayClient-side Modal Widget + Redirect
KlarnaClient-side Modal Widget
ApplePayClient-side Modal Widget + Redirect
JuspayClient-side Custom Widget + Redirect
ElavonClient-side Modal Widget + Redirect

PayPal

NameReferenceDescription
API Collectionhttps://developer.paypal.com/api/rest/current-resources/Create and manage your site's payment functions using PayPal API collections.
API v2 SDKhttps://developer.paypal.com/docs/api/orders/v2/
NPM Packagehttps://github.com/better-commerce/bc-paypal-sdkNode.js SDK for interaction with PayPal APIs - @better-commerce/bc-paypal-sdk
Dashboard - Sandboxhttps://www.sandbox.paypal.com/signin?returnUri=https%3A%2F%2Fwww.sandbox.paypal.com%2Fmep%2F
Dashboard - Livehttps://www.paypal.com/signin?returnUri=%2Fshopping%2Fdashboard

Checkout

NameReferenceDescription
Widget Integrationhttps://www.checkout.com/docs/payments/accept-payments/accept-a-payment-on-your-website/frames-referenceIntegrate with Checkout.com's frames.
API SDKhttps://api-reference.checkout.com/#operation/getPaymentDetails
NPM Packagehttps://github.com/better-commerce/bc-checkout-sdkNode.js SDK for interaction with Checkout APIs - @better-commerce/bc-checkout-sdk
Dashboard - Sandboxhttps://dashboard.sandbox.checkout.com/
Dashboard - Livehttps://dashboard.checkout.com/

Stripe

NameReferenceDescription
Widget Integrationhttps://stripe.com/docs/payments/accept-a-paymentIntegrate with Stripe's various payment services.
API SDKhttps://stripe.com/docs/api
NPM Packagehttps://github.com/better-commerce/bc-stripe-sdkNode.js SDK for interaction with Stripe APIs - @better-commerce/bc-checkout-sdk
Dashboard - Sandboxhttps://dashboard.stripe.com/login
Dashboard - Livehttps://dashboard.stripe.com/login

ClearPay

NameReferenceDescription
Widget Integrationhttps://developers.clearpay.co.uk/clearpay-online/reference/standard-checkout#popup-method
API SDKhttps://developers.clearpay.co.uk/clearpay-online/reference/api-environments
NPM Packagehttps://github.com/better-commerce/bc-clearpay-sdkNode.js SDK for interaction with ClearPay APIs - @better-commerce/bc-clearpay-sdk
Dashboard - Sandboxhttps://portal.sandbox.clearpay.co.uk/uk/login-email
Dashboard - Livehttps://portal.clearpay.co.uk/uk/login-email

Klarna

NameReferenceDescription
Widget Integrationhttps://docs.klarna.com/klarna-payments/integrate-with-klarna-payments/
API SDKhttps://docs.klarna.com/api
NPM Packagehttps://github.com/better-commerce/bc-klarna-sdkNode.js SDK for interaction with Klarna APIs - @better-commerce/bc-klarna-sdk
Dashboard - Sandboxhttps://portal.playground.klarna.com/
Dashboard - Livehttps://portal.klarna.com/

Checkout ApplePay

NameReferenceDescription
Setting Up Your Serverhttps://developer.apple.com/documentation/apple_pay_on_the_web/setting_up_your_serverSet up your server for secure communications with Apple Pay.
Widget Integrationhttps://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api
API SDKhttps://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/requesting_an_apple_pay_payment_session
NPM Packagehttps://github.com/better-commerce/bc-apple-pay-sdkNode.js SDK for interaction with ApplePay - @better-commerce/bc-apple-pay-sdk
Sandbox Urlhttps://sandbox.apple-pay-gateway.apple.com/
Live Urlhttps://apple-pay-gateway.apple.com/
Setting Up Sandboxhttps://developer.apple.com/apple-pay/sandbox-testing/

Juspay

NameReferenceDescription
API Collectionhttps://docs.juspay.io/api-reference/docs/express-checkout/postman-collectionA Postman collection with the tools you’ll need to test the server-side component of your integration.
Express Checkout SDKhttps://docs.juspay.io/api-reference/docs/express-checkout/introduction
NPM Packagehttps://github.com/better-commerce/bc-juspay-sdkNode.js SDK for interaction with Juspay APIs - @better-commerce/bc-juspay-sdk
Dashboard - Sandboxhttps://sandbox.portal.juspay.in/
Dashboard - Livehttps://portal.juspay.in/

Elavon

NameReferenceDescription
API Collectionhttps://developer.elavon.com/products/checkout-js/v1/api-referenceAn API reference you’ll need to test the server-side component of your integration.
Checkout.js Transaction Requesthttps://developer.elavon.com/products/checkout-js/v1/api-reference#tag/Checkout.js-Transaction-Request
NPM Packagehttps://github.com/better-commerce/bc-elavon-sdkNode.js SDK for interaction with Elavon APIs - @better-commerce/bc-elavon-sdk
Dashboard - Sandboxhttps://reporting.sandbox.elavonpaymentgateway.com/#/login
Dashboard - Livehttps://reporting.elavonpaymentgateway.com/#/login

Installation

Use below command for package installation:

npm install @better-commerce/bc-payments-sdk

Architecture Diagram

Architecture Diagram

SDK Initialization

Use following snippet to initialize the SDK:

PayPal

const paypalConfig = {
    systemName: "Paypal",
    notificationUrl: "<Return_Url>",
    settings: [{
        "key": "AccountCode",
        "value": "<Client_Id>"
    },
    {
        "key": "Signature",
        "value": "<Secret_Key>"
    },
    {
        "key": "UseSandbox",
        "value": "True"
    },
    {
        "key": "CancelUrl",
        "value": "<Cancel_Url>"
    }]
};

Checkout

const checkoutConfig = {
    systemName: "Checkout",
    notificationUrl: "<Return_Url>",
    settings: [{
        "key": "AccountCode",
        "value": "<Public_Key>"
    },
    {
        "key": "Signature",
        "value": "<Secret_Key>"
    },
    {
        "key": "MotoAccountCode",
        "value": "<Client_Id>"
    },
    {
        "key": "MotoSignature",
        "value": "<Access_Secret>"
    },
    {
        "key": "MotoUserName",
        "value": "<Processing_Channel_Id>"
    },
    {
        "key": "UseSandbox",
        "value": "True"
    },
    {
        "key": "CancelUrl",
        "value": "<Cancel_Url>"
    }]
};

Stripe

const stripeConfig = {
    systemName: "Stripe",
    notificationUrl: "<Return_Url>",
    settings: [{
        "key": "AccountCode",
        "value": "<Public_Key>"
    },
    {
        "key": "Signature",
        "value": "<Secret_Key>"
    },
    {
        "key": "UseSandbox",
        "value": "True"
    },
    {
        "key": "CancelUrl",
        "value": "<Cancel_Url>"
    }]
};

Klarna

const klarnaConfig = {
    systemName: "Klarna",
    notificationUrl: "<Return_Url>",
    settings: [{
        "key": "AccountCode",
        "value": "<API_User_Id>"
    },
    {
        "key": "Signature",
        "value": "<API_Password>"
    },
    {
        "key": "UseSandbox",
        "value": "True"
    },
    {
        "key": "CancelUrl",
        "value": "<Cancel_Url>"
    }]
};

ApplePay

const applePayConfig = {
    systemName: "CheckoutApplePay",
    notificationUrl: "<Return_Url>",
    settings: [{
        key: "AccountCode",
        value: "merchant.com.commerce.ffx"
    }, {
        "key": "Signature",
        "value": "<Secret_Key>"
    }, {
        "key": "UseSandbox",
        "value": "True"
    }, {
        key: "CancelUrl",
        value: "/payment-notification/checkoutapplepay/canceled"
    }]
};

Initialization

BCEnvironment.init(paypalConfig || checkoutConfig || stripeConfig || klarnaConfig);
BCEnvironment.withCredentials("<bc_client_id>", "<bc_shared_secret>", [useSandbox: boolean]);

Usage Example

Get PayPal Order Details

const result = await new PaymentOperation().getOrderDetails("<order_id>");