PayPal JS SDK v6 — Developer Showcase
All major SDK components in one page. Click a card or use the nav to explore each payment method and scenario.
PayPal Button
Standard checkout, Pay Now, Continue, BOPIS, and onShippingChange scenarios.
Venmo Button
Renders on eligible devices using FUNDING.VENMO funding source.
Pay Later Button
Dedicated Pay Later checkout via FUNDING.PAYLATER.
<script src="https://www.paypal.com/sdk/js ?client-id=AVJ64pXVas3BtB-YrVVMFfCAZx2r2RlEjn0TwRtpGGNxqhhR-DRILDWX8gONSh-jSgunDQucOrVplXtm &components=buttons,messages &enable-funding=venmo,paylater ¤cy=USD" ></script>
PayPal Button
Four scenarios: Standard + onShippingChange, Pay Now (user_action: PAY_NOW), Continue (user_action: CONTINUE), and BOPIS (in-store pickup, no shipping). Select a scenario below.
Live Preview
Configuration
// ── PayPal Button · Standard + onShippingChange ─ paypal.Buttons({ fundingSource: paypal.FUNDING.PAYPAL, style: { layout: 'vertical', color: 'gold', shape: 'rect', label: 'paypal', height: 45, }, createOrder(data, actions) { return actions.order.create({ purchase_units: [{ amount: { currency_code: 'USD', value: '99.99', breakdown: { item_total: { currency_code: 'USD', value: '89.99' }, shipping: { currency_code: 'USD', value: '10.00' }, }, }, }], application_context: { shipping_preference: 'GET_FROM_FILE', user_action: 'PAY_NOW', }, }); }, // ─ Fires when buyer changes address or shipping option onShippingChange(data, actions) { // Reject non-US addresses if (data.shipping_address.country_code !== 'US') { return actions.reject(); } // Determine shipping cost from selected option const shippingCost = data.selected_shipping_option ? parseFloat(data.selected_shipping_option.amount.value) : 10.00; // Patch the order total in real-time return actions.order.patch([{ op: 'replace', path: "/purchase_units/@reference_id=='default'/amount", value: { currency_code: 'USD', value: (89.99 + shippingCost).toFixed(2), breakdown: { item_total: { currency_code: 'USD', value: '89.99' }, shipping: { currency_code: 'USD', value: shippingCost.toFixed(2) }, }, }, }]); }, onApprove(data, actions) { return actions.order.capture().then(details => { alert(`Captured! Payer: ${details.payer.name.given_name}`); }); }, onCancel: () => console.log('Cancelled'), onError: (err) => console.error(err), }).render('#paypal-button-container');
Venmo Button
Renders the Venmo funding source button using paypal.FUNDING.VENMO. The button only renders on eligible devices — desktop browsers may show the fallback message.
Live Preview
Configuration
// ── Venmo Button (JS SDK v6) ─────────────────── // // SDK script must include: &enable-funding=venmo // const venmoBtn = paypal.Buttons({ fundingSource: paypal.FUNDING.VENMO, style: { color: 'blue', // Venmo brand blue shape: 'rect', label: 'pay', height: 45, }, createOrder(data, actions) { return actions.order.create({ purchase_units: [{ amount: { currency_code: 'USD', value: '99.99' }, }], application_context: { user_action: 'PAY_NOW' }, }); }, onApprove(data, actions) { return actions.order.capture().then(details => { alert('Venmo payment complete!'); }); }, onCancel: () => console.log('Cancelled'), onError: (err) => console.error(err), }); // Always check eligibility before rendering if (venmoBtn.isEligible()) { venmoBtn.render('#venmo-button-container'); } else { console.log('Venmo not eligible on this device'); }
Pay Later Button
Dedicated Pay Later checkout using paypal.FUNDING.PAYLATER. Lets buyers split purchases into installments — no extra cost to the merchant.
Live Preview
Configuration
// ── Pay Later Button (JS SDK v6) ─────────────── // // SDK script must include: &enable-funding=paylater // paypal.Buttons({ fundingSource: paypal.FUNDING.PAYLATER, style: { color: 'white', // 'gold' | 'blue' | 'silver' | 'white' | 'black' shape: 'pill', label: 'pay', height: 45, }, createOrder(data, actions) { return actions.order.create({ purchase_units: [{ amount: { currency_code: 'USD', value: '99.99', }, description: 'Pay Later Demo', }], application_context: { user_action: 'PAY_NOW', }, }); }, onApprove(data, actions) { return actions.order.capture().then(details => { alert(`Pay Later captured!\nOrder: ${details.id}`); }); }, onCancel: () => console.log('Cancelled'), onError: (err) => console.error(err), }).render('#paylater-button-container');
Pay Later Message
The paypal.Messages() component renders inline Pay Later messaging. In sandbox, buyerCountry simulates the buyer's locale and activates the correct Pay Later product. Select a country, then adjust the amount slider.
buyerCountry param)
Product Page
product · logo: inlineCart Page
cart · logo: primaryPayment Page
payment · logo: alternativeHome Page
home · logo: inline// ── Pay Later Message (JS SDK v6) ───────────── // SDK tag requires: &components=messages // // buyerCountry is a SANDBOX-ONLY param that simulates // the buyer's locale. In production, PayPal detects // the buyer's country automatically — do NOT send it. // Product page paypal.Messages({ amount: 150.00, placement: 'product', buyerCountry: 'US', // sandbox only style: { layout: 'text', logo: { type: 'inline' } }, }).render('#msg-product'); // Cart page paypal.Messages({ amount: 150.00, placement: 'cart', buyerCountry: 'US', style: { layout: 'text', logo: { type: 'primary' } }, }).render('#msg-cart'); // Payment page paypal.Messages({ amount: 150.00, placement: 'payment', buyerCountry: 'US', style: { layout: 'text', logo: { type: 'alternative' } }, }).render('#msg-payment'); // Home page paypal.Messages({ amount: 150.00, placement: 'home', buyerCountry: 'US', style: { layout: 'text', logo: { type: 'inline' } }, }).render('#msg-home');