Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions advanced-integration/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
let paymentsClient = null, googlepayConfig = null;

const ENV = 'TEST';
const API_PATH = '/api/orders';


/**
*
Expand All @@ -31,7 +34,7 @@ async function getGooglePayConfig(){
* @returns {object} PaymentDataRequest fields
*/
async function getGooglePaymentDataRequest() {
const {allowedPaymentMethods,merchantInfo, apiVersion, apiVersionMinor , countryCode} = await getGooglePayConfig();
const {allowedPaymentMethods, merchantInfo, apiVersion, apiVersionMinor, countryCode} = await getGooglePayConfig();
const baseRequest = {
apiVersion,
apiVersionMinor
Expand Down Expand Up @@ -78,7 +81,7 @@ async function getGooglePaymentDataRequest() {
function getGooglePaymentsClient() {
if (paymentsClient === null) {
paymentsClient = new google.payments.api.PaymentsClient({
environment: 'TEST',
environment: ENV,
paymentDataCallbacks: {
onPaymentAuthorized: onPaymentAuthorized
}
Expand Down Expand Up @@ -174,7 +177,7 @@ async function processPayment(paymentData) {
const modal = document.getElementById("resultModal");
resultElement.innerHTML = ""
try {
const { id } = await fetch(`/api/orders`,{
const { id } = await fetch(`${API_PATH}`,{
method:'POST',
headers : {
'Content-Type': 'application/json'
Expand All @@ -196,7 +199,7 @@ async function processPayment(paymentData) {
/**
* GET Order
*/
const orderResponse = await fetch(`/api/orders/${id}`, {
const orderResponse = await fetch(`${API_PATH}/${id}`, {
method: "GET"
}).then(res =>res.json())

Expand Down Expand Up @@ -226,7 +229,7 @@ async function processPayment(paymentData) {
* CAPTURE THE ORDER
*/

const response = await fetch(`/api/orders/${id}/capture`, {
const response = await fetch(`${API_PATH}/${id}/capture`, {
method: "POST"
}).then(res =>res.json())

Expand Down