@bloonio/lokotro-pay 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnInit, OnDestroy, EventEmitter, ModuleWithProviders, InjectionToken } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import * as i2 from '@angular/common/http';
5
- import { HttpClient } from '@angular/common/http';
6
- import * as i3 from '@angular/forms';
2
+ import { OnInit, OnDestroy, EventEmitter, InjectionToken, ModuleWithProviders } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
7
4
  import { FormGroup, FormBuilder } from '@angular/forms';
8
5
  import { Observable } from 'rxjs';
6
+ import { HttpClient } from '@angular/common/http';
9
7
 
10
8
  /**
11
9
  * Lokotro Pay - Enums
@@ -119,12 +117,8 @@ declare const LokotroPayApiResponseCodeInfo: {
119
117
  declare enum LokotroPayLanguage {
120
118
  English = "en",
121
119
  French = "fr",
122
- German = "de",
123
120
  Spanish = "es",
124
- Italian = "it",
125
121
  Russian = "ru",
126
- Hindi = "hi",
127
- Japanese = "ja",
128
122
  Chinese = "zh",
129
123
  Lingala = "ln"
130
124
  }
@@ -285,6 +279,7 @@ interface LokotroPaymentInfo {
285
279
  showUserInfoForm: boolean;
286
280
  showPaymentMethodForm: boolean;
287
281
  fillingInfo?: string;
282
+ channelInfo?: string;
288
283
  }
289
284
  /**
290
285
  * Payment method model
@@ -386,8 +381,14 @@ interface LokotroTransactionDetails {
386
381
  * Payment submit request
387
382
  */
388
383
  interface LokotroPaymentSubmitRequest {
389
- transactionId: string;
390
- paymentMethod: string;
384
+ transactionId?: string;
385
+ paymentId?: string;
386
+ paymentMethod?: string;
387
+ paymentMethodId?: string;
388
+ firstName?: string;
389
+ lastName?: string;
390
+ email?: string;
391
+ phoneNumber?: string;
391
392
  walletNumber?: string;
392
393
  walletPin?: string;
393
394
  mobileMoneyPhoneNumber?: string;
@@ -398,6 +399,15 @@ interface LokotroPaymentSubmitRequest {
398
399
  cardCvv?: string;
399
400
  cardHolderName?: string;
400
401
  bankTransferAccountId?: string;
402
+ bankAccountId?: string;
403
+ bankAccountNumber?: string;
404
+ bankAccountLabel?: string;
405
+ bankId?: string;
406
+ bankEntityId?: string;
407
+ mastercardPaymentMethod?: 'HOSTED_SESSION' | 'DIRECT_CAPTURE';
408
+ sessionId?: string;
409
+ cardData?: Record<string, unknown>;
410
+ savePaymentMethod?: boolean;
401
411
  }
402
412
  /**
403
413
  * Payment submit response
@@ -415,8 +425,10 @@ interface LokotroPaymentSubmitResponse {
415
425
  * OTP verification request
416
426
  */
417
427
  interface LokotroOtpVerifyRequest {
418
- transactionId: string;
419
- otp: string;
428
+ transactionId?: string;
429
+ paymentId?: string;
430
+ otp?: string;
431
+ otpCode?: string;
420
432
  }
421
433
  /**
422
434
  * OTP verification response
@@ -431,7 +443,8 @@ interface LokotroOtpVerifyResponse {
431
443
  * OTP resend request
432
444
  */
433
445
  interface LokotroOtpResendRequest {
434
- transactionId: string;
446
+ transactionId?: string;
447
+ paymentId?: string;
435
448
  }
436
449
  /**
437
450
  * Theme configuration
@@ -477,6 +490,8 @@ interface LokotroHttpClientConfig {
477
490
  */
478
491
  declare class LokotroHttpClientService {
479
492
  private http;
493
+ private static instanceCounter;
494
+ private instanceId;
480
495
  private appKey?;
481
496
  private acceptLanguage;
482
497
  private customHeaders;
@@ -541,6 +556,7 @@ declare class LokotroHttpClientService {
541
556
  static ɵprov: i0.ɵɵInjectableDeclaration<LokotroHttpClientService>;
542
557
  }
543
558
 
559
+ type JsonRecord = Record<string, unknown>;
544
560
  /**
545
561
  * Payment state for reactive updates
546
562
  */
@@ -557,6 +573,11 @@ declare class LokotroPaymentService {
557
573
  private httpClient;
558
574
  private stateSubject;
559
575
  state$: Observable<LokotroPaymentState>;
576
+ private currentPaymentBody?;
577
+ private mobileMoneyPollingTimer?;
578
+ private mobileMoneyPollingAttempts;
579
+ private static readonly MOBILE_MONEY_POLL_INTERVAL;
580
+ private static readonly MOBILE_MONEY_MAX_ATTEMPTS;
560
581
  constructor(httpClient: LokotroHttpClientService);
561
582
  /**
562
583
  * Get current state
@@ -611,6 +632,14 @@ declare class LokotroPaymentService {
611
632
  * Navigate to screen
612
633
  */
613
634
  navigateToScreen(screen: LokotroPayScreenNavigation): void;
635
+ /**
636
+ * Start polling for mobile money payment status
637
+ */
638
+ private startMobileMoneyPolling;
639
+ /**
640
+ * Stop mobile money status polling
641
+ */
642
+ private stopMobileMoneyPolling;
614
643
  /**
615
644
  * Handle payment success
616
645
  */
@@ -619,6 +648,14 @@ declare class LokotroPaymentService {
619
648
  * Handle payment failure
620
649
  */
621
650
  private handlePaymentFailure;
651
+ /**
652
+ * Resolve the collect response into the same flow the Flutter SDK uses.
653
+ */
654
+ private resolveCollectResponse;
655
+ /**
656
+ * Resolve transaction details into the correct screen or auto-submit flow.
657
+ */
658
+ private resolveTransactionResponse;
622
659
  /**
623
660
  * Get form screen for payment channel
624
661
  */
@@ -632,60 +669,100 @@ declare class LokotroPaymentService {
632
669
  */
633
670
  private convertSubmitRequestToData;
634
671
  /**
635
- * Parse payment info from API response
672
+ * Parse payment info from collect response.
636
673
  */
637
674
  private parsePaymentInfo;
638
675
  /**
639
- * Parse payment method from API response
676
+ * Parse payment info from transaction details response.
677
+ */
678
+ private parseTransactionPaymentInfo;
679
+ /**
680
+ * Parse payment method from API response.
640
681
  */
641
682
  private parsePaymentMethod;
642
683
  /**
643
- * Parse submit response from API
684
+ * Parse submit response from API.
644
685
  */
645
686
  private parseSubmitResponse;
687
+ /**
688
+ * Build an auto-submit request using the original payment body.
689
+ */
690
+ private buildAutoSubmitRequest;
691
+ /**
692
+ * Resolve the selected payment method from transaction details.
693
+ */
694
+ private resolveSelectedPaymentMethod;
695
+ /**
696
+ * Normalize payloads that sometimes return data nested inside data.
697
+ */
698
+ private unwrapPayload;
699
+ private resolvePaymentId;
700
+ private parseChannel;
701
+ private normalizeMethodKey;
702
+ private getNumber;
703
+ private getString;
704
+ private getBoolean;
705
+ private asRecord;
706
+ private getRecordArray;
646
707
  static ɵfac: i0.ɵɵFactoryDeclaration<LokotroPaymentService, never>;
647
708
  static ɵprov: i0.ɵɵInjectableDeclaration<LokotroPaymentService>;
648
709
  }
649
710
  interface CreatePaymentResponse {
650
711
  transaction_id?: string;
651
- amount?: string;
712
+ payment_id?: string;
713
+ amount?: number | string;
652
714
  currency?: string;
653
715
  description?: string;
654
716
  merchant_name?: string;
655
717
  merchant_id?: string;
656
- available_payment_methods?: Record<string, unknown>[];
718
+ available_payment_methods?: JsonRecord[];
657
719
  created_at?: string;
658
720
  expires_at?: string;
659
- metadata?: Record<string, unknown>;
721
+ metadata?: JsonRecord;
660
722
  payment_url?: string;
661
- show_user_info_form?: boolean;
662
- show_payment_method_form?: boolean;
723
+ status?: string;
724
+ additional_data?: JsonRecord;
663
725
  }
664
726
  interface TransactionDetailsResponse {
727
+ payment_id?: string;
665
728
  transaction_id?: string;
666
- amount?: string;
667
- currency?: string;
729
+ transactional_amount?: number | string;
730
+ amount?: number | string;
731
+ transactional_currency?: string;
732
+ currency_str?: string;
668
733
  status?: string;
669
- payment_method?: string;
734
+ channel?: string;
735
+ payment_method_id?: string;
736
+ payment_method_str?: string;
737
+ filling_info?: string;
738
+ channel_info?: string;
739
+ payment_methods?: JsonRecord[];
670
740
  customer_reference?: string;
671
- system_reference?: string;
672
741
  created_at?: string;
673
742
  updated_at?: string;
674
- metadata?: Record<string, unknown>;
743
+ metadata?: JsonRecord;
744
+ success_redirect_url?: string;
745
+ fail_redirect_url?: string;
746
+ mastercardUrl?: string;
747
+ redirect_url?: string;
675
748
  }
676
749
  interface PaymentSubmitResponse {
677
750
  success?: boolean;
678
751
  message?: string;
752
+ payment_id?: string;
679
753
  transaction_id?: string;
680
754
  status?: string;
681
755
  requires_otp?: boolean;
682
756
  otp_destination?: string;
757
+ otp_sent_to?: string;
683
758
  redirect_url?: string;
759
+ mastercardUrl?: string;
684
760
  [key: string]: unknown;
685
761
  }
686
762
  interface OtpVerifyResponse {
687
763
  success?: boolean;
688
764
  message?: string;
765
+ payment_id?: string;
689
766
  transaction_id?: string;
690
767
  status?: string;
691
768
  [key: string]: unknown;
@@ -693,7 +770,9 @@ interface OtpVerifyResponse {
693
770
  interface OtpResendResponse {
694
771
  success?: boolean;
695
772
  message?: string;
773
+ payment_id?: string;
696
774
  otp_destination?: string;
775
+ otp_sent_to?: string;
697
776
  }
698
777
 
699
778
  /**
@@ -787,6 +866,8 @@ interface LokotroTranslations {
787
866
  accountLabel: string;
788
867
  bankTransferProofInstructions: string;
789
868
  confirmBankTransfer: string;
869
+ redirectingIn: string;
870
+ tapToCancel: string;
790
871
  }
791
872
  declare class LokotroLocalizationService {
792
873
  private currentLanguageSubject;
@@ -816,9 +897,11 @@ declare class LokotroLocalizationService {
816
897
  */
817
898
  setLanguageByCode(code: string): void;
818
899
  /**
819
- * Get translation by key
900
+ * Get translation by key with optional interpolation
901
+ * @param key - Translation key
902
+ * @param params - Optional parameters for interpolation (e.g., { seconds: 3 })
820
903
  */
821
- translate(key: keyof LokotroTranslations): string;
904
+ translate(key: keyof LokotroTranslations, params?: Record<string, string | number>): string;
822
905
  /**
823
906
  * Get all supported languages
824
907
  */
@@ -862,8 +945,12 @@ declare class LokotroPayCheckoutComponent implements OnInit, OnDestroy {
862
945
  closed: EventEmitter<void>;
863
946
  state?: LokotroPaymentState;
864
947
  isDarkTheme: boolean;
948
+ private static readonly MAX_RETRY_ATTEMPTS;
949
+ private retryAttempts;
865
950
  private stateSubscription?;
866
951
  constructor(paymentService: LokotroPaymentService, localization: LokotroLocalizationService);
952
+ /** Check if user has retries left */
953
+ get hasRetriesLeft(): boolean;
867
954
  ngOnInit(): void;
868
955
  ngOnDestroy(): void;
869
956
  private initializeEnvironment;
@@ -887,6 +974,10 @@ declare class LokotroPayCheckoutComponent implements OnInit, OnDestroy {
887
974
  onRetry(): void;
888
975
  onDone(): void;
889
976
  onContinue(): void;
977
+ /** Handle auto-redirect from success screen */
978
+ onSuccessAutoRedirect(): void;
979
+ /** Handle auto-redirect from error screen (after retries exhausted) */
980
+ onErrorAutoRedirect(): void;
890
981
  static ɵfac: i0.ɵɵFactoryDeclaration<LokotroPayCheckoutComponent, never>;
891
982
  static ɵcmp: i0.ɵɵComponentDeclaration<LokotroPayCheckoutComponent, "lokotro-pay-checkout", never, { "title": { "alias": "title"; "required": false; }; "titleStyle": { "alias": "titleStyle"; "required": false; }; "titleBackgroundColor": { "alias": "titleBackgroundColor"; "required": false; }; "configs": { "alias": "configs"; "required": false; }; "paymentBody": { "alias": "paymentBody"; "required": false; }; "enableHapticFeedback": { "alias": "enableHapticFeedback"; "required": false; }; "backgroundColor": { "alias": "backgroundColor"; "required": false; }; "padding": { "alias": "padding"; "required": false; }; "themeConfig": { "alias": "themeConfig"; "required": false; }; "language": { "alias": "language"; "required": false; }; }, { "response": "response"; "error": "error"; "closed": "closed"; }, never, never, true, never>;
892
983
  }
@@ -1000,7 +1091,7 @@ declare class LokotroProcessingComponent {
1000
1091
  */
1001
1092
 
1002
1093
  type ResultType = 'success' | 'error' | 'warning' | 'info';
1003
- declare class LokotroResultComponent {
1094
+ declare class LokotroResultComponent implements OnInit, OnDestroy {
1004
1095
  localization: LokotroLocalizationService;
1005
1096
  type: ResultType;
1006
1097
  title: string;
@@ -1010,14 +1101,28 @@ declare class LokotroResultComponent {
1010
1101
  transactionId?: string;
1011
1102
  primaryActionLabel?: string;
1012
1103
  secondaryActionLabel?: string;
1104
+ /** Auto-redirect duration in seconds. If > 0, will auto-call onAutoRedirect after countdown. */
1105
+ autoRedirectSeconds: number;
1013
1106
  primaryAction: EventEmitter<void>;
1014
1107
  secondaryAction: EventEmitter<void>;
1108
+ /** Emitted when auto-redirect triggers after countdown completes. */
1109
+ autoRedirect: EventEmitter<void>;
1110
+ countdownSeconds: number;
1111
+ isCountdownCancelled: boolean;
1112
+ private countdownInterval?;
1015
1113
  constructor(localization: LokotroLocalizationService);
1114
+ ngOnInit(): void;
1115
+ ngOnDestroy(): void;
1116
+ private startAutoRedirectCountdown;
1117
+ cancelCountdown(): void;
1118
+ private clearCountdown;
1119
+ private triggerAutoRedirect;
1120
+ getCountdownProgress(): number;
1016
1121
  formatAmount(amount: number, currency?: string): string;
1017
1122
  onPrimaryClick(): void;
1018
1123
  onSecondaryClick(): void;
1019
1124
  static ɵfac: i0.ɵɵFactoryDeclaration<LokotroResultComponent, never>;
1020
- static ɵcmp: i0.ɵɵComponentDeclaration<LokotroResultComponent, "lokotro-result", never, { "type": { "alias": "type"; "required": false; }; "title": { "alias": "title"; "required": false; }; "message": { "alias": "message"; "required": false; }; "amount": { "alias": "amount"; "required": false; }; "currency": { "alias": "currency"; "required": false; }; "transactionId": { "alias": "transactionId"; "required": false; }; "primaryActionLabel": { "alias": "primaryActionLabel"; "required": false; }; "secondaryActionLabel": { "alias": "secondaryActionLabel"; "required": false; }; }, { "primaryAction": "primaryAction"; "secondaryAction": "secondaryAction"; }, never, never, true, never>;
1125
+ static ɵcmp: i0.ɵɵComponentDeclaration<LokotroResultComponent, "lokotro-result", never, { "type": { "alias": "type"; "required": false; }; "title": { "alias": "title"; "required": false; }; "message": { "alias": "message"; "required": false; }; "amount": { "alias": "amount"; "required": false; }; "currency": { "alias": "currency"; "required": false; }; "transactionId": { "alias": "transactionId"; "required": false; }; "primaryActionLabel": { "alias": "primaryActionLabel"; "required": false; }; "secondaryActionLabel": { "alias": "secondaryActionLabel"; "required": false; }; "autoRedirectSeconds": { "alias": "autoRedirectSeconds"; "required": false; }; }, { "primaryAction": "primaryAction"; "secondaryAction": "secondaryAction"; "autoRedirect": "autoRedirect"; }, never, never, true, never>;
1021
1126
  }
1022
1127
 
1023
1128
  declare class LokotroLoadingComponent {
@@ -1080,7 +1185,7 @@ declare class LokotroPayModule {
1080
1185
  defaultConfig: Partial<LokotroPayConfig>;
1081
1186
  }>): ModuleWithProviders<LokotroPayModule>;
1082
1187
  static ɵfac: i0.ɵɵFactoryDeclaration<LokotroPayModule, never>;
1083
- static ɵmod: i0.ɵɵNgModuleDeclaration<LokotroPayModule, never, [typeof i1.CommonModule, typeof i2.HttpClientModule, typeof i3.ReactiveFormsModule, typeof i3.FormsModule, typeof LokotroPayCheckoutComponent, typeof LokotroPaymentMethodSelectionComponent, typeof LokotroPaymentFormComponent, typeof LokotroOtpVerificationComponent, typeof LokotroProcessingComponent, typeof LokotroResultComponent, typeof LokotroLoadingComponent], [typeof LokotroPayCheckoutComponent, typeof LokotroPaymentMethodSelectionComponent, typeof LokotroPaymentFormComponent, typeof LokotroOtpVerificationComponent, typeof LokotroProcessingComponent, typeof LokotroResultComponent, typeof LokotroLoadingComponent]>;
1188
+ static ɵmod: i0.ɵɵNgModuleDeclaration<LokotroPayModule, never, [typeof i1.ReactiveFormsModule, typeof i1.FormsModule, typeof LokotroPayCheckoutComponent, typeof LokotroPaymentMethodSelectionComponent, typeof LokotroPaymentFormComponent, typeof LokotroOtpVerificationComponent, typeof LokotroProcessingComponent, typeof LokotroResultComponent, typeof LokotroLoadingComponent], [typeof LokotroPayCheckoutComponent, typeof LokotroPaymentMethodSelectionComponent, typeof LokotroPaymentFormComponent, typeof LokotroOtpVerificationComponent, typeof LokotroProcessingComponent, typeof LokotroResultComponent, typeof LokotroLoadingComponent]>;
1084
1189
  static ɵinj: i0.ɵɵInjectorDeclaration<LokotroPayModule>;
1085
1190
  }
1086
1191
 
@@ -1209,6 +1314,7 @@ declare class LokotroPayEnv {
1209
1314
  static get endpoints(): {
1210
1315
  collect: string;
1211
1316
  transaction: string;
1317
+ mobileMoneyStatus: string;
1212
1318
  submit: string;
1213
1319
  verifyOtp: string;
1214
1320
  resendOtp: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloonio/lokotro-pay",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Angular SDK for Lokotro Pay - Payment processing library with multiple payment methods",
5
5
  "keywords": [
6
6
  "angular",
@@ -18,9 +18,9 @@
18
18
  "url": "https://github.com/bloonio/lokotro-pay-angular.git"
19
19
  },
20
20
  "peerDependencies": {
21
- "@angular/common": "^17.0.0 || ^18.0.0 || ^19.0.0",
22
- "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0",
23
- "@angular/forms": "^17.0.0 || ^18.0.0 || ^19.0.0",
21
+ "@angular/common": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
22
+ "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
23
+ "@angular/forms": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
24
24
  "rxjs": "^7.8.0"
25
25
  },
26
26
  "dependencies": {