trust-my-travel-legacy
Version:
SDK for the Trust My Travel legacy payments API.
267 lines (266 loc) • 6.15 kB
TypeScript
import getSpreedlyTestTokens from './getSpreedlyTestTokens';
export { getSpreedlyTestTokens };
/**
* Trust My Travel SDK Class
*/
export default class TrustMyTravel {
private username;
private password;
private client;
/**
* Trust My Travel SDK for taking payments and making refunds
*
* Creates an XMLRPC client for the Trust My Travel API
*/
constructor({ username, password, live }: Config);
private methodCall;
takePayment(data: PaymentParameters): Promise<PaymentResponse>;
refund(data: RefundParameters): Promise<RefundResponse>;
testConnection(): Promise<string>;
}
export interface Config {
/**
* Trust My Travel username
*/
username: string;
/**
* Trust My Travel password
*/
password: string;
/**
* Use live API setting
*
* If false, staging.trustmytravel.com will be used instead
*/
live?: boolean;
}
export interface PaymentParameters {
firstname: string;
surname: string;
email: string;
/**
* Address line 1
*
* Equivalenty premise (building number, building name & sub-building name) & thoroughfare (street name)
*/
address: string;
/**
* Address line 2
*
* Typically dependency thoroughfare (secondard part if there are 2 streets with the same name in the area) or empty
*/
address2?: string;
/**
* City
*
* Locality (city)
*/
city?: string;
/**
* State / County
*/
state?: string;
/**
* Country ISO
*
* [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) 2-digit format
*/
country: string;
/**
* Zip/postal code
*/
postcode: string;
/**
* Reference
*
* E.g. payment or transaction ID
*/
reference: string;
/**
* Trip end date
*
* Fromat YYYY-MM-DD
*/
date_end: string;
/**
* Currency ISO
*
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-digit format
*/
currency: Currency;
/**
* Total amount in cents/pence
*
* Note this is not zero-decimal - instead it assumes 2 decimal places for every currency (e.g. `100.00` for £100)
*/
total: number;
/**
* Line item
*
* Given as a string - e.g. booking ID
*/
line_items?: string;
/**
* Spreedly payment token
*/
payment_method_token: string;
/**
* Affiliate payments
*/
affiliate_payments?: [AffiliatePaymentParameters];
}
export interface AffiliatePaymentParameters {
/**
* Trust My Travel Affiliate PID
*/
affiliate_id: string;
/**
* Currency ISO
*
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-digit format
*/
currency: Currency;
/**
* Total amount in cents/pence
*
* Note this is not zero-decimal - instead it assumes 2 decimal places for every currency (e.g. `100.00` for £100)
*/
total: number;
}
export declare enum Currency {
GBP = "GBP",
USD = "USD",
EUR = "EUR"
}
export interface RefundParameters {
/**
* Trust My Travel Payment ID
*/
booking_id: number;
/**
* Currency ISO
*
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-digit format
*/
currency: Currency;
/**
* Total amount in cents/pence
*
* Note this is not zero-decimal - instead it assumes 2 decimal places for every currency (e.g. `100.00` for £100)
*/
amount: number;
/**
* Affiliate refunds
*/
affiliate_refunds?: [AffiliateRefundParameters];
}
export interface AffiliateRefundParameters {
/**
* Trust My Travel Affiliate Payment ID
*/
booking_id: number;
/**
* Currency ISO
*
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-digit format
*/
currency: Currency;
/**
* Total amount in cents/pence
*
* Note this is not zero-decimal - instead it assumes 2 decimal places for every currency (e.g. `100.00` for £100)
*/
amount: number;
}
export interface PaymentResponse {
/**
* Payment success status
*/
success: boolean;
/**
* Trust My Travel payment ID
*/
booking_id: number;
/**
* Response
*
* Can return e.g. "Suceeded" if successful, or "Declined - Do Not Honour" as a failure reason
*/
response: string;
investigate: boolean;
/**
* Card last four digits
*/
last_four_digits: string;
/**
* Card type
*
* E.g. "visa"
*/
card_type: string;
/**
* Card expiry
*
* Of format MM-YYYY
*/
card_expiry: string;
/**
* Cardholder full name
*/
cardholder: string;
/**
* Affiliate payments
*/
affiliate_payments?: [PaymentAffiliateResponse];
}
export interface PaymentAffiliateResponse {
/**
* Trust My Travel payment ID
*
* Note: This this appears to be the main affiliate payment ID, and is different to the booking_id from the main
* payment
*/
booking_id: number;
/**
* Affiliate ID
*/
affiliate_id: string;
/**
* Trust My Travel secondary ID
*
* __Do Not Use!__
*
* @deprecated Marked as depreciated to also flag not to use this property
*
* It is not clear as to what this is for - however it does not appear to be unique
*/
tmt_id: number;
/**
* Total amount in cents/pence
*
* Note this is not zero-decimal - instead it assumes 2 decimal places for every currency (e.g. `100.00` for £100)
*/
total: number;
/**
* Currency ISO
*
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-digit format
*/
currency: Currency;
}
export interface RefundResponse {
/**
* Payment success status
*/
success: boolean;
/**
* Response
*
* Can return e.g. "Suceeded" if successful or an error descriptor
*/
response: string;
/**
* Trust My Travel refund ID
*/
refund_id: number;
}