如何检索 Stripe 中客户的所有费用并使用 ajax 将它们转储到数据表中?

How to retrieve all charges for a customer in Stripe and dump them into Datatables using ajax?

我正在使用 Stripe 作为我的支付网关,我的应用程序是经典 ASP 并且我正在使用 DataTables 作为 table 来存储客户的所有费用。我需要做的是检索所有客户元数据并将其显示在 Datatables table 中。我知道 Stripe 将在 Json 中发送响应,这是 Datatables 用来填充其 table 的内容,但是实际上没有 Classic ASP 的文档可以显示实现这一点。以下是 Datatables 的工作原理:

$('#sortable').dataTable({
    autoWidth: false,
    paging: true,
    order: [[ 1, 'asc' ]],
    ajax: {
        url: '<ASP PAGE WHERE JSON WILL RETURN>',
        type: 'POST'
      },
    deferRender: true,
    columnDefs: [
        { targets: [0], visible: false, searchable: false },
        { targets: [1], title: 'Office' },
        { targets: [2], title: 'Client' },
        { targets: [3], title: 'Charge Date' },
        { targets: [4], title: 'Charge Amount' },
        { targets: [5], title: 'Last 4 of Card' }
    ],       
    pagingType: 'full_numbers'
});    

因此,如果有人这样做过,我将不胜感激。提前致谢。

您不能直接从您的前端代码向 Stripe 的 API 发出请求,因为您需要在请求中使用您的秘密 API 密钥。

您需要将 AJAX 请求发送到您的后端服务器,它本身会将请求发送到 retrieve all charges with the ID of the customer you want in the customer 参数,然后将响应转发回您的前端代码。

Stripe 没有 Classic ASP 的官方库,但如果您可以使用 .NET,Stripe.net 社区库维护得很好,应该可以做您想做的事。