Skip to content

Instantly share code, notes, and snippets.

@tochi
Created April 2, 2019 13:19
Show Gist options
  • Save tochi/8ef2daa93078dfc09f534730ecacaff2 to your computer and use it in GitHub Desktop.
Save tochi/8ef2daa93078dfc09f534730ecacaff2 to your computer and use it in GitHub Desktop.
Point of Sale for Square
%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