@yosle/tropipayjs
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -303,4 +303,23 @@ 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>; | ||
} | ||
declare const SERVER_MODE: ServerMode$1; | ||
export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig }; | ||
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 }; |
73
index.js
@@ -439,2 +439,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`); | ||
} | ||
} | ||
} | ||
const SERVER_MODE = "Development"; // Move the constant here | ||
@@ -458,2 +530,3 @@ | ||
exports.ClientSideUtils = ClientSideUtils; | ||
exports.PaymentCard = PaymentCard; | ||
exports.SERVER_MODE = SERVER_MODE; | ||
@@ -460,0 +533,0 @@ exports.ServerSideUtils = ServerSideUtils; |
{ | ||
"name": "@yosle/tropipayjs", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Javascript / Typescript SDK for the Tropipay API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,4 +23,5 @@ /** | ||
export { TropipayHooks } from "./hooks/TropipayHooks"; | ||
export { PaymentCard } from "./paymentcard/PaymentCard"; | ||
export * from "./interfaces/index"; | ||
export { SERVER_MODE } from "./config/TropipayConfig"; | ||
export * from "./constants/TropipayConstants"; |
1670846
2372