diff --git a/src/pages/buy/buy.html b/src/pages/buy/buy.html index ab46543..a026b54 100644 --- a/src/pages/buy/buy.html +++ b/src/pages/buy/buy.html @@ -23,7 +23,7 @@ N° de carte - + @@ -31,17 +31,36 @@ - - Date d'expiration - - + + + + + + + Date d'expiration + + + + + + / + + + + + + + + + + Cryptogramme - + - + diff --git a/src/pages/buy/buy.ts b/src/pages/buy/buy.ts index 58b2b96..8cefda3 100644 --- a/src/pages/buy/buy.ts +++ b/src/pages/buy/buy.ts @@ -23,19 +23,75 @@ export class BuyPage { console.log('ionViewDidLoad BuyPage'); } - sendTransaction($amount) { - //TODO : Contacter l'API et proposer la transaction. L'API répondra true ou False - if (true === true) { - this.navCtrl.popToRoot(); + sendTransaction($cardnumber, $month, $year, $cryp, $amount) { + if (typeof $cardnumber !== 'undefined' && typeof $month !== 'undefined' && typeof $year !== 'undefined' && typeof $cryp !== 'undefined' && typeof $amount !== 'undefined' ) { + if (this.checkFields($cardnumber, $month, $year, $cryp)) { + //TODO : Contacter l'API et proposer la transaction. L'API répondra true ou False + if (true === true) { + this.navCtrl.popToRoot(); + } + else { + const alert = this.alertCtrl.create({ + title: 'Erreur', + subTitle: 'La transaction a échoué. Vérifiez les données saisies et réessayez.', + buttons: ['OK'] + }); + alert.present(); + } + } } else { const alert = this.alertCtrl.create({ - title: 'Erreur', - subTitle: 'La transaction a échoué. Vérifiez les données saisies et réessayez.', + title: 'Champs vides', + subTitle: 'Merci de remplir tous les champs', buttons: ['OK'] }); alert.present(); } } + //Vérification des champs + checkFields(cardnumber, month, year, cryp) { + if (!this.checkCardInfoIntegrity(12, 19, cardnumber) || !this.checkCardInfoIntegrity(3, 4, cryp) || !this.checkCardInfoValue(0, 9999, cryp)) { + const alert = this.alertCtrl.create({ + title: 'Erreur', + subTitle: 'Le numéro de carte bancaire est erroné. Vérifiez les données et recommencez.', + buttons: ['OK'] + }); + alert.present(); + return false; + } + else if (!this.checkCardInfoIntegrity(1, 2, month) || !this.checkCardInfoValue(1, 12, month) || !this.checkCardInfoIntegrity(4, 4, year) || !this.checkCardInfoValue(2018, 2050, year)) { + const alert = this.alertCtrl.create({ + title: 'Erreur', + subTitle: 'La date est erronée. Vérifiez les données et recommencez.', + buttons: ['OK'] + }); + alert.present(); + return false; + } + else { + return true; + } + } + checkCardInfoIntegrity($min, $max, $number) { + $number = parseInt($number); + if ($number.length < $min || $number.length > $max) { + return false; + } + else { + return true; + } + } + + checkCardInfoValue($min, $max, $number) { + $number = parseInt($number); + if ($number < $min || $number > $max) { + return false; + } + else { + return true; + } + } + } diff --git a/src/pages/home/home.html b/src/pages/home/home.html index 977b105..775d37e 100644 --- a/src/pages/home/home.html +++ b/src/pages/home/home.html @@ -8,9 +8,6 @@ Mon compte - - - @@ -32,6 +29,7 @@ + diff --git a/src/pages/transactions/transactions.html b/src/pages/transactions/transactions.html index fa2c467..a0a6f85 100644 --- a/src/pages/transactions/transactions.html +++ b/src/pages/transactions/transactions.html @@ -7,7 +7,7 @@ - transactions + Dernières transactions @@ -28,4 +28,70 @@ + + + +

Virement reçu

+
+ +

Date : 2 novembre 2018

+

De : Jean-Charles DUTROU

+

Montant : 45 G

+
+ +
+ + + + +

Virement émis

+
+ +

Date : 31 octobre 2018 13:30:03

+

À : Docteur FREUD

+

Montant : 150 G

+
+ +
+ + + + +

Paiement

+
+ +

Date : 30 novembre 2018 22:12:35

+

À : Bar de la CUITTHE

+

Montant : 5 G

+
+ +
+ + + + +

Paiement

+
+ +

Date : 30 novembre 2018 21:23:35

+

À : Bar de la CUITTHE

+

Montant : 5 G

+
+ +
+ + + + +

Paiement

+
+ +

Date : 30 novembre 2018 20:45:35

+

À : Bar de la CUITTHE

+

Montant : 5 G

+
+ +
+ +