From 65dd8b5ea9816041485f5fe5865cfec5e13cb714 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Wed, 12 Sep 2018 10:23:15 -0300 Subject: [PATCH 1/2] add TypeScript type definitions. --- index.d.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..b3118a1 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,23 @@ +type Platform = 'amazon' | 'apple' | 'google' | 'roku'; + +interface Payment { + receipt: any, // always required + productId: string, + packageName: string, + secret: string, + subscription?: boolean, + keyObject?: any, // required, if google + userId?: string, // required, if amazon + devToken?: string, // required, if roku +} + +interface Response { + receipt: any, + platform: Platform, + productId: string, + transactionId: string, + purchaseDate: number, + expirationDate: number, +} + +export function verifyPayment (platform: Platform, payment: Payment, callback: (error: string, response: Response) => void); From e45a613cae6019315e1fb2a157ba4b734a7f485d Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Wed, 12 Sep 2018 10:28:28 -0300 Subject: [PATCH 2/2] fix response callback to allow accessing any field of the Response --- index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b3118a1..72ad1ab 100644 --- a/index.d.ts +++ b/index.d.ts @@ -20,4 +20,8 @@ interface Response { expirationDate: number, } -export function verifyPayment (platform: Platform, payment: Payment, callback: (error: string, response: Response) => void); +export function verifyPayment ( + platform: Platform, + payment: Payment, + callback: (error: string, response: Response & any) => void +);