-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow paying with using on-site credit card (#22)
- Loading branch information
Showing
63 changed files
with
3,087 additions
and
633 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './js/card_encoder'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as JSEncrypt from './jsencrypt.min'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const form = document.querySelector('[name="sylius_checkout_complete"]'); | ||
const submit_button = form.querySelector('[type="submit"]'); | ||
const cards_api = document.getElementById('sylius_checkout_complete_tpay_cards_api').value.replace(/\s/g, ''); | ||
const encrypted_card_field = document.getElementById('sylius_checkout_complete_tpay_card_card'); | ||
|
||
const encrypt = new JSEncrypt(); | ||
encrypt.setPublicKey(atob(cards_api)); | ||
|
||
submit_button.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
|
||
const card_number = document.getElementById('sylius_checkout_complete_tpay_card_number').value.replace(/\s/g, ''); | ||
const cvc = document.getElementById('sylius_checkout_complete_tpay_card_cvv').value.replace(/\s/g, ''); | ||
const expiration_date_month = document.getElementById('sylius_checkout_complete_tpay_card_expiration_date_month').value.replace(/\s/g, ''); | ||
const expiration_date_year = document.getElementById('sylius_checkout_complete_tpay_card_expiration_date_year').value.replace(/\s/g, ''); | ||
const expiration_date = [expiration_date_month, expiration_date_year].join('/'); | ||
|
||
encrypted_card_field.value = encrypt.encrypt([card_number, expiration_date, cvc, document.location.origin].join('|')); | ||
|
||
form.submit(); | ||
}) | ||
}); |
Oops, something went wrong.