【发布时间】: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