npm install @paypal/sdk-client

Shared config between PayPal/Braintree.

More from paypal

paypal npm packages

Find the best node modules for your project.

Search npm

@paypal/paypal-js

Loading wrapper and TypeScript types for the PayPal JS...

Read more
,

@paypal/sdk-constants

Utilities...

Read more
,

@paypal/react-paypal-js

React components for the PayPal JS...

Read more
,

@paypal/installments

PayPal...

Read more
,

@paypal/paypalhttp

A library for integrating with PayPalHttp...

Read more
,

@paypal/checkout-server-sdk

NodeJS SDK for PayPal Checkout...

Read more
,

paypal-checkout

PayPal Checkout components, for integrating checkout products...

Read more
,

@paypal/payouts-sdk

NodeJS SDK for PayPal Payouts...

Read more
,

@paypal/sdk-client

Shared config between PayPal/Braintree...

Read more
,

@paypal/checkout-components

PayPal Checkout components, for integrating checkout products...

Read more
,

@paypal/sdk-logos

JSX/SVG logos for PayPal...

Read more
,

paypal-server-api

Powerful assistive library for interacting with the PayPal API...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

@krakenjs/beaver-logger, @krakenjs/belter, @krakenjs/cross-domain-utils, @krakenjs/jsx-pragmatic, @krakenjs/zalgo-promise, @paypal/sdk-constants, bowser, @bunchtogether/vite-plugin-flow, @krakenjs/babel-config-grumbler, @krakenjs/eslint-config-grumbler, @krakenjs/grumbler-scripts, babel-core, cheerio, cross-env, esdoc, esdoc-flow-type-plugin, esdoc-standard-plugin, flow-bin, flow-typed, husky, jsdom, jsonwebtoken, lint-staged, prettier, @vitest/coverage-v8, @vitest/ui, vite, vitest

Documentation

A README file for the @paypal/sdk-client code repository. View Code

PayPal SDK Client

build status code coverage npm version apache license

A shared client for PayPal/Braintree client sdk modules. Has both client-side and server-side bindings to help you build and integrate an sdk component.

Client

Your client-side sdk component can take advantage of any common utilities or functionality exposed by this module. For example:

import { getClientID } from "@paypal/sdk-client/src";

fetch("https://api.paypal.com/v1/foo", {
    headers: {
        "client-id": getClientID(),
    },
});

Server

This module helps you load the payments sdk in a child window, matching the url from the parent.

Rationale

This module helps with that.

On your server

  1. Import unpackSDKMeta:
import { unpackSDKMeta } from "@paypal/sdk-client";
  1. Call unpackSDKMeta with req.query.sdkMeta, passed from the client in the query string, and pass the script tag in the page render.
// Listen for requests to your app
app.get("/my-app", (req, res) => {
    // Unpack the sdk meta payload from the client
    const { getSDKLoader } = unpackSDKMeta(req.query.sdkMeta);

    // Call getSDKLoader to build a script tag, passing in csp nonce, if applicable
    const sdkScriptTag = getSDKLoader({ nonce });

    // Insert script tag into response
    res.send(`
        <body>
            <h1>My App</h1>
            ${sdkScriptTag}
        </body>
    `);
});
  1. Ensure the sdkMeta payload is passed to the child window from the parent. If you are using zoid to construct your component, please add the following:
import { getSdkMeta } from "@paypal/sdk-client/src";

let MyComponent = zoid.create({
    tag: "my-component",
    url: "https://www.paypal.com/my-component",
    props: {
        sdkMeta: {
            type: "string",
            value: getSdkMeta,
            queryParam: true,
        },
    },
});

If you are not using zoid, please use getSdkMeta() to construct the sdkMeta payload, and pass it to your child-window or frame in a different way.

Notes:

Quick Start

Installing

npm install --save @paypal/sdk-client

Getting Started

Building

npm run build

Tests