2016-07-08 00:43:33 +02:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
2016-06-09 10:17:08 -04:00
|
|
|
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
export interface CardIOOptions {
|
2016-06-09 10:17:08 -04:00
|
|
|
|
2016-07-08 00:43:33 +02:00
|
|
|
/**
|
2016-12-06 09:03:39 -05:00
|
|
|
* Set to true to require expiry date
|
2016-07-08 00:43:33 +02:00
|
|
|
*/
|
2016-12-06 09:03:39 -05:00
|
|
|
requireExpiry?: boolean;
|
2016-06-09 10:17:08 -04:00
|
|
|
|
2016-07-08 00:43:33 +02:00
|
|
|
/**
|
2016-12-06 09:03:39 -05:00
|
|
|
* The user will be prompted for the card CVV
|
2016-07-08 00:43:33 +02:00
|
|
|
*/
|
2016-12-01 18:37:00 -05:00
|
|
|
requireCVV?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The user will be prompted for the card billing postal code.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
requirePostalCode?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Removes the keyboard button from the scan screen.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
supressManual?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The postal code will only collect numeric input. Set this if you know the expected country's postal code has only numeric postal codes.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
restrictPostalCodeToNumericOnly?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The theme for the card.io Activity's will be set to the theme of the application.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
keepApplicationTheme?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The user will be prompted for the cardholder name
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
requireCardholderName?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Used to display instructions to the user while they are scanning their card.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
scanInstructions?: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* If set, the card will not be scanned with the camera.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
noCamera?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* If scanExpiry is true, an attempt to extract the expiry from the card image will be made.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
scanExpiry?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The preferred language for all strings appearing in the user interface. If not set, or if set to null, defaults to the device's current language setting.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
languageOrLocale?: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Changes the color of the guide overlay on the camera. The color is provided in hexadecimal format (e.g. `#FFFFFF`)
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
guideColor?: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The user will not be prompted to confirm their card number after processing.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
supressConfirmation?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The card.io logo will not be shown overlaid on the camera.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
hideCardIOLogo?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* The card.io logo will be shown instead of the PayPal logo.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
useCardIOLogo?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Once a card image has been captured but before it has been processed, this value will determine whether to continue processing as usual.
|
|
|
|
*/
|
2016-07-08 00:43:33 +02:00
|
|
|
supressScan?: boolean;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-07-08 00:43:33 +02:00
|
|
|
}
|
2016-12-01 18:45:02 -05:00
|
|
|
|
|
|
|
export interface CardIOResponse {
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Card type
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
cardType: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Masked card number, showing only last 4 digits
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
redactedCardNumber: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Full card number
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
cardNumber: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Expiry month
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
expiryMonth: number;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Expiry year
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
expiryYear: number;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* CVV
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
cvv: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Postal code
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
postalCode: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-06 09:03:39 -05:00
|
|
|
/**
|
|
|
|
* Cardholder name
|
|
|
|
*/
|
2016-12-01 18:45:02 -05:00
|
|
|
cardholderName: string;
|
2016-12-06 08:02:00 -05:00
|
|
|
|
2016-12-01 18:45:02 -05:00
|
|
|
}
|
2016-12-06 09:03:39 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @name CardIO
|
|
|
|
* @description
|
|
|
|
* @usage
|
|
|
|
* ```
|
|
|
|
* import { CardIO } from 'ionic-native';
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* CardIO.canScan()
|
|
|
|
* .then(
|
|
|
|
* (res: boolean) => {
|
|
|
|
* if(res){
|
|
|
|
* let options = {
|
|
|
|
* requireExpiry: true,
|
|
|
|
* requireCCV: false,
|
|
|
|
* requirePostalCode: false
|
|
|
|
* };
|
|
|
|
* CardIO.scan(options);
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* );
|
|
|
|
* ```
|
|
|
|
* @interfaces
|
|
|
|
* CardIOOptions
|
|
|
|
* CardIOResponse
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
pluginName: 'CardIO',
|
|
|
|
plugin: 'card.io.cordova.mobilesdk',
|
|
|
|
pluginRef: 'CardIO',
|
|
|
|
repo: 'https://github.com/card-io/card.io-Cordova-Plugin',
|
|
|
|
platforms: ['iOS', 'Android']
|
|
|
|
})
|
|
|
|
export class CardIO {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether card scanning is currently available. (May vary by
|
|
|
|
* device, OS version, network connectivity, etc.)
|
|
|
|
*
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static canScan(): Promise<boolean> { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scan a credit card with card.io.
|
|
|
|
* @param {CardIOOptions} options Options for configuring the plugin
|
|
|
|
* @returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static scan(options?: CardIOOptions): Promise<CardIOResponse> { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the version of the card.io library. Useful when contacting support.
|
|
|
|
* @returns {Promise<string>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static version(): Promise<string> { return; }
|
|
|
|
|
|
|
|
}
|