@yosle/tropipayjs
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -11,2 +11,3 @@ /** | ||
import { TropipayHooks } from "../hooks/TropipayHooks"; | ||
import { PaymentCard } from "../paymentcard/PaymentCard"; | ||
export declare class Tropipay { | ||
@@ -20,2 +21,3 @@ readonly clientId: string; | ||
hooks: TropipayHooks; | ||
paymentcards: PaymentCard; | ||
constructor(config: TropipayConfig); | ||
@@ -22,0 +24,0 @@ login(): Promise<LoginResponse>; |
@@ -201,2 +201,21 @@ import { Axios } from 'axios'; | ||
declare class PaymentCard { | ||
private tropipay; | ||
constructor(tropipayInstance: Tropipay); | ||
/** | ||
* Create a paymentLink with the specified options. | ||
* @param payload PaymentLinkPayload Object. | ||
* @returns Promise<PaymentLink> or throws an Exception. | ||
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge | ||
*/ | ||
create(payload: PaymentLinkPayload): Promise<PaymentLink>; | ||
/** | ||
* Shows a list of stored paymentcards created by user. | ||
* This list includes active and closed paylinks | ||
* @returns Array of paymentlinks | ||
*/ | ||
list(): Promise<any>; | ||
get(id: string): Promise<any>; | ||
} | ||
/** | ||
@@ -219,2 +238,3 @@ * Tropipayjs is a Typescript/Javascript library for the Tropipay API. | ||
hooks: TropipayHooks; | ||
paymentcards: PaymentCard; | ||
constructor(config: TropipayConfig); | ||
@@ -305,23 +325,4 @@ login(): Promise<LoginResponse>; | ||
declare class PaymentCard { | ||
private tropipay; | ||
constructor(tropipayInstance: Tropipay); | ||
/** | ||
* Create a paymentLink with the specified options. | ||
* @param payload PaymentLinkPayload Object. | ||
* @returns Promise<PaymentLink> or throws an Exception. | ||
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge | ||
*/ | ||
create(payload: PaymentLinkPayload): Promise<PaymentLink>; | ||
/** | ||
* Shows a list of stored paymentcards created by user. | ||
* This list includes active and closed paylinks | ||
* @returns Array of paymentlinks | ||
*/ | ||
list(): Promise<any>; | ||
get(id: string): Promise<any>; | ||
} | ||
declare const SERVER_MODE: ServerMode$1; | ||
export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentCard, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig }; |
146
index.js
@@ -161,2 +161,74 @@ 'use strict'; | ||
class PaymentCard { | ||
tropipay; | ||
constructor(tropipayInstance) { | ||
this.tropipay = tropipayInstance; | ||
} | ||
/** | ||
* Create a paymentLink with the specified options. | ||
* @param payload PaymentLinkPayload Object. | ||
* @returns Promise<PaymentLink> or throws an Exception. | ||
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge | ||
*/ | ||
async create(payload) { | ||
if (!Tropipay.accessToken) { | ||
await this.tropipay.login(); | ||
} | ||
try { | ||
const paylink = await this.tropipay.request.post("/api/v2/paymentcards", payload, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${Tropipay.accessToken}`, | ||
Accept: "application/json", | ||
}, | ||
}); | ||
return paylink.data; | ||
} | ||
catch (error) { | ||
throw new Error(`TropipayJS - Error creating the Payment Card.`); | ||
} | ||
} | ||
/** | ||
* Shows a list of stored paymentcards created by user. | ||
* This list includes active and closed paylinks | ||
* @returns Array of paymentlinks | ||
*/ | ||
async list() { | ||
if (!Tropipay.accessToken) { | ||
await this.tropipay.login(); | ||
} | ||
try { | ||
const paymentcards = await this.tropipay.request.get(`/api/v2/paymentcards`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${Tropipay.accessToken}`, | ||
Accept: "application/json", | ||
}, | ||
}); | ||
return paymentcards.data; | ||
} | ||
catch (error) { | ||
throw new Error(`Could not retrieve PaymenCards list`); | ||
} | ||
} | ||
async get(id) { | ||
if (!Tropipay.accessToken) { | ||
await this.tropipay.login(); | ||
} | ||
try { | ||
const paymentcard = await this.tropipay.request.get(`/api/v2/paymentcards/${id}`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${Tropipay.accessToken}`, | ||
Accept: "application/json", | ||
}, | ||
}); | ||
return paymentcard.data; | ||
} | ||
catch (error) { | ||
throw new Error(`Could not retrieve PaymenCards`); | ||
} | ||
} | ||
} | ||
/** | ||
@@ -176,2 +248,3 @@ * Tropipayjs is a Typescript/Javascript library for the Tropipay API. | ||
hooks; | ||
paymentcards; | ||
constructor(config) { | ||
@@ -192,2 +265,3 @@ this.clientId = config.clientId; | ||
this.hooks = new TropipayHooks(this); | ||
this.paymentcards = new PaymentCard(this); | ||
} | ||
@@ -442,74 +516,2 @@ async login() { | ||
class PaymentCard { | ||
tropipay; | ||
constructor(tropipayInstance) { | ||
this.tropipay = tropipayInstance; | ||
} | ||
/** | ||
* Create a paymentLink with the specified options. | ||
* @param payload PaymentLinkPayload Object. | ||
* @returns Promise<PaymentLink> or throws an Exception. | ||
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge | ||
*/ | ||
async create(payload) { | ||
if (!Tropipay.accessToken) { | ||
await this.tropipay.login(); | ||
} | ||
try { | ||
const paylink = await this.tropipay.request.post("/api/v2/paymentcards", payload, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${Tropipay.accessToken}`, | ||
Accept: "application/json", | ||
}, | ||
}); | ||
return paylink.data; | ||
} | ||
catch (error) { | ||
throw new Error(`TropipayJS - Error creating the Payment Card.`); | ||
} | ||
} | ||
/** | ||
* Shows a list of stored paymentcards created by user. | ||
* This list includes active and closed paylinks | ||
* @returns Array of paymentlinks | ||
*/ | ||
async list() { | ||
if (!Tropipay.accessToken) { | ||
await this.tropipay.login(); | ||
} | ||
try { | ||
const paymentcards = await this.tropipay.request.get(`/api/v2/paymentcards`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${Tropipay.accessToken}`, | ||
Accept: "application/json", | ||
}, | ||
}); | ||
return paymentcards.data; | ||
} | ||
catch (error) { | ||
throw new Error(`Could not retrieve PaymenCards list`); | ||
} | ||
} | ||
async get(id) { | ||
if (!Tropipay.accessToken) { | ||
await this.tropipay.login(); | ||
} | ||
try { | ||
const paymentcard = await this.tropipay.request.get(`/api/v2/paymentcards/${id}`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${Tropipay.accessToken}`, | ||
Accept: "application/json", | ||
}, | ||
}); | ||
return paymentcard.data; | ||
} | ||
catch (error) { | ||
throw new Error(`Could not retrieve PaymenCards`); | ||
} | ||
} | ||
} | ||
const SERVER_MODE = "Development"; // Move the constant here | ||
@@ -516,0 +518,0 @@ |
{ | ||
"name": "@yosle/tropipayjs", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "Javascript / Typescript SDK for the Tropipay API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -21,2 +21,3 @@ /** | ||
import { TropipayHooks } from "../hooks/TropipayHooks"; | ||
import { PaymentCard } from "../paymentcard/PaymentCard"; | ||
export class Tropipay { | ||
@@ -30,2 +31,3 @@ readonly clientId: string; | ||
public hooks: TropipayHooks; | ||
public paymentcards: PaymentCard; | ||
@@ -48,2 +50,3 @@ constructor(config: TropipayConfig) { | ||
this.hooks = new TropipayHooks(this); | ||
this.paymentcards = new PaymentCard(this); | ||
} | ||
@@ -50,0 +53,0 @@ |
1671176
2380