Ver código fonte

Payfast Fix

master
30117125 4 anos atrás
pai
commit
1ffccffc47

+ 34
- 22
src/components/financial/paymentOption.vue Ver arquivo

@@ -59,6 +59,9 @@ export default {
59 59
   computed: {
60 60
     ...mapGetters("fees", ["getListingFee"])
61 61
   },
62
+  created() {
63
+    console.log(this.week);
64
+  },
62 65
   methods: {
63 66
     ...mapActions("payment", ["addPayment"]),
64 67
     ...mapActions("myWeeks", ["editSave"]),
@@ -79,6 +82,11 @@ export default {
79 82
     },
80 83
     generatePayment(id) {
81 84
       var myData = [];
85
+      var date =
86
+        "From: " +
87
+        this.week.arrivalDate.substring(0, 10) +
88
+        " To " +
89
+        this.week.departureDate.substring(0, 10);
82 90
       // Merchant details
83 91
       myData["merchant_id"] = "10000100";
84 92
       myData["merchant_key"] = "46f0cd694581a";
@@ -92,12 +100,16 @@ export default {
92 100
       // Transaction details
93 101
       //myData["m_payment_id"] = "1234";
94 102
       myData["amount"] = this.getListingFee.amount.toString();
95
-      myData["item_name"] = id.toString();
103
+      myData["item_name"] = "Uni-Vate Week Sale. Reference: #" + id.toString();
104
+      myData["item_description"] = this.week.resortName;
105
+      myData["custom_str1"] = date;
106
+
96 107
       myData["signature"] = this.generateSignature(myData);
97 108
       //console.log(paymentObj);
98 109
       //axios.post("https://sandbox.payfast.co.za​/eng/process", paymentObj);
99 110
       //console.log(myData);
100 111
       var paymentObj = Object.assign({}, myData);
112
+      console.log("Twas here");
101 113
       console.log(paymentObj);
102 114
       this.$router.push({
103 115
         name: "PayFast",
@@ -125,28 +137,28 @@ export default {
125 137
       console.log(hash.hex());
126 138
       console.log(getString);
127 139
       return hash.toString();
128
-    },
129
-    paygateRedirect() {
130
-      var amount = this.getListingFee.amount;
131
-      var paymentObj = {
132
-        timeshareWeekId: this.week.id, // this.sellItem.Id,
133
-        propertyId: 0,
134
-        creatydById: Log.getUser().id, //Log.getUser().id,
135
-        amount: amount,
136
-        paymentStatus: "",
137
-        paymentToken: ""
138
-      };
139
-
140
-      this.addPayment(paymentObj).then(res => {
141
-        this.$router.push({
142
-          name: "PaymentGateway",
143
-          params: {
144
-            paymentReqId: res.PAY_REQUEST_ID,
145
-            checksum: res.CHECKSUM
146
-          }
147
-        });
148
-      });
149 140
     }
141
+    // paygateRedirect() {
142
+    //   var amount = this.getListingFee.amount;
143
+    //   var paymentObj = {
144
+    //     timeshareWeekId: this.week.id, // this.sellItem.Id,
145
+    //     propertyId: 0,
146
+    //     creatydById: Log.getUser().id, //Log.getUser().id,
147
+    //     amount: amount,
148
+    //     paymentStatus: "",
149
+    //     paymentToken: ""
150
+    //   };
151
+
152
+    //   this.addPayment(paymentObj).then(res => {
153
+    //     this.$router.push({
154
+    //       name: "PaymentGateway",
155
+    //       params: {
156
+    //         paymentReqId: res.PAY_REQUEST_ID,
157
+    //         checksum: res.CHECKSUM
158
+    //       }
159
+    //     });
160
+    //   });
161
+    // }
150 162
   }
151 163
 };
152 164
 </script>

+ 57
- 1
src/components/timeshare/sell/contentSectionNew.vue Ver arquivo

@@ -870,6 +870,7 @@ import addressAutoComplete from "../../shared/addressAutoComplete";
870 870
 import Alert from "../../shared/alert.vue";
871 871
 import Log from "../../../assets/Log";
872 872
 import _ from "lodash";
873
+import md5 from "js-md5";
873 874
 
874 875
 export default {
875 876
   name: "TimeshareToSell",
@@ -1000,6 +1001,57 @@ export default {
1000 1001
       var pubDate = new Date(fixedDate).toISOString();
1001 1002
       return pubDate;
1002 1003
     },
1004
+    generatePayment(id) {
1005
+      var myData = [];
1006
+      // Merchant details
1007
+      myData["merchant_id"] = "10000100";
1008
+      myData["merchant_key"] = "46f0cd694581a";
1009
+      myData["return_url"] = "https://www.univateproperties.co.za/#/payments/success";
1010
+      myData["cancel_url"] = "https://www.univateproperties.co.za/#/";
1011
+      myData["notify_url"] = "http://www.yourdomain.co.za/notify_url";
1012
+      // Buyer details
1013
+      myData["name_first"] = this.indiv.name;
1014
+      myData["name_last"] = this.indiv.surname;
1015
+      myData["email_address"] = this.indiv.emailAddress;
1016
+      // Transaction details
1017
+      //myData["m_payment_id"] = "1234";
1018
+      myData["amount"] = this.getListingFee.amount.toString();
1019
+      myData["item_name"] =
1020
+        "Uni-Vate Week sale. Resort: " + this.sellItem.resort + " Referemce: #" + id.toString();
1021
+      myData["signature"] = this.generateSignature(myData);
1022
+      //console.log(paymentObj);
1023
+      //axios.post("https://sandbox.payfast.co.za​/eng/process", paymentObj);
1024
+      //console.log(myData);
1025
+      var paymentObj = Object.assign({}, myData);
1026
+      console.log("Twas here");
1027
+      console.log(paymentObj);
1028
+      this.$router.push({
1029
+        name: "PayFast",
1030
+        params: {
1031
+          paymentObj: paymentObj
1032
+        }
1033
+      });
1034
+    },
1035
+    generateSignature(data, passPhrase = null) {
1036
+      let pfOutput = "";
1037
+      for (let key in data) {
1038
+        if (data.hasOwnProperty(key)) {
1039
+          if (data[key] !== "") {
1040
+            pfOutput += `${key}=${encodeURIComponent(data[key].trim()).replace(/%20/g, "+")}&`;
1041
+          }
1042
+        }
1043
+      }
1044
+
1045
+      let getString = pfOutput.slice(0, -1);
1046
+      if (passPhrase !== null) {
1047
+        getString += `&passphrase=${encodeURIComponent(passPhrase.trim()).replace(/%20/g, "+")}`;
1048
+      }
1049
+      var hash = md5.create();
1050
+      hash.update(getString);
1051
+      console.log(hash.hex());
1052
+      console.log(getString);
1053
+      return hash.toString();
1054
+    },
1003 1055
     submitSale() {
1004 1056
       this.boolError = false;
1005 1057
       if (this.userLoggedIn) {
@@ -1087,9 +1139,13 @@ export default {
1087 1139
         if (!this.boolError) {
1088 1140
           this.saveWeek(this.sellItem)
1089 1141
             .then(fulfilled => {
1090
-              // this.$router.push({ name: "PaymentOption", params: { week: fulfilled, indiv: this.indiv } });
1142
+              // this.$router.push({
1143
+              //   name: "PaymentOption",
1144
+              //   params: { week: fulfilled, indiv: this.indiv }
1145
+              // });
1091 1146
               this.$router.push({ name: "EFTPage", params: { week: fulfilled } });
1092 1147
               //this.paygateRedirect();
1148
+              //this.generatePayment(fulfilled.id);
1093 1149
             })
1094 1150
             .catch(ex => {
1095 1151
               this.errorOccurred = "ERRORHTML";

Carregando…
Cancelar
Salvar