13 | Request ID: @Model.RequestId
14 |
19 | Swapping to Development environment will display more detailed information about the error that occurred. 20 |
21 |22 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 23 |
24 | -------------------------------------------------------------------------------- /connect-examples/v2/csharp_payment/wwwroot/js/sq-google-pay.js: -------------------------------------------------------------------------------- 1 | async function GooglePay(buttonEl) { 2 | const paymentRequest = window.payments.paymentRequest( 3 | // Use global method from sq-payment-flow.js 4 | window.getPaymentRequest() 5 | ); 6 | const googlePay = await payments.googlePay(paymentRequest); 7 | await googlePay.attach(buttonEl); 8 | 9 | async function eventHandler(event) { 10 | // Clear any existing messages 11 | window.paymentFlowMessageEl.innerText = ''; 12 | 13 | try { 14 | const result = await googlePay.tokenize(); 15 | if (result.status === 'OK') { 16 | // Use global method from sq-payment-flow.js 17 | window.createPayment(result.token); 18 | } 19 | } catch (e) { 20 | if (e.message) { 21 | window.showError(`Error: ${e.message}`); 22 | } else { 23 | window.showError('Something went wrong'); 24 | } 25 | } 26 | } 27 | 28 | buttonEl.addEventListener('click', eventHandler); 29 | } 30 | -------------------------------------------------------------------------------- /connect-examples/v2/node_payment/public/js/sq-google-pay.js: -------------------------------------------------------------------------------- 1 | async function GooglePay(buttonEl) { 2 | const paymentRequest = window.payments.paymentRequest( 3 | // Use global method from sq-payment-flow.js 4 | window.getPaymentRequest() 5 | ); 6 | const googlePay = await payments.googlePay(paymentRequest); 7 | await googlePay.attach(buttonEl); 8 | 9 | async function eventHandler(event) { 10 | // Clear any existing messages 11 | window.paymentFlowMessageEl.innerText = ''; 12 | 13 | try { 14 | const result = await googlePay.tokenize(); 15 | if (result.status === 'OK') { 16 | // Use global method from sq-payment-flow.js 17 | window.createPayment(result.token); 18 | } 19 | } catch (e) { 20 | if (e.message) { 21 | window.showError(`Error: ${e.message}`); 22 | } else { 23 | window.showError('Something went wrong'); 24 | } 25 | } 26 | } 27 | 28 | buttonEl.addEventListener('click', eventHandler); 29 | } 30 | -------------------------------------------------------------------------------- /connect-examples/v2/python_payment/static/js/sq-google-pay.js: -------------------------------------------------------------------------------- 1 | async function GooglePay(buttonEl) { 2 | const paymentRequest = window.payments.paymentRequest( 3 | // Use global method from sq-payment-flow.js 4 | window.getPaymentRequest() 5 | ); 6 | const googlePay = await payments.googlePay(paymentRequest); 7 | await googlePay.attach(buttonEl); 8 | 9 | async function eventHandler(event) { 10 | // Clear any existing messages 11 | window.paymentFlowMessageEl.innerText = ''; 12 | 13 | try { 14 | const result = await googlePay.tokenize(); 15 | if (result.status === 'OK') { 16 | // Use global method from sq-payment-flow.js 17 | window.createPayment(result.token); 18 | } 19 | } catch (e) { 20 | if (e.message) { 21 | window.showError(`Error: ${e.message}`); 22 | } else { 23 | window.showError('Something went wrong'); 24 | } 25 | } 26 | } 27 | 28 | buttonEl.addEventListener('click', eventHandler); 29 | } 30 | -------------------------------------------------------------------------------- /connect-examples/v2/rails_payment/app/assets/javascripts/sq-google-pay.js: -------------------------------------------------------------------------------- 1 | async function GooglePay(buttonEl) { 2 | const paymentRequest = window.payments.paymentRequest( 3 | // Use global method from sq-payment-flow.js 4 | window.getPaymentRequest() 5 | ); 6 | const googlePay = await payments.googlePay(paymentRequest); 7 | await googlePay.attach(buttonEl); 8 | 9 | async function eventHandler(event) { 10 | // Clear any existing messages 11 | window.paymentFlowMessageEl.innerText = ''; 12 | 13 | try { 14 | const result = await googlePay.tokenize(); 15 | if (result.status === 'OK') { 16 | // Use global method from sq-payment-flow.js 17 | window.createPayment(result.token); 18 | } 19 | } catch (e) { 20 | if (e.message) { 21 | window.showError(`Error: ${e.message}`); 22 | } else { 23 | window.showError('Something went wrong'); 24 | } 25 | } 26 | } 27 | 28 | buttonEl.addEventListener('click', eventHandler); 29 | } 30 | -------------------------------------------------------------------------------- /connect-examples/v2/java_payment/src/main/resources/static/js/sq-google-pay.js: -------------------------------------------------------------------------------- 1 | async function GooglePay(buttonEl) { 2 | const paymentRequest = window.payments.paymentRequest( 3 | // Use global method from sq-payment-flow.js 4 | window.getPaymentRequest() 5 | ); 6 | const googlePay = await payments.googlePay(paymentRequest); 7 | await googlePay.attach(buttonEl); 8 | 9 | async function eventHandler(event) { 10 | // Clear any existing messages 11 | window.paymentFlowMessageEl.innerText = ''; 12 | 13 | try { 14 | const result = await googlePay.tokenize(); 15 | if (result.status === 'OK') { 16 | // Use global method from sq-payment-flow.js 17 | window.createPayment(result.token); 18 | } 19 | } catch (e) { 20 | if (e.message) { 21 | window.showError(`Error: ${e.message}`); 22 | } else { 23 | window.showError('Something went wrong'); 24 | } 25 | } 26 | } 27 | 28 | buttonEl.addEventListener('click', eventHandler); 29 | } 30 | -------------------------------------------------------------------------------- /connect-examples/v2/rails_snippet/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /connect-examples/v2/rails_snippet/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Square Online Store Snippets Example 4 | 5 | ### Setup 6 | 7 | The sample app currently runs on: 8 | 9 | Ruby Version: 2.5.8 10 | 11 | Rails Version: 6.1.3.1 12 | 13 | 1. To run this app locally using Docker Compose, you must have first have [Docker Compose installed](https://docs.docker.com/compose/install/) 14 | 2. Once installed you can run `docker-compose build` to build the application web container 15 | 3. Then run `docker-compose run web rails webpacker:install` to build the application's webpack manifest 16 | 4. Update the .env file at the root with following values: (WARNING: never upload .env with your credentials/secrets) 17 | ``` 18 | SQUARE_APPLICATION_ID=your-app-id 19 | SQUARE_APPLICATION_SECRET=your-app-secret 20 | ``` 21 | 5. Then run `docker-compose up` to start the rails web server 22 | 23 | The application will then run and be accessible at http://localhost:3000 24 | 25 | ## Feedback 26 | Rate this sample app [here](https://delighted.com/t/Z1xmKSqy)! -------------------------------------------------------------------------------- /connect-examples/v2/node_orders-payments/views/README.md: -------------------------------------------------------------------------------- 1 | # Views 2 | 3 | This directory contains the templates written in [PugJs](https://pugjs.org/api/getting-started.html). PugJs templates are rendered by [ExpressJs](https://expressjs.com/en/guide/using-template-engines.html)'s `render` function into HTML that is subsequently sent to the client's browser. Each `.pug` file is an individual view that the user can navigate through the app. When working with PugJs one needs to keep in mind that any javascript outside of a script block in the `.pug` file is run on the server side **before** it reaches to the client. To write client side javascript, write javascript within a script block or in a separate file and load it using script tags. 4 | 5 | ## Includes 6 | 7 | The `/includes` subdirectory contains pug files that can be `included` into other `.pug` files. Including `.pug` files into one another can be thought of as akin to component composition found in other front end frameworks. This allows us to write more modular templates that can be reused in different views. -------------------------------------------------------------------------------- /connect-examples/v2/rails_payment/app/views/layouts/index.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |{subTitle}
19 | ) : null} 20 | {title} 21 |