Created
April 2, 2019 13:19
-
-
Save tochi/8ef2daa93078dfc09f534730ecacaff2 to your computer and use it in GitHub Desktop.
Point of Sale for Square
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h1 Squareとの連携 | |
= text_field_tag :price, 100 | |
= button_tag '送信' | |
:javascript | |
const button = document.getElementsByName('button')[0] | |
button.addEventListener('click', () => { | |
const price = document.getElementsByName('price')[0] | |
const dataParameter = { | |
amount_money: { | |
amount: price.value, | |
currency_code: 'JPY' | |
}, | |
callback_url: 'https://domain-name.com/visitors/new', | |
client_id: 'Application ID', | |
version: '1.3', | |
notes: 'notes for the transaction', | |
options: { | |
supported_tender_types: ['CREDIT_CARD','CASH','OTHER','SQUARE_GIFT_CARD','CARD_ON_FILE'] | |
} | |
}; | |
window.location = | |
'square-commerce-v1://payment/create?data=' + | |
encodeURIComponent(JSON.stringify(dataParameter)); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment