From 7c5ae9c333c22f03c13f45682a02eb1246a7998a Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 12 Feb 2024 12:15:08 -0500 Subject: [PATCH] add credit --- .../accounts/addcredit/addcredit.page.html | 7 + src/app/accounts/addcredit/addcredit.page.ts | 136 +++++++++++++++--- 2 files changed, 122 insertions(+), 21 deletions(-) diff --git a/src/app/accounts/addcredit/addcredit.page.html b/src/app/accounts/addcredit/addcredit.page.html index a92e181..3ae8d28 100644 --- a/src/app/accounts/addcredit/addcredit.page.html +++ b/src/app/accounts/addcredit/addcredit.page.html @@ -182,6 +182,7 @@ @@ -207,6 +209,7 @@ @@ -220,6 +223,7 @@ @@ -262,6 +266,9 @@ + + + diff --git a/src/app/accounts/addcredit/addcredit.page.ts b/src/app/accounts/addcredit/addcredit.page.ts index 52feddf..97e272a 100644 --- a/src/app/accounts/addcredit/addcredit.page.ts +++ b/src/app/accounts/addcredit/addcredit.page.ts @@ -308,6 +308,11 @@ export class AddcreditPage implements OnInit { payment_card: string = ""; selPaymentCard: any; + cardnumber:string=''; + cvc:string=''; + exp_month:string=''; + exp_year:string=''; + feeReturn: any; veriyEntry(){ @@ -338,23 +343,46 @@ export class AddcreditPage implements OnInit { if (this.total > 100 && this.processor == 3030) { this.isDisabled = false; } - if (this.total > 5 && this.processor == 5000 && this.payment_card != "") { + + if ( this.card_level == 200 && this.total > 5 && this.processor == 5000 && this.payment_card != "") { this.selPaymentCard = this.usersCardsData.filter( (item) => item.card_uid == this.payment_card )[0]; this.isDisabled = false; } + + if ( this.card_level == 400 && this.total > 5 + && this.processor == 5000 + && this.cardnumber.toString().length == 16 + && this.cvc.toString().length == 3 + && this.exp_month.toString() !='' + && this.exp_year.toString() != '' + ) { + this.isDisabled = false; + } // } // } // ); // this.total = this.fee + this.amount; } + myWallet() { + this.router.navigate(["tabs/tab4"]); + } + credit_confirmation: string = ""; - creditResult: any; async processPayment(processor) { + if (this.card_level == 200){ + return this.processPaymentPreviousCard(processor); + } + if (this.card_level == 400){ + return this.processPaymentNewCard(processor); + } + } + + async processPaymentNewCard(processor) { this.credit_confirmation = ""; const loading = await this.loadingCtrl.create({ message: "Processing...", @@ -382,29 +410,95 @@ export class AddcreditPage implements OnInit { loading.present(); this.wrenchService - .payPrevCard(this.payPevCreditData) - .subscribe((creditResult) => { - loading.dismiss(); - console.log("creditResult TOTAL RETURN->", this.creditResult); - if ( - creditResult != undefined && - creditResult.internal_return > 0 && - creditResult.confirmation != "" - ) { - this.userWalletService.getWalletData(); // refresh the wallet - this.credit_confirmation = creditResult.confirmation; - this.showCrediAlert("Credit Processing", "Completed"); + .payPrevCard(this.payPevCreditData) + .subscribe((creditResult) => { + loading.dismiss(); + console.log("creditResult TOTAL RETURN->", this.creditResult); + if ( + creditResult != undefined && + creditResult.internal_return > 0 && + creditResult.confirmation != "" + ) { + this.userWalletService.getWalletData(); // refresh the wallet + this.credit_confirmation = creditResult.confirmation; + this.showCrediAlert("Credit Processing", "Completed"); - setTimeout(() => { - // this.setCloseModal(); - }, 5000); - } - }); + setTimeout(() => { + // this.setCloseModal(); + }, 5000); + } + }); } } - myWallet() { - this.router.navigate(["tabs/tab4"]); + + payNewCreditData: { + member_id: number; + sessionid: string; + uid: string; + currency: string; + amount: number; + credit_reference: string; + cardnumber: string, + cvc: string, + exp_month: string, + exp_year: string, + paymenttype: string, + description: string, + action: number; + }; + async processPaymentPreviousCard(processor) { + this.credit_confirmation = ""; + const loading = await this.loadingCtrl.create({ + message: "Processing...", + duration: 3500, + }); + + if (this.processor == 3030) { + // debugger; + loading.present(); + this.payViaPromise(); + return 0; + } + if (this.processor == 5000) { + this.isProcessDisabled = true; + this.payNewCreditData = { + member_id: this.sessionDataProviderService.member_id, + sessionid: this.sessionDataProviderService.session, + uid: this.sessionDataProviderService.member_uid, + currency: this.currency_code, + amount: this.startCreditResult.amount, + credit_reference: this.startCreditResult.credit_reference, + cardnumber: this.cardnumber, + cvc: this.cvc, + exp_month: this.exp_month, + exp_year: this.exp_year, + paymenttype: '100', + description:'', + action: 11056, + }; + + loading.present(); + this.wrenchService + .payPrevCard(this.payNewCreditData) + .subscribe((creditResult) => { + loading.dismiss(); + console.log("creditResult TOTAL RETURN->", this.creditResult); + if ( + creditResult != undefined && + creditResult.internal_return > 0 && + creditResult.confirmation != "" + ) { + this.userWalletService.getWalletData(); // refresh the wallet + this.credit_confirmation = creditResult.confirmation; + this.showCrediAlert("Credit Processing", "Completed"); + + setTimeout(() => { + // this.setCloseModal(); + }, 5000); + } + }); + } } payPevCreditData: {