令牌以[object Object]离子的形式返回

时间:2018-02-05 12:18:30

标签: angularjs ionic-framework stripe-payments

我使用'@ ionic-native / stripe'中的import {Stripe}来创建卡片令牌但是函数createCardToken()正在返回对象

this.stripe.createCardToken(card).then(token => alert('transaction Successfull !!'+ token)) .catch(error => alert('error'+ error));

enter image description here

我如何得到令牌的刺痛?

以下是createCardToken的原型  createCardToken(params:StripeCardTokenParams):承诺;

2 个答案:

答案 0 :(得分:1)

您应该转入JSON.stringify(token)

答案 1 :(得分:0)

根据文档@ https://ionicframework.com/docs/native/stripe/

返回的令牌确实是一个对象。您可能想要访问它的id属性:

this.stripe.createCardToken(card) .then(token => console.log(token.id)) .catch(error => console.error(error));

相关问题