Added cors

This commit is contained in:
Zakary Timson 2018-07-22 18:04:41 -04:00
parent 336b02e4c4
commit e9ddb92bf8

View File

@ -2,32 +2,28 @@ import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
import * as paypal from 'paypal-rest-sdk';
const cors = require('cors')({origin: true});
paypal.configure({
mode: 'sandbox',
client_id: 'AaU8tQfmz1_MFDTKuf84yYERXvdDt2ZFJVrxhNW_49DazF4A_F0VBuKyV5_nntyEdZqUa5Oq9ZBj65GV',
client_secret: 'EAZ8aFDU4lHHLy1bQqULYWqznf3dBknXZW3AH__zFC0bUs8AGUyR6RNbm-jHvqtikX7PsSqMO5vxuvKm'
});
export const checkout = functions.https.onRequest(async (request, response) => {
export const checkout = functions.https.onRequest((request, response) => {
cors(request, response, async () => {
// Create base request
let req = {
intent: 'sale',
payer: {
payment_method: 'paypal'
},
payer: {payment_method: 'paypal'},
redirect_urls: {
return_url: 'https://fhsons.zakscode.com/success',
cancel_url: 'https://fhsons.zakscode.com/cart'
},
transactions: [
{
item_list: {
items: []
},
amount: {
total: 0,
currency: 'CAD'
},
item_list: {items: []},
amount: {total: 0, currency: 'CAD'},
description: 'Purchase of equipment and suplies from FH & Sons'
}
]
@ -74,6 +70,7 @@ export const checkout = functions.https.onRequest(async (request, response) => {
console.error(err);
response.status(500);
}
});
});
exports.process = functions.https.onRequest((req, res) => {