GithubHelp home page GithubHelp logo

paypal-sdk-client's Introduction

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:

  • Determining the current paypal url
  • Getting the merchant's client-id
  • Running experiments.
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

  • You're building a component that is rendered into an iframe or popup window.
  • Your component uses zoid to construct the component, and to communicate between the component and the parent page and vice-versa.
  • You want to make sure the version of the component between the parent and child, to prevent any incompatibilities in the messaging protocol zoid defines (trust me on this one)
  • You also want to take advantage of browser caching benefits, and not download dependencies like zoid multiple times in each new frame or window being rendered
  • You can't just load <script src="https://www.paypal.com/sdk/js?client-id=CLIENT_ID"></script> in the child frame or popup, because different query params could have been passed on the top level page, and to take advantage of any caching benefits you need to match the url exactly as it appeared in the parent.
  • You also probably want to avoid passing down all of the query params from /sdk/js, but that's a lot to keep track of, and you would need to update your code every time a new parameter is added.
  • Or, you could pass the entire https://www.paypal.com/sdk/js?client-id=xyz&... url down from the parent to each new child; meaning we'll get an exact match each time, with exact the same version of the code, and any new url params will automatically be included without any more integration work.
  • And of course, if we're doing that, we need to validate the url before we throw it into a script tag, to prevent xss or injection attacks

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:

  • The script tag should not introduce any extra latency. It has already been downloaded, pre-cached, and pre-parsed in the parent window. So it is usually safe to put in the <head> tag.
  • Assuming a zoid component integration, window.xprops, containing the props used to receive data from the parent and used to send callbacks back to the parent window, will only be available after the script tag has completed loading on the client. If any other scripts require window.xprops immediately, please ensure the sdk script tag is placed before those scripts.
  • unpackSDKMeta will throw an error if req.query.sdkMeta does not validate. This should be handled and translated into a 500 server error, indicating that the payload has been tampered with.
  • unpackSDKMeta may be passed undefined if req.query.sdkMeta is not present. This is necessary for some legacy integrations where the sdk metadata is passed via window.name entirely on the client-side.

Quick Start

Installing

npm install --save @paypal/sdk-client

Getting Started

  • Fork the module
  • Run setup: npm run setup
  • Start editing code in ./src and writing tests in ./tests
  • npm run build

Building

npm run build

Tests

  • Edit tests in ./test/tests

  • Run the tests:

    npm test

paypal-sdk-client's People

Contributors

amyegan avatar asquiroga avatar bluepnume avatar borodovisin avatar bywood avatar cgdibble avatar crookedneighbor avatar davixyz avatar dtjones404 avatar elizabethmv avatar gabrielo91 avatar gregjopa avatar jianyigao avatar jshawl avatar mnicpt avatar mstuart avatar nbierdeman avatar nikrom17 avatar quinnjn avatar ravishekhar avatar renovate[bot] avatar seavenly avatar siddy2181 avatar sioked avatar spencersablan avatar vishakha94 avatar weihou avatar westeezy avatar wsbrunson avatar xuanwan05 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-sdk-client's Issues

Flow syntax error

In the flow type definitions, this seems to be a syntax error:

https://github.com/paypal/paypal-braintree-web-client/blob/3c7b64f560bd5b58d55235c5b66eb91ce3d3027d/dist/module/index.js.flow#L49

at least the flow command says so:

49:   toPromise(): Class<Promise<R>> | Class<Promise> | Promise<+R>;
                                                                ^ Unexpected token +

and flow.org/try:

https://flow.org/try/#0PTAEAEDMBsHsHcBQiAmBTAxtAhgJzaFtgM7GgDCOpAjKAN6KijEAu2LAlhqACQbbRoACgC2aUtgDmaAPwAuZi1wcAdpICUCyiWLUA3I0XsuhbAAcWAV3wBlNhgDWAFVzYMaIW1zSWCgPIARgBWmCwANISwKqy4lhgssLjyoABilirxHFGaoABusBwoBkysxtxm+GZ4aHZuzq7uCkJouLhaVLoRpY4KAIKt2ACeADzkAtA2HCxoAHzqoAC8M6AiHAAeaEWGpZzc3fVuaAAyHKu+oCqWIgEtBoYYsNBXKgByVzdJCpfXt4boxBhlBYsipkjFVJJiqBIBxoGgXtgxGClBCodBVPD3i1kt8PlCxBJpApwWooSpEWhiSjSYZcdivljcFD9lTlDSmA9oko4glcKJxMQpLIFKsNigcvlClCEnY2ZIhDkSZDEABfVCYHD4QgdCgdAAM9G2bF2oHGwwAGgoANqizagYAAKlAAFUXgBRc0ABTd5CcboAIqAnABNb0KN1rDisYhOUAO4AAXVAAB9QDb1nbHS73V6fX7AyGw6AI1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kHREInTm5qaAHquVq0b2zY5U2trAO-WgFO14fQA8OkDPM0iZDTH+GYSpDgGoMz15PNMWOz8AGT9YRT8jC0IMK4ZwFEDGMQ-T9tOiioM4dgoYUqMbGfREVEREG-QIAPDnAyyker6AJz5IFEQR8R+HCwDE6Edg+TwkTYGI-SnALO7zNL3QAAI4owpHi8ghPsPAiBy8K+rwezK-hGRErdqAa9U9a9EwM-JGDD6+G-G8mwPNm8W-UjRHdfrc2PL1cNpUYxmIn2Tc2OQDpCZBRCmjxNuCgy5f71wgIhiD6-n3GqWCwjoBpxCDWw5zojOGe+S9Ey+FmwBGkxREhGp9gdq+h9p9FykNKgUOzgqgSglzjdKO0NF8ZAS8qCgA+A2BJNRA+boxKiL89cbeKFwCSDSCIfysoCwLywt+N-N8VJt9WxEyD-j-D9yhz-LJT+p-6EyChHpKFARAX9+UpsbALf2gAt9H+9idvs-2n7G9J+0Ar-kEl-7LJYkpoFACgE9BDA4A8rUAeAMgEQDP+5DWAR-3gGEDQAP-Efn-xQAAC0BLgOoBCBwH39rYD-egCQIphEC7YBAtgWQKQF2wUB6Abxkb3sSBt9eEjLASgAH7WwYB3AigcgJLhPI7EQgYQeP286DAxBEgofogJkG8C5BgMBGMDELiHIvoUMdTiIDEA5J-WKQIGPoMqSGD2Yxg0AKoGS5NAlBSoFQWoKf6SCEB0gt-pQIi4sBaB0QQhhAOYF0BpK8rFoE+1YHBEE+oADtlEH8DBBQgJsPpvrxNbsDlgRyKGL4JsINAzO9iUQXKyPZRDJA3-Hgakn-6lc8AKgZwRSBEGYDCh6gl-poJ8GyDCgEhIAA

PayPal CloudQuery Plugin?

Hi Team, hopefully this is right place to ask, if not, I'd appreciate if you can direct me.

I'm the founder of cloudquery.io, a high performance open source ELT framework.

Our users are interested in a PayPal plugin, but as we cannot maintain all the plugins ourselves, I was curious if this would be an interesting collaboration, where we would help implement an initial source plugin, and you will help maintain it.

This will give your users the ability to sync PayPal data to any of their datalakes/data-warehouses/databases easily using any of the growing list of CQ destination plugins.

Best,
Yevgeny

Smart Button onError callback not firing

Greetings!

We're tightening up our integration by making sure we've got error handling locked down. I'm having trouble getting the onError callback on the paypal.Buttons(config) to work properly. Here's the thing, though, it's working just fine in this codepen I threw together: https://codepen.io/JasonTheAdams/pen/gOrKyoG

Clearly we're doing something different. Here's what we've got in the application:

		paypal.Buttons( {
			onInit: onInitHandler,
			onClick: onClickHandler,
			createOrder: createOrderHandler,
			onApprove: onApproveHandler,
			onError: function( error ) {
				console.log( 'In this function' );
				console.log( error );
			},
			style: {
				layout: 'vertical',
				size: 'responsive',
				shape: 'rect',
				label: 'paypal',
				color: 'gold',
				tagline: false,
			},
		} ).render( this.smartButtonContainer );

As you can see, I've just got a closure for onError, however "In this function" never shows up in the console. Here's our createOrderHandler method which throws the error:

	async createOrderHandler( data, actions ) {
		Give.form.fn.removeErrors( this.jQueryForm );

		const response = await fetch( `${ Give.fn.getGlobalVar( 'ajaxurl' ) }?action=give_paypal_commerce_create_order`, {
			method: 'POST',
			body: DonationForm.getFormDataWithoutGiveActionField( this.form ),
		} );

		const responseJson = await response.json();

		if ( ! responseJson.success ) {
			if ( null === responseJson.data.error ) {
				throw {};
			}

			throw responseJson.data.error;
		}

		return responseJson.data.id;
	}

It is throwing the error, and I see the following show up in the console:
image

Any ideas as to why the onError callback may not be getting fired?

Invalid authorization code

we just noticed that, when use paypal authentication. it will return authorization code. But to some specifc user, when we use this authorization code to exchange token, it always report 400, and the payload would like:
{"error_description":"Invalid authorization code","error":"access_denied","correlation_id":"2ac9f7fa4e099","information_link":"https://developer.paypal.com/docs/api/#errors"}

How to detect closed onboarding window?

Greetings!

We're using the following for embedding the sign up link: https://developer.paypal.com/docs/platforms/seller-onboarding/build-onboarding/#step-2-embed-the-paypal-sign-up-link

As we're testing, we're finding that some folks are starting the process and closing (maybe they meant to change countries), or they're actually finishing the onboarding process but then closing the window instead of clicking "Go back to John's Store website".

When the user first clicks on the link, the SDK puts a dark overlay on the screen while the onboarding process goes on. If the user closes the window, the overly is simply removed. We can't seem to find a way to know if the user simply canceled the process — or if they did finish but didn't click the 'Go Back' button. There's checking the response.ok, but this seems to only cover errors, which these two scenarios don't appear to qualify as.

Any direction you're able to give for this? Thank you!

QUESTION: Where am I supposed to ask about webhook?

Hi, sorry for the random question.
I realized that the webhook is not working since some hours ago.
Not sure where to ask about this though.
I checked the API status page and it says Sandbox system is working correctly.
Please let me know if this is something I can expect to be back to normal soon.

Allow to destroy existing hosted card field

As per requirement, we re-render smart buttons and hosted card fields when currency changes because PayPal SDK only processes currency which we pass in query param. The smart button can be destroyed by calling the close function but I did not find a similar function for hosted card fields.

GitHub Discussion: #44 (comment)

Can you suggest the best way to re-render the hosted card field without reloading the whole page?

Specify orders versus subscription when displaying Smart Buttons

I wanted to expand on #44 (comment) — I believe that issue is resolved, but we have another need I want to clearly spell out.

Our product, GiveWP, provides our customers with the ability to create a donation form on their website. The form can be displayed either as the page is loaded, or in a modal once a button is clicked, or some other way. This creates the common scenario where a page will have more than one donation form displayed at a time.

Right now, the SDK seems to be built around as a global, wherein the SDK applies to the whole document. This is especially evident as the intent=order or intent=subscription is defined as a parameter of the script. In #44 we were given the ability to change between orders and subscriptions by reloading the script, but this isn't a perfect solution in the context of multiple forms potentially being in separate states (i.e. one in single donations, the other in recurring).

As @ravinderk found, we're able to process Orders and Subscriptions by setting vault=true and intent=order, however we get a warning when the Subscription is processed. Is this something stable we can continue to do? Or will it likely break at some point?

In our perfect world, we wouldn't need to globally set whether we intend to process orders or subscriptions, but handle it on a per Smart Buttons and per Hosted Fields basis. Does this make sense?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v3
  • actions/setup-node v3
  • bahmutov/npm-install v1
  • codecov/codecov-action v3
  • codecov/codecov-action v3
.github/workflows/publish.yml
  • actions/checkout v3
  • actions/setup-node v3
  • bahmutov/npm-install v1
npm
package.json
  • @krakenjs/beaver-logger ^5.0.0
  • @krakenjs/belter ^2.0.0
  • @krakenjs/cross-domain-utils ^3.0.2
  • @krakenjs/jsx-pragmatic ^3.0.0
  • @krakenjs/zalgo-promise ^2.0.0
  • @paypal/sdk-constants ^1.0.94
  • bowser ^2.0.0
  • @krakenjs/grumbler-scripts ^8.0.4
  • @krakenjs/sync-browser-mocks ^3.0.0
  • babel-core 7.0.0-bridge.0
  • cheerio 1.0.0-rc.9
  • cross-env ^7.0.3
  • esdoc 1.1.0
  • esdoc-flow-type-plugin 1.1.0
  • esdoc-standard-plugin 1.0.0
  • flow-bin 0.155.0
  • flow-typed ^3.8.0
  • husky ^8.0.1
  • jest ^29.3.1
  • lint-staged ^13.0.3
  • mocha ^10.0.0
  • prettier 2.8.8
nvm
.nvmrc
  • node 18

  • Check this box to trigger a request for Renovate to run again on this repository

Allow for switching between Orders and Subscriptions

Greetings!

I work with givewp.com and we've been working with an integration manager at PayPal since June to provide integration for PayPal Commerce.

We've recently run into a problem with this SDK wherein the vault=true parameter must be set at the time that the SDK script is loaded. This means that the SDK is locked into either creating Orders or Subscriptions once it's loaded.

This is a problem for us as our product provides organizations with a donation form to put on their website. During realtime, the donor may decide whether they're making a one-time or recurring donation. In fact, the donor could even start willing out CC details, then decide they want to make it recurring, tick a box, and continue. You can see a couple demos:

Is there currently a way of switching between Orders and Subscriptions at runtime? If not, we need that for compatibility of integration.

Thank you!

web-client repository infrastructure

There is a card to take care of a couple of tasks in this repo and I feel like we need input from other folks that will be touching this code before I sign off on this card.

Reviewers (Feel free to add folks to this for review):

These are the tasks that this repo needs to setup for infrastructure:

  • Build
  • Lint
  • Test
  • src dir structure
  • test dir structure
  • Docs
  • Assets are in a deployable state

I'm going to summarize it currently in point form. Please comment on this issue with questions, or just 👍 if you're happy!

Build

  • Babel transpiling
  • Builds to webpack
  • Uses flow

Lint

Test

src dir structure

  • Currently just js scripts in src/
  • I could see the structure being:
    • src/component/Client/index.js
    • src/component/Client/shared-config.js
    • src/component/HostedFields/index.js
    • src/lib/polyfill-assign.js

test dir structure

  • Currently a karma test skeleton
  • I could see the structure being:
    • test/unit/Client/index.js
    • test/integration/Client/index.js

Docs

  • ESDocs
    • Removes flow flavored code
    • Generates HTML that we can host on ESDocs or though GitHub pages

Assets are in a deployable state

  • Git holds on to dist/
  • Built assets are assigned a tag in git

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.