Added cors
This commit is contained in:
parent
336b02e4c4
commit
e9ddb92bf8
@ -2,32 +2,28 @@ import * as admin from 'firebase-admin';
|
|||||||
import * as functions from 'firebase-functions';
|
import * as functions from 'firebase-functions';
|
||||||
import * as paypal from 'paypal-rest-sdk';
|
import * as paypal from 'paypal-rest-sdk';
|
||||||
|
|
||||||
|
const cors = require('cors')({origin: true});
|
||||||
|
|
||||||
paypal.configure({
|
paypal.configure({
|
||||||
mode: 'sandbox',
|
mode: 'sandbox',
|
||||||
client_id: 'AaU8tQfmz1_MFDTKuf84yYERXvdDt2ZFJVrxhNW_49DazF4A_F0VBuKyV5_nntyEdZqUa5Oq9ZBj65GV',
|
client_id: 'AaU8tQfmz1_MFDTKuf84yYERXvdDt2ZFJVrxhNW_49DazF4A_F0VBuKyV5_nntyEdZqUa5Oq9ZBj65GV',
|
||||||
client_secret: 'EAZ8aFDU4lHHLy1bQqULYWqznf3dBknXZW3AH__zFC0bUs8AGUyR6RNbm-jHvqtikX7PsSqMO5vxuvKm'
|
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
|
// Create base request
|
||||||
let req = {
|
let req = {
|
||||||
intent: 'sale',
|
intent: 'sale',
|
||||||
payer: {
|
payer: {payment_method: 'paypal'},
|
||||||
payment_method: 'paypal'
|
|
||||||
},
|
|
||||||
redirect_urls: {
|
redirect_urls: {
|
||||||
return_url: 'https://fhsons.zakscode.com/success',
|
return_url: 'https://fhsons.zakscode.com/success',
|
||||||
cancel_url: 'https://fhsons.zakscode.com/cart'
|
cancel_url: 'https://fhsons.zakscode.com/cart'
|
||||||
},
|
},
|
||||||
transactions: [
|
transactions: [
|
||||||
{
|
{
|
||||||
item_list: {
|
item_list: {items: []},
|
||||||
items: []
|
amount: {total: 0, currency: 'CAD'},
|
||||||
},
|
|
||||||
amount: {
|
|
||||||
total: 0,
|
|
||||||
currency: 'CAD'
|
|
||||||
},
|
|
||||||
description: 'Purchase of equipment and suplies from FH & Sons'
|
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);
|
console.error(err);
|
||||||
response.status(500);
|
response.status(500);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.process = functions.https.onRequest((req, res) => {
|
exports.process = functions.https.onRequest((req, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user