3 _out.push('<!DOCTYPE html>')
6 meta(charset="utf-8") {}
7 meta(http-equiv="x-ua-compatible" content="ie=edge") {}
8 meta(name="viewport" content="width=device-width,initial-scale=1") {}
9 link(href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous") {}
10 script(src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous") {}
12 'Checkout With PayPal NodeJs Demo'
17 background: -moz-linear-gradient(0deg,#004094 0,#0096d9 50%,#004094 100%);
18 background: -webkit-gradient(linear,left top,right top,color-stop(0,#004094),color-stop(50%,#0096d9),color-stop(100%,#004094));
19 background: -webkit-linear-gradient(0deg,#004094 0,#0096d9 50%,#004094 100%);
20 background: -o-linear-gradient(0deg,#004094 0,#0096d9 50%,#004094 100%);
21 background: -ms-linear-gradient(0deg,#004094 0,#0096d9 50%,#004094 100%);
22 background: linear-gradient(90deg,#004094 0,#0096d9 50%,#004094 100%)
28 div.row.header-bg-color.'mb-5'.p-3 {
30 'Checkout with PayPal Demo'
33 'Using Orders v2 REST API with PayPal JavaScript SDK'
36 'Server-side Integration'
42 img.card-img-top.img-responsive(src="https://www.paypalobjects.com/web/res/b0b/e9fea36098a7a8192723a8d3b86b2/img/platform/common/merchantStore/cart/camera-lg.jpg") {}
45 'Sample Sandbox Buyer Credentials'
47 table.table.table-striped {
77 'jack_potter@buyer.com'
101 'bella_brown@buyer.com'
118 _out.push('<!-- Cart Details -->')
120 input(name="return_url" type="hidden" value="http://localhost/pages/success.html") {}
122 input(name="cancel_url" type="hidden" value="http://localhost/pages/success.html") {}
124 label.'col-sm-5'.control-label(for="camera_amount") {
128 input.form-control#camera_amount(type="text" name="item_amt" value="300" readonly="") {}
132 label.'col-sm-5'.control-label(for="tax_amt") {
136 input.form-control#tax_amt(type="text" name="tax_amt" value="5" readonly="") {}
140 label.'col-sm-5'.control-label(for="insurance_fee") {
144 input.form-control#insurance_fee(type="text" name="insurance_fee" value="10" readonly="") {}
148 label.'col-sm-5'.control-label(for="handling_fee") {
152 input.form-control#handling_fee(type="text" name="handling_fee" value="5" readonly="") {}
156 label.'col-sm-5'.control-label(for="shipping_amt") {
160 input.form-control#shipping_amt(type="text" name="shipping_amt" value="2" readonly="") {}
164 label.'col-sm-5'.control-label(for="shipping_discount") {
168 input.form-control#shipping_discount(type="text" name="shipping_discount" value="2" readonly="") {}
172 label.'col-sm-5'.control-label(for="total_amt") {
176 input.form-control#total_amt(type="text" name="total_amt" value="320" readonly="") {}
180 label.'col-sm-5'.control-label(for="currency_Code") {
184 input.form-control#currency_Code(type="text" name="currency" value="USD" readonly="") {}
188 _out.push('<!-- Checkout Options -->')
190 div.'col-sm-offset-5'.col-sm {
191 _out.push('<!-- Container for PayPal Shortcut Checkout -->')
192 div#paypalCheckoutContainer {}
193 _out.push('<!-- Container for PayPal Mark Redirect -->')
194 div#paypalMarkRedirect {
198 a.'w-100'.btn.btn-success.btn-block(href="pages/shipping.html" role="button") {
200 'Proceed to Checkout'
215 'Enter REST API credentials in common/config/config.json. You can get your own REST app credentials by creating a REST app with the steps outlined '
217 a(href="https://developer.paypal.com/docs/api-basics/manage-apps/#create-or-edit-sandbox-and-live-apps" target="_blank") {
225 'Click on \'PayPal Checkout’ button and see the experience.'
228 'Checkout with PayPal using a buyer sandbox account provided on this page. And you\'re done!'
231 'In the guest checkout experience, the buyer country can be switched. When switched to one of Germany, Poland, Austria, Netherlands, Italy and Spain, you will be able to choose the alternative payment methods offered in those countries.'
234 'For example: Selecting \'Germany\' in the country drop down will pre-fill the shipping address on the Shipping Information page. For all other countries not mentioned in step 5, the address has to be manually entered.'
239 'In-Context Checkout integration steps with PayPal JavaScript SDK'
243 'Copy the files and folders in the package to the same location where you have your shopping cart page.'
246 'In order to view Alternative Payment Methods as part of the guest checkout flow, you must add query parameters intent=capture, commit=true, vault=false and buyer-country= and you must provide a supported buyer country'
249 'Include the following script on your shopping cart page: (For APMs, the layout must be '
253 ' and setting up the payment in the alternative payment method '
254 a(href="https://developer.paypal.com/docs/checkout/integration-features/alternative-payment-methods/#availability" target="_blank") {
257 ' is required for the alternative payment method to render.)'
260 '\r\n paypal.Buttons({\r\n env: \'sandbox\', // sandbox | production\r\n \r\n // Set style of buttons\r\n style: {\r\n layout: \'vertical\', // horizontal | vertical <-Must be vertical for APMs\r\n size: \'responsive\', // medium | large | responsive\r\n shape: \'pill\', // pill | rect\r\n color: \'gold\', // gold | blue | silver | black,\r\n fundingicons: false, // true | false,\r\n tagline: false // true | false,\r\n },\r\n \r\n // payment() is called when the button is clicked\r\n createOrder: function() {\r\n \r\n return fetch(\'/my-server/create-paypal-transaction\')\r\n .then(function(res) {\r\n return res.json();\r\n }).then(function(data) {\r\n return data.orderID;\r\n });\r\n },\r\n \r\n // onAuthorize() is called when the buyer approves the payment\r\n onApprove: function(data, actions) {\r\n \r\n return fetch(\'/my-server/capture-paypal-transaction\', {\r\n body: JSON.stringify({\r\n orderID: data.orderID\r\n })\r\n }).then(function(res) {\r\n return res.json();\r\n }).then(function(details) {\r\n alert(\'Transaction funds captured from \' + details.payer_given_name);\r\n });\r\n }\r\n }).render(\'#paypal-button-container\');'
266 'Open your browser and navigate to your Shopping cart page. Click on \'Checkout with PayPal\' button and complete the flow.'
269 'You can use the sample Buyer Sandbox credentials provided on index/home page.'
273 a(href="https://developer.paypal.com/docs/checkout/" target="_blank") {
276 ' site for detailed guidelines.'
280 a(href="https://developer.paypal.com/docs/api/orders/v2/" target="_blank") {
283 ' for the API reference.'
289 _out.push('<!-- Javascript Import -->')
290 script(src="../js/config.js") {}
291 _out.push('<!-- PayPal In-Context Checkout script -->')
292 script(type="text/javascript") {
293 init_smart_buttons = (() => {
304 createOrder: function() {
305 return new Promise((resolve, reject) => {
308 url: "api/createOrder.json",
309 data: serialize(document.getElementById("camera_form")),
310 success: function(response) {
313 error: function(error) {
316 }).then(function(response) {
317 console.log("Order ID: " + response.id);
318 resolve(response.id);
322 onApprove: function(data, actions) {
323 return fetch("api/getOrderDetails.json", {
325 }).then(function(res) {
327 }).then(function(res) {
328 window.location.href = "pages/success.html";
331 }).render("#paypalCheckoutContainer");
334 _out.push('<!-- jQuery (necessary for Bootstrap\'s JavaScript plugins) -->')
335 script(src="https://code.jquery.com/jquery.js") {}
338 env.site.serve(env, 200, Buffer.from(_out.join('')), 'index.html.jst')