From 5b15bb9f46d5212a494ba685cad422a0741abbed Mon Sep 17 00:00:00 2001
From: Akshay Dwivedi <akshaydwivedi@live.com>
Date: Thu, 28 Sep 2017 04:56:25 +0800
Subject: [PATCH] fix(stripe): fix stripe create card token (#2002)

fix stripe create card token promise
---
 src/@ionic-native/plugins/stripe/index.ts | 31 ++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/@ionic-native/plugins/stripe/index.ts b/src/@ionic-native/plugins/stripe/index.ts
index 83c7a7c8c..32eda51de 100644
--- a/src/@ionic-native/plugins/stripe/index.ts
+++ b/src/@ionic-native/plugins/stripe/index.ts
@@ -79,6 +79,31 @@ export interface StripeBankAccountParams {
   account_holder_type?: string;
 }
 
+export interface StripeCardTokenRes {
+    /**
+     * Card Object.
+     */
+    card: {
+        brand: string,
+        exp_month: number,
+        exp_year: number,
+        funding: string,
+        last4: string
+    };
+    /**
+     * Token Request Date Time.
+     */
+    created: string;
+    /**
+     * Card Token.
+     */
+    id: string;
+    /**
+     * Source Type (card or account).
+     */
+    type: string;
+}
+
 /**
  * @name Stripe
  * @description
@@ -102,7 +127,7 @@ export interface StripeBankAccountParams {
  * };
  *
  * this.stripe.createCardToken(card)
- *    .then(token => console.log(token))
+ *    .then(token => console.log(token.id))
  *    .catch(error => console.error(error));
  *
  * ```
@@ -131,10 +156,10 @@ export class Stripe extends IonicNativePlugin {
   /**
    * Create Credit Card Token
    * @param params {StripeCardTokenParams} Credit card information
-   * @return {Promise<string>} returns a promise that resolves with the token, or rejects with an error
+   * @return {Promise<StripeCardTokenRes>} returns a promise that resolves with the token object, or rejects with an error
    */
   @Cordova()
-  createCardToken(params: StripeCardTokenParams): Promise<string> { return; }
+  createCardToken(params: StripeCardTokenParams): Promise<StripeCardTokenRes> { return; }
 
   /**
    * Create a bank account token