【问题标题】:I need an help for integrate Stripe in my Ionic Mobile App我需要帮助将 Stripe 集成到我的 Ionic 移动应用程序中
【发布时间】:2016-12-27 15:44:45
【问题描述】:

我正在使用 Ionic 和 Firebase 在移动混合应用上开发出租车预订平台。

我需要您的帮助来将支付系统与 Stripe 集成。

我想自动创建客户并仅在客户按下“付款”按钮时收费。

这是我已经使用的代码:

$scope.addCard = function () {
Stripe.card.createToken($scope.newCard, function stripeResponseHandler(status, response) {

  if (response.error) {
    Toast.error(response.error.message);
  } else {
    // response contains id and card, which contains additional card details
    var token = response.id;
    StripeHttp.post('https://api.stripe.com/v1/customers/' + customerId  + '/sources', {
      source: token
    }).success(function (data, status, headers, config) {
      getCards(customerId);
      console.log(reponse.id)
    }).error(function (data, status, headers, config) {
      Toast.error("Add cards fail. " + status + data);
    });
  }
});
};

【问题讨论】:

  • 那么问题出在哪里?究竟是什么问题?什么不工作?
  • 如果我在变量中设置 customerId,此代码可以工作,我的问题是我想在我的应用程序中自动创建客户,我会知道创建付款结帐的解决方案

标签: angularjs cordova ionic-framework stripe-payments


【解决方案1】:

我从您的代码中看到,您没有区分客户端和服务器端。

您显示的代码应该放在服务器上,而不是放在您的 Ionic 应用程序中。

有两种方法可以解决您的问题:

  1. Host your own Server Side 并从您的 Ionic 应用程序进行 HTTP 调用
  2. Send HTTP calls from your Ionic app 到已托管且免费的支付服务器,例如 Stripe Payments API

至于选项 2,这里有两个模板已经集成并解释了如何做到这一点(详细文档):

【讨论】:

    猜你喜欢
    • 2021-04-10
    • 2022-08-24
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 2020-11-14
    • 1970-01-01
    • 2012-04-26
    相关资源
    最近更新 更多