Mollie Payment API Firestore函数(CORS错误)

时间:2018-07-23 11:19:13

标签: javascript firebase google-cloud-functions mollie

我正在尝试使用Firestore函数实现php demo at eval.in付款API。我发现了一个教程和其他用户关于堆栈溢出的问题,这使我得以创建函数。但是,每次我尝试执行它时,都会收到CORS错误:“不允许访问原件”。

我的代码:

From Coq Require Import Arith.
Local Coercion is_true : bool >-> Sortclass.

Definition Z_pos: Set := {n : nat | 0 <? n }.

Definition Z_pos__N (p: Z_pos): nat := proj1_sig p.

Definition Z_pos_mult : Z_pos -> Z_pos -> Z_pos.
  intros [x xpos%Nat.ltb_lt] [y ypos%Nat.ltb_lt].
  refine (exist  _ (x * y) _).
  now apply Nat.ltb_lt, Nat.mul_pos_pos.
Defined.

Lemma compat: forall p q: Z_pos, Z_pos__N (Z_pos_mult p q) = Z_pos__N p * Z_pos__N q.
Proof. now intros [x xpos] [y ypos]. Qed.

我也尝试过:

import * as cors from 'cors';
const corsHandler = cors({origin: true});

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const Mollie = require("mollie-api-node");
const mollie = new Mollie.API.Client;
mollie.setApiKey("myapikey");
const querystring = require("querystring");
const fs = require("fs");

exports.pay = functions.https.onRequest((req, res) => {
    console.log('1. response', res)
    corsHandler(req, res, () => {
    mollie.payments.create({
        amount: 9.99,
        method: Mollie.API.Object.Method.DIRECTDEBIT,
        description: "Betaling voor co",
        redirectUrl: "redirectUrl",
        webhookUrl: "webhookUrl",
        testmode: true
    }, (payment) => {
        if (payment.error) {
            console.error('errrr', payment.error);
            return res.end();
        }
        if(payment.isPaid()){
            console.log('test case for response: Payment is payed!! ')
        }
        console.log('3. payment.getPaymentUrl()', payment.getPaymentUrl());
        res.redirect(302, payment.getPaymentUrl());
    });
  });
});

但结果相同。

有人知道如何使用firebase函数实现Mollie API,或者我做错了什么?

先谢谢了。

0 个答案:

没有答案