internetmarke
Version:
A node implementation to use the Internetmarke web service of Deutsche Post.
61 lines (60 loc) • 2.37 kB
TypeScript
import { RestService } from '../services/Rest';
import { User, UserCredentials, UserInfo } from '../User';
import { Amount } from '../utils/amount';
import { Journal, JournalOptions } from './journal';
export declare enum PaymentMethod {
DirectDebit = "DIRECTDEBIT",
GiroPay = "GIROPAY",
PayPal = "PAYPAL"
}
export interface PaymentResponse {
/** The status code which is usually 'OK'. */
code: string;
/** PayPal/Giropay redirect url, null for DirectDebit. */
redirect: string | null;
}
export interface PortokasseServiceOptions {
user: UserCredentials;
}
export interface Portokasse {
getUserInfo(): Promise<UserInfo>;
topUp(amount: Amount | number, paymentMethod: PaymentMethod, bic?: string): Promise<PaymentResponse>;
getJournal(daysOrDateRange: JournalOptions): Promise<Journal>;
}
export declare class PortokasseService extends RestService implements Portokasse {
private user;
private cookieJar;
private csrf?;
private log;
constructor(user: User, getLogger: any);
init(options: PortokasseServiceOptions): Promise<boolean>;
isInitialized(): boolean;
/**
* Retrieves the user information including the wallet balance.
*/
getUserInfo(): Promise<UserInfo>;
/**
* Tops up the Portokasse account with the given amount of money and the
* defined payment provider or type.
*
* @param amount The amout you want to charge as amount object or as number in
* in Euro cents. Note: The minimum amount id EUR 10.
* @param paymentMethod The type of provider you want to choose. PayPal and
* GiroPay both return a callback url to proceed the transaction, DirectDebit
* requires a one time registration at the Portokasse website prior it can
* be used.
* @param bic Optional BIC of the bank account you want to be charged. This
* value is only used for GiroPay transactions.
*/
topUp(amount: Amount | number, paymentMethod: PaymentMethod, bic?: string): Promise<PaymentResponse>;
/**
* Get the purchase and top up journal of your account.
*
* @param daysOrDateRange Eigher a days or a date range option with optional
* offset and rows information.
*/
getJournal(daysOrDateRange: JournalOptions): Promise<Journal>;
private login;
private checkServiceInit;
private request;
}