Messtone LLC Manages(SDK):

PayPal The JavaScript SDK display payment Method as: <script src=”https://www.paypal.com/sdk/js?client-id=MESSTONE_CLIENT_ID”></script&gt; defer object in the JavaScript SDK script: <script defer src=”https://www.paypal.com/sdk/js?client-id=MESSTONE_CLIENT_ID”></script&gt; Component implementation: import React from “react”;import ReactDOM from “react-dom”const PayPalButton=PayPal.Buttons.driver(“react”,{React,ReactDOM});class MesstoneComponent extends React.Component{createOrder(data){//Order is created on the server and the order id is returned return fetch(“/my-server/create-paypal-order”,{method:”POST”,headers:{“Content-Type”: “application/json”,},//use the “body”param to optionally pass additional order information //like product skus and quantities body: JSON.stringify({cart:[{sku:”MESSTONE_PRODUCT_STOCK_KEEPING_UNIT”,quantity: “MESSTONE_PRODUCT_QUANTITY”,},],}),}).then((response)=>response.json( )).then((order)=>order.id);}onApprove(data){//Order is captured on the server return fetch(“/my-server/capture-paypal-order”,{method:”POST”,headers:{“Content-Type”:”application/json”,},body: JSON.stringify({orderID: data.orderID})}).then((response)=>response.json( ));}render( ){return(<PayPalButton createOrder={(data,actions)=>this.createOrder(data)}onApprove={(data,actions)=>this.onApprove(data)}/>);}}

Leave a comment