2024-02-09 17:49:45 +00:00
|
|
|
class Fastlane {
|
2024-10-05 02:26:09 +02:00
|
|
|
constructor( namespace ) {
|
|
|
|
this.namespace = namespace;
|
2024-07-12 12:58:34 +02:00
|
|
|
this.connection = null;
|
|
|
|
this.identity = null;
|
|
|
|
this.profile = null;
|
|
|
|
this.FastlaneCardComponent = null;
|
|
|
|
this.FastlanePaymentComponent = null;
|
|
|
|
this.FastlaneWatermarkComponent = null;
|
|
|
|
}
|
2024-02-09 17:49:45 +00:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
connect( config ) {
|
|
|
|
return new Promise( ( resolve, reject ) => {
|
2024-10-05 02:26:09 +02:00
|
|
|
if ( ! window[ this.namespace ] ) {
|
|
|
|
reject(
|
|
|
|
new Error(
|
|
|
|
`Namespace ${ this.namespace } not found on window object`
|
|
|
|
)
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window[ this.namespace ]
|
2024-07-12 12:58:34 +02:00
|
|
|
.Fastlane( config )
|
|
|
|
.then( ( result ) => {
|
|
|
|
this.init( result );
|
|
|
|
resolve();
|
|
|
|
} )
|
|
|
|
.catch( ( error ) => {
|
|
|
|
console.error( error );
|
2024-10-05 02:26:09 +02:00
|
|
|
reject( error );
|
2024-07-12 12:58:34 +02:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
}
|
2024-02-09 17:49:45 +00:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
init( connection ) {
|
|
|
|
this.connection = connection;
|
|
|
|
this.identity = this.connection.identity;
|
|
|
|
this.profile = this.connection.profile;
|
|
|
|
this.FastlaneCardComponent = this.connection.FastlaneCardComponent;
|
|
|
|
this.FastlanePaymentComponent =
|
|
|
|
this.connection.FastlanePaymentComponent;
|
|
|
|
this.FastlaneWatermarkComponent =
|
|
|
|
this.connection.FastlaneWatermarkComponent;
|
|
|
|
}
|
2024-02-09 17:49:45 +00:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
setLocale( locale ) {
|
|
|
|
this.connection.setLocale( locale );
|
|
|
|
}
|
2024-02-09 17:49:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Fastlane;
|