Stripe Connect перенаправляет URI для запуска базы данных облачного пожарного хранилища

Привет, пожалуйста, проверьте, что это полный код запроса ajax.

        $('#foo').submit(function(event) {
        // get the form data
        // there are many ways to get this data using jQuery (you can use the 
    class or id also)
    var formData = $('#foo').serialize();
    var url ='url of the request';
    // process the form.

    $.ajax({
        type        : 'POST', // define the type of HTTP verb we want to use
        url         : 'url/', // the url where we want to POST
        data        : formData, // our data object
        dataType    : 'json', // what type of data do we expect back.
        beforeSend : function() {
        //this will run before sending an ajax request do what ever activity 
         you want like show loaded 
         },
        success:function(response){
            var obj = eval(response);
            if(obj)
            {  
                if(obj.error==0){
                alert('success');
                }
            else{  
                alert('error');
                }   
            }
        },
        complete : function() {
           //this will run after sending an ajax complete                   
                    },
        error:function (xhr, ajaxOptions, thrownError){ 
          alert('error occured');
        // if any error occurs in request 
        } 
    });
    // stop the form from submitting the normal way and refreshing the page
    event.preventDefault();
});
0
задан DSS 22 March 2019 в 19:53
поделиться

1 ответ

Одним из решений является использование HTTPS Cloud Function .

Как объясняется в документе, «после развертывания функции HTTPS вы можете вызывать ее через собственный уникальный URL-адрес». URL будет выглядеть следующим образом: https: // us-central1- .cloudfunctions.net / stripeWebhook, и вам просто нужно объявить его в настройках Stripe.

В облачной функции вы сможете получать значения, передаваемые в тело HTTP-запроса, следующим образом:

exports.stripeWebhook = functions.https.onRequest((req, res) => {
    const orderId = req.body.data.object.metadata.orderId;
    const sourceId = req.body.data.object.id;
    const sourceType = req.body.data.object.type;
    ....
});

, а также записывать в Firestore, чтобы обновить запись в соответствии с paiement. В качестве примера вы можете посмотреть следующее официальное видео: https://www.youtube.com/watch?v=7IkUgCLr5oA&t=1s&list=PLl-K7zZEsYLkPZHe41m4jfAxUi0JjLgSM&index=3 117

0
ответ дан Renaud Tarnec 22 March 2019 в 19:53
поделиться
Другие вопросы по тегам:

Похожие вопросы: