From 57e9cc7ec897bc9c6d24d8d29df1e056ffcbe766 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Sat, 27 May 2023 11:47:29 +0530 Subject: [PATCH] payment gateway intergration --- .../booking-summary.component.html | 10 +- .../booking-summary.component.ts | 125 ++++++-- .../customer-info.component.html | 172 ++++++++++- .../customer-info/customer-info.component.ts | 271 ++++++++++++++++-- ng-seed/src/app/end-user/end-user.service.ts | 18 ++ .../app/end-user/payment/payment.component.ts | 5 +- .../slot-booking-details.component.ts | 3 +- ng-seed/src/environments/environment.ts | 4 +- 8 files changed, 552 insertions(+), 56 deletions(-) diff --git a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html index b4b4c52..e7a39b8 100644 --- a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html +++ b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html @@ -22,14 +22,16 @@
+

Your appointment has been successfully registered.

-

- An email with the appointment details has been sent to you.

+

+ Thank You..! Your order status is {{resPayment.response_message}}. + Your Transaction ID for this transaction is {{resPayment.transaction_id}}. + We have received a payment of Rs {{resPayment.amount}}

- - Please check your spam folder if the email does not arrive within a few minutes. +

diff --git a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts index 7869b97..bd628cb 100644 --- a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts +++ b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts @@ -19,6 +19,7 @@ export class BookingSummaryComponent implements OnInit { busName: any; logo: any; currency:any =[]; + resPayment:any=[]; private apiUrl = environment.apiEndpoint; customerBookingDetails: any = []; busCurrency: any = []; @@ -35,7 +36,7 @@ export class BookingSummaryComponent implements OnInit { console.log(URL) let URL_AS_LIST = URL.split('/'); console.log(URL_AS_LIST); - this.router.navigate(['customer/business/'+URL_AS_LIST[3]]) + // this.router.navigate(['customer/business/'+URL_AS_LIST[3]]) } }) @@ -43,29 +44,113 @@ export class BookingSummaryComponent implements OnInit { } ngOnInit() { + + let slot_array = JSON.parse(localStorage.getItem("slotData")) + + + let service = localStorage.getItem("servicedetails") + let serviceDetails = JSON.parse(service) + console.log(serviceDetails) + + let URL = this.router.url; + console.log(URL,slot_array) + let URL_AS_LIST = URL.split('/'); + console.log(URL_AS_LIST); + // if(serviceDetails.hasOwnProperty('userId')){ + serviceDetails.userId = localStorage.getItem('user_id') + let paramPay = {"cusId":URL_AS_LIST[9]} + this.end_user.paymentstatus(paramPay).subscribe(resPay => { + + + if (resPay.status == 200) { + console.log(resPay) + this.resPayment = resPay.data[0] + + + // } + let paramsmap= { + "serviceId": ""+serviceDetails.serviceId+"", + "userId": serviceDetails.userId, + "busId": serviceDetails.busId + } + console.log(paramsmap) + this.end_user.CreatecusServicesMapDetails(paramsmap).subscribe(res => { + if (res.status == 200) { + console.log(res) + let serviceMap = res['data'][0].id + let time = new Date().toLocaleTimeString() + let params= { + "busId": serviceDetails.busId, + "cusId": URL_AS_LIST[9], + "appoinmentDate": slot_array[0].date, + "appoinmentTime": time, + "serviceMap": serviceMap, + "appoinmentSlots": JSON.stringify(slot_array[0].slots) + //"servicemap" :this.bookedAppointment_servicemap + } + console.log(params) + this.end_user.CreateAppoinmentsCus(params).subscribe(res => { + if (res.status == 200) { + console.log(res) + res = res.data; + // this.end_user.summmarylist.next(res.data) + console.log('booked2', res); + this.customerBookingDetails = res[0].customer[0] + console.log(this.customerBookingDetails) + this.bookingSummary = res[0] + if(this.bookingSummary.appoinmentSlots instanceof Array){ + this.bookingSummary.appoinmentSlots =this.bookingSummary.appoinmentSlots + }else{ + this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) + } + // this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) + + // this.end_user.getcusServicesMapDetails() + let param ={id:this.bookingSummary.serviceMap} + this.end_user.getcusServicesMapDetails(param).subscribe(res => { + if (res.status == 200) { + console.log(res) + this.serviceMapDetails = res['data'][0] + this.busCurrency = this.serviceMapDetails['business'][0].currency + + } + }) + + // localStorage.setItem('summarylist',JSON.stringify(res.data)) + // this.router.navigate([URL+"/bts"]) + } + }) + + } + + }) + + } + }) + this.currency = localStorage.getItem('currency') this.end_user.summmarylist_observable$.subscribe((res) => { - console.log('booked2', res); - this.customerBookingDetails = res[0].customer[0] - console.log(this.customerBookingDetails) - this.bookingSummary = res[0] - if(this.bookingSummary.appoinmentSlots instanceof Array){ - this.bookingSummary.appoinmentSlots =this.bookingSummary.appoinmentSlots - }else{ - this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) - } - // this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) + // console.log('booked2', res); + // this.customerBookingDetails = res[0].customer[0] + // console.log(this.customerBookingDetails) + // this.bookingSummary = res[0] + // if(this.bookingSummary.appoinmentSlots instanceof Array){ + // this.bookingSummary.appoinmentSlots =this.bookingSummary.appoinmentSlots + // }else{ + // this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) + // } + // // this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) - // this.end_user.getcusServicesMapDetails() - let param ={id:this.bookingSummary.serviceMap} - this.end_user.getcusServicesMapDetails(param).subscribe(res => { - if (res.status == 200) { - console.log(res) - this.serviceMapDetails = res['data'][0] - this.busCurrency = this.serviceMapDetails['business'][0].currency + // // this.end_user.getcusServicesMapDetails() + // let param ={id:this.bookingSummary.serviceMap} + // this.end_user.getcusServicesMapDetails(param).subscribe(res => { + // if (res.status == 200) { + // console.log(res) + // this.serviceMapDetails = res['data'][0] + // this.busCurrency = this.serviceMapDetails['business'][0].currency - } - }) + // } + // }) }) } diff --git a/ng-seed/src/app/end-user/customer-info/customer-info.component.html b/ng-seed/src/app/end-user/customer-info/customer-info.component.html index de53c1b..33912b3 100644 --- a/ng-seed/src/app/end-user/customer-info/customer-info.component.html +++ b/ng-seed/src/app/end-user/customer-info/customer-info.component.html @@ -16,13 +16,13 @@

Customer Information

-
+
-
+ + Email is required @@ -87,14 +87,167 @@ City is required Limit exceed -
+
--> + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- +

AvatarPractitioner

{{bookedDetails.doctor}}

Avatar Service

@@ -105,15 +258,12 @@ {{bookedDetails.time | date:'shortTime'}}

AvatarAmount

{{currency}} {{bookedDetails.amount}} - +
- +
diff --git a/ng-seed/src/app/end-user/customer-info/customer-info.component.ts b/ng-seed/src/app/end-user/customer-info/customer-info.component.ts index 7975eb2..02b8ca8 100644 --- a/ng-seed/src/app/end-user/customer-info/customer-info.component.ts +++ b/ng-seed/src/app/end-user/customer-info/customer-info.component.ts @@ -1,4 +1,4 @@ -import { Component, HostListener, NgZone, OnInit } from '@angular/core'; +import { Component, HostListener, NgZone, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, RequiredValidator, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { EndUserService } from '../end-user.service'; @@ -41,7 +41,12 @@ export class CustomerInfoComponent implements OnInit { noChangeNo: any = 0; private apiUrl = environment.apiEndpoint; logo: any; + formData:any =[]; + url ="https://api.payaidpayments.com/v2/paymentrequest"; + paymentform:any=[]; + bookedDetails: any = []; + @ViewChild('testForm') testFormEl; constructor(private _location: Location,public dialog: MatDialog,private router: Router,private formBuilder: FormBuilder,public _cus:EndUserService, private ngZone: NgZone) { this._cus.bookedDetails_observable$.subscribe((res) => { console.log('booked2', res); @@ -49,25 +54,76 @@ export class CustomerInfoComponent implements OnInit { console.log(this.bookedDetails) }) + this.formData= new FormData(); // firebase.initializeApp(config) } ngOnInit() { + let URL = this.router.url; + console.log(URL) + let URL_AS_LIST = URL.split('/'); + console.log(URL_AS_LIST); this.busName = localStorage.getItem('busName') this.currency = localStorage.getItem('currency') this.logo = localStorage.getItem('logo') this.form = new FormGroup({ - cusName: new FormControl('', [Validators.required]), - email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( - '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', - ),]), - phoneNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]), - address_1: new FormControl('', [Validators.required,Validators.maxLength(100)]), - city: new FormControl('',[Validators.required]), - state: new FormControl('',[Validators.required]), - otp: new FormControl('', [ Validators.maxLength(6),Validators.minLength(6)]), - pincode: new FormControl('',[Validators.required]), + api_key:new FormControl('', [Validators.required]), + hash:new FormControl('', []), + amount: new FormControl('', []), + name: new FormControl('', [Validators.required]), + email: new FormControl('', [Validators.required]), + phone: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]), + address_line_1: new FormControl('', [Validators.required]), + address_line_2:new FormControl('', []), + order_id: new FormControl('', []), + description: new FormControl('', []), + mode: new FormControl('', []), + return_url: new FormControl('', []), + currency: new FormControl('', []), + country: new FormControl('', []), + zip_code: new FormControl('', []), + state: new FormControl('', []), + city: new FormControl('', []), + udf1: new FormControl('', []), + udf2: new FormControl('', []), + udf3: new FormControl('', []), + udf4: new FormControl('', []), + udf5:new FormControl('', []) + // cusName: new FormControl('', [Validators.required]), + // email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( + // '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', + // ),]), + // phoneNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]), + // address_1: new FormControl('', [Validators.required,Validators.maxLength(100)]), + // city: new FormControl('',[Validators.required]), + // state: new FormControl('',[Validators.required]), + // otp: new FormControl('', [ Validators.maxLength(6),Validators.minLength(6)]), + // pincode: new FormControl('',[Validators.required]), }); + let busId = localStorage.getItem('busId') + function generateRandomString() { + const prefix = "ORD-"; + const randomNum = (Math.random() + 1).toString(36).substring(7); + return prefix + randomNum; + } + let payment = { + api_key: '4cb964d4-9ef4-4a25-8f85-a2a13f43cbba', + hash: '', + amount: ""+this.bookedDetails.amount+"", + order_id: generateRandomString(), + description: 'testing', + mode: 'TEST', + return_url: 'http://localhost:8080/api/paymentResponse', + currency: 'INR', + country: 'IND', + udf1: ''+busId+'', + udf2: ''+window.location.origin+'/#'+URL+'/', + udf3: '', + udf4: '', + udf5: '' + } + + this.form.patchValue(payment) } public myError = (controlName: string, errorName: string) =>{ @@ -75,15 +131,58 @@ export class CustomerInfoComponent implements OnInit { } submit(){ + let row_obj = this.form.value + let payment = { + + amount: this.bookedDetails.amount, + name: row_obj.cusName, + email: row_obj.email, + phone: row_obj.phoneNo, + address_line_1: row_obj.address_1, + address_line_2: row_obj.address_1, + // order_id: 'r959659swd', + // description: 'testing', + // mode: 'TEST', + // return_url: 'http://localhost:8080/api/paymentResponse', + currency: 'INR', + country: 'IND', + zip_code: row_obj.pincode, + state: row_obj.state, + city: row_obj.city, + udf1: '', + udf2: '', + udf3: '', + udf4: '', + udf5: '' + } + + // this.formData.append('amount', this.bookedDetails.amount); + // this.formData.append('name', row_obj.cusName); + // this.formData.append('email', row_obj.email); + // this.formData.append('phone', row_obj.phoneNo); + // this.formData.append('address_line_1', row_obj.address_1); + // this.formData.append('address_line_2', row_obj.address_1); + // this.formData.append('currency', 'INR'); + // this.formData.append('country', 'IND'); + // this.formData.append('zip_code', row_obj.pincode); + // this.formData.append('state', row_obj.state); + // this.formData.append('city', row_obj.city); + // this.formData.append('udf1', ''); + // this.formData.append('udf2', ''); + // this.formData.append('udf3', ''); + // this.formData.append('udf4', ''); + // this.formData.append('udf5', ''); + console.log(this.form.value) console.log('add') if(!this.form.valid && this.verifyOTP == 0){ return }else { if(this.verifyOTP == 1){ - let row_obj = this.form.value + console.log(row_obj) let busId = localStorage.getItem('busId') + let addFormData = { busId: busId, cusName: row_obj.cusName, @@ -96,15 +195,64 @@ export class CustomerInfoComponent implements OnInit { }; console.log(addFormData) - this._cus.addCusDetails(addFormData).subscribe(res => { - if (res.status == 200) { + this._cus.paymentRequest(payment).subscribe(res => { + if (res) { console.log(res) + res =res.data + // api_key: '4cb964d4-9ef4-4a25-8f85-a2a13f43cbba', + // hash: '', + this.formData.append('api_key', res.api_key); + this.formData.append('hash', res.hash); + + this.formData.append('order_id', res.order_id); + this.formData.append('description', res.description); + this.formData.append('mode', res.mode); + this.formData.append('return_url', res.return_url); + + + // order_id: 'r959659swd', + // description: 'testing', + // mode: 'TEST', + // return_url: 'http://localhost:8080/api/paymentResponse', + + + + this.formData.append('amount', res.amount); + this.formData.append('name',res.name); + this.formData.append('email', res.email); + this.formData.append('phone', res.phone); + this.formData.append('address_line_1', res.address_line_1); + this.formData.append('address_line_2', res.address_line_1); + this.formData.append('currency', 'INR'); + this.formData.append('country', 'IND'); + this.formData.append('zip_code', res.zip_code); + this.formData.append('state', res.state); + this.formData.append('city', res.city); + this.formData.append('udf1', ''); + this.formData.append('udf2', ''); + this.formData.append('udf3', ''); + this.formData.append('udf4', ''); + this.formData.append('udf5', ''); + + + // this._cus.paymentRequestApi(this.paymentform).subscribe(res => { + // console.log(res) + // if (res) { + // console.log(res) + + // // let URL = this.router.url; + // // console.log(URL) + // // this.router.navigate([URL+"/"+res['data'].id+"/pt"]) + // } + // }); - let URL = this.router.url; - console.log(URL) - this.router.navigate([URL+"/"+res['data'].id+"/pt"]) + // let URL = this.router.url; + // console.log(URL) + // this.router.navigate([URL+"/"+res['data'].id+"/pt"]) } }); + + } else{ this.getOTP(1) } @@ -191,4 +339,93 @@ export class CustomerInfoComponent implements OnInit { return this.apiUrl+'imageViewer?img_name='+image; } + + onclickfun(){ + console.log("worked") + let row_obj = this.form.value + function generateRandomString() { + const prefix = "ORD-"; + const randomNum = (Math.random() + 1).toString(36).substring(7); + return prefix + randomNum; + } + let payment = { + api_key: "4cb964d4-9ef4-4a25-8f85-a2a13f43cbba", + hash: '', + amount: this.bookedDetails.amount, + name: row_obj.cusName, + email: row_obj.email, + phone: row_obj.phoneNo, + address_line_1: row_obj.address_1, + address_line_2: row_obj.address_1, + order_id: generateRandomString(), + description: 'testing', + mode: 'TEST', + return_url: 'http://localhost:8080/api/paymentResponse', + currency: 'INR', + country: 'IND', + zip_code: row_obj.pincode, + state: row_obj.state, + city: row_obj.city, + udf1: '', + udf2: '', + udf3: '', + udf4: '', + udf5: '' + } + let busId = localStorage.getItem('busId') + + let addFormData = { + busId: busId, + cusName: this.form.value.name, + email: this.form.value.email, + address_1: this.form.value.address_line_1, + phoneNo: this.form.value.phone, + pincode: this.form.value.zip_code, + state: this.form.value.state, + city: this.form.value.city, + }; + console.log(addFormData) + + this._cus.paymentRequest(this.form.value ).subscribe(res => { + +console.log(this.form.value , res) + + +//this._cus.addCusDetails(addFormData).subscribe(res1 => { + //if (res1.status == 200) { + // console.log(res1) + + // let URL = this.router.url; + // console.log(URL) + this.form.controls['hash'].setValue(res.data) + this.testFormEl.nativeElement.submit() + //let cusId = ''+res1['data'].id+''; +// this.form.controls['udf2'].setValue(""+cusId+"") + + + // this.form.controls['udf1'].setValue(cusId) +// this.form.controls['udf1'].setValue( this.form.value.udf1) + +// console.log(this.form.value,cusId ,this.form.value.udf1) +// setTimeout(() => { + +// }, 500); + + // this.router.navigate([URL+"/"+res['data'].id+"/pt"]) + // } +//}); + + + +console.log(this.form.value , res) +payment.hash = res.data + console.log(res) +this.paymentform = payment; +// + } + + ) + // + } + } diff --git a/ng-seed/src/app/end-user/end-user.service.ts b/ng-seed/src/app/end-user/end-user.service.ts index 4ec2ab0..f38700c 100644 --- a/ng-seed/src/app/end-user/end-user.service.ts +++ b/ng-seed/src/app/end-user/end-user.service.ts @@ -49,6 +49,24 @@ private apiUrl = environment.apiEndpoint; // catchError(this.handleError('role', [])) // ) } + + + paymentRequest(Params): Observable { + return this._http.post(this.apiUrl + 'paymentRequest', Params) + + } + + paymentstatus(Params): Observable { + return this._http.post(this.apiUrl + 'paymentStatus', Params) + + } + + + + paymentRequestApi(Params): Observable { + return this._http.post('https://api.payaidpayments.com/v2/paymentrequest', Params) + + } addCusDetails(addParams): Observable { return this._http.post(this.apiUrl + 'CreateCustomers', addParams) // .pipe( diff --git a/ng-seed/src/app/end-user/payment/payment.component.ts b/ng-seed/src/app/end-user/payment/payment.component.ts index 5839d44..31863ca 100644 --- a/ng-seed/src/app/end-user/payment/payment.component.ts +++ b/ng-seed/src/app/end-user/payment/payment.component.ts @@ -34,7 +34,10 @@ export class PaymentComponent implements OnInit { this.router.navigate(['customer/'+URL_AS_LIST[2]+'/'+URL_AS_LIST[3]]) } }) - + this.router.getCurrentNavigation().extras; + console.log( this.router.getCurrentNavigation().extras) + console.log( this.route.snapshot.paramMap) + } diff --git a/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts b/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts index 0c878a5..bf8d49c 100644 --- a/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts +++ b/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts @@ -254,8 +254,9 @@ if(this.getHours.length != 0){ this.slotIndex = i this.slotTime = param - console.log(this.date,param) + console.log(this.date,param,this.servicesName.duration) let thirtyMinutes = this.servicesName.duration * 60 * 1000; // convert 30 minutes to milliseconds + console.log(thirtyMinutes) let date1 = new Date(param); let date2 = new Date(date1.getTime() + thirtyMinutes); console.log(date1); diff --git a/ng-seed/src/environments/environment.ts b/ng-seed/src/environments/environment.ts index 4f1b2f3..6abbc6e 100644 --- a/ng-seed/src/environments/environment.ts +++ b/ng-seed/src/environments/environment.ts @@ -7,12 +7,12 @@ export const environment = { production: false, environmentName: 'Testing Environment',//Localhost Environment. // apiEndpoint:'http://venbainfotech.com:5000/api/', - // apiEndpoint:'http://192.168.1.19:8080/api/', + apiEndpoint:'http://192.168.1.10:8080/api/', // apiEndpoint:'https://api.venbait.in/api/', // apiEndpoint:'http://venbainfotech.com:5000/api/', // apiEndpoint:'http://192.168.1.19:8080/api/', - apiEndpoint:'https://api.venbait.in/api/', + // apiEndpoint:'https://api.venbait.in/api/', //EndUser URL endUserUrl: window.location.origin+'/#/customer/',