Skip to content

Commit 6ec08d2

Browse files
Teach clientId for V6 SDK Instance Creation in READMEs (#846)
* update v6 paypal-js readme and react-paypal-js readme to prefer client ID to client token * chore: add changeset * Update packages/react-paypal-js/README.md Co-authored-by: Drew Liu <98370449+HackTheW2d@users.noreply.github.com> --------- Co-authored-by: Drew Liu <98370449+HackTheW2d@users.noreply.github.com>
1 parent f717d37 commit 6ec08d2

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

.changeset/tired-ghosts-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@paypal/react-paypal-js": patch
3+
---
4+
5+
Fix react-paypal-js readme to prefer Client ID for SDK instance creation.

.changeset/twenty-hornets-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@paypal/paypal-js": patch
3+
---
4+
5+
Update paypal-js V6 section to prefer Client ID to Client Token for SDK instance creation.

packages/paypal-js/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ After loading, create an instance with `createInstance()`:
324324

325325
```ts
326326
const sdkInstance = await paypal.createInstance({
327-
clientToken: "YOUR_CLIENT_TOKEN",
327+
clientId: "YOUR_CLIENT_ID",
328328
components: ["paypal-payments", "venmo-payments"],
329329
locale: "en-US",
330330
pageType: "checkout",
@@ -376,7 +376,7 @@ async function initPayPal() {
376376
}
377377

378378
const sdkInstance = await paypal.createInstance({
379-
clientToken: "YOUR_CLIENT_TOKEN",
379+
clientId: "YOUR_CLIENT_ID",
380380
components: ["paypal-payments"],
381381
});
382382

packages/react-paypal-js/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import {
7575
function App() {
7676
return (
7777
<PayPalProvider
78-
clientToken="your-client-token"
78+
clientId="your-client-id"
7979
components={["paypal-payments"]}
8080
pageType="checkout"
8181
>
@@ -158,7 +158,7 @@ function App() {
158158
}
159159
```
160160

161-
### With Promise-based Token
161+
Alternative: With Promise-based Token
162162

163163
```tsx
164164
function App() {
@@ -177,19 +177,19 @@ function App() {
177177
}
178178
```
179179

180-
### Deferred Loading (works for either Client token or ID)
180+
### Deferred Loading
181181

182182
```tsx
183183
function App() {
184-
const [clientToken, setClientToken] = useState<string>();
184+
const [clientId, setClientId] = useState<string>();
185185

186186
useEffect(() => {
187-
fetchClientToken().then(setClientToken);
187+
fetchClientId().then(setClientId);
188188
}, []);
189189

190190
return (
191191
<PayPalProvider
192-
clientToken={clientToken}
192+
clientId={clientId}
193193
components={["paypal-payments"]}
194194
pageType="checkout"
195195
>
@@ -277,7 +277,7 @@ Renders a Venmo button for one-time payments. Requires `"venmo-payments"` in the
277277
import { VenmoOneTimePaymentButton } from "@paypal/react-paypal-js/sdk-v6";
278278

279279
<PayPalProvider
280-
clientToken={token}
280+
clientId={clientId}
281281
components={["paypal-payments", "venmo-payments"]}
282282
pageType="checkout"
283283
>
@@ -335,7 +335,7 @@ Renders a guest checkout button for card payments without a PayPal account (Bran
335335
import { PayPalGuestPaymentButton } from "@paypal/react-paypal-js/sdk-v6";
336336

337337
<PayPalProvider
338-
clientToken={token}
338+
clientId={clientId}
339339
components={["paypal-payments", "paypal-guest-payments"]}
340340
pageType="checkout"
341341
>
@@ -396,7 +396,7 @@ Renders a PayPal button for subscription payments. Requires `"paypal-subscriptio
396396
import { PayPalSubscriptionButton } from "@paypal/react-paypal-js/sdk-v6";
397397

398398
<PayPalProvider
399-
clientToken={token}
399+
clientId={clientId}
400400
components={["paypal-subscriptions"]}
401401
pageType="checkout"
402402
>
@@ -847,7 +847,7 @@ export default async function CheckoutPage() {
847847

848848
return (
849849
<PayPalProvider
850-
clientToken={clientToken}
850+
clientId={clientId}
851851
pageType="checkout"
852852
eligibleMethodsResponse={eligibleMethodsResponse}
853853
>
@@ -898,7 +898,7 @@ import {
898898
PayPalOneTimePaymentButton,
899899
} from "@paypal/react-paypal-js/sdk-v6";
900900

901-
<PayPalProvider clientToken={token} pageType="checkout">
901+
<PayPalProvider clientId={clientId} pageType="checkout">
902902
<PayPalOneTimePaymentButton
903903
createOrder={async () => {
904904
const res = await fetch("/api/orders", { method: "POST" });

0 commit comments

Comments
 (0)