wenliming 2 anni fa
parent
commit
40bda03434

+ 18 - 1
src/http/account.js

@@ -50,4 +50,21 @@ export function getFrontConfig(params) {
     method: 'post',
     data: params
   })
-}
+}
+
+export function usdRechargeRequestByAchpay(params) {
+  return service({
+    url: `/wallet/recharge/usdRechargeRequestByAchpay`,
+    method: 'post',
+    data: params
+  })
+}
+
+export function calcRechargePayAmount(params) {
+  return service({
+    url: `/wallet/pay/calcRechargePayAmount`,
+    method: 'post',
+    data: params
+  })
+}
+

+ 1 - 1
src/http/configAPI.js

@@ -1,4 +1,4 @@
-export const appVersionCode = 14
+export const appVersionCode = 16
 
 const api = {
 	production: 'https://api.denetme.net',

+ 6 - 0
src/iframe/ach-cashier.js

@@ -0,0 +1,6 @@
+import { createApp } from 'vue'
+import App from '@/view/iframe/ach-pay/cashier.vue'
+
+const app = createApp(App);
+
+app.mount('#app');

+ 2 - 1
src/manifest.json

@@ -96,7 +96,8 @@
                 "/iframe/tab-group.html",
                 "/iframe/joined-group-list.html",
                 "/iframe/tool-box-guide.html",
-                "/iframe/test.html"
+                "/iframe/test.html",
+                "/iframe/ach-cashier.html"
             ],
             "matches": [
                 "<all_urls>"

+ 1 - 1
src/view/components/currency-list.vue

@@ -36,7 +36,7 @@
                                 <img class="icon-currency" :src="data.currencies[0].iconPath" />
                                 <div class="currency-info">
                                     <div class="name">{{ data.currencies[0].currencyCode == 'USD' ? 'USD' : data.currencies[0].tokenSymbol }}</div>
-                                    <div class="desc">{{ data.currencies[0].currencyCode == 'USD' ? 'Paypal' : data.currencies[0].currencyName }}
+                                    <div class="desc">{{ data.currencies[0].currencyName }}
                                     </div>
                                 </div>
                             </div>

+ 75 - 0
src/view/iframe/ach-pay/cashier.vue

@@ -0,0 +1,75 @@
+<template>
+    <div class="cashier-wrapper">
+        <form ref="formDom" :action="pageData.formData.actionUrl" method="post" id="submitForm">
+            <input type="hidden" name="callbackUrl" :value="pageData.formData.callbackUrl">
+            <input type="hidden" name="currency" :value="pageData.formData.currency">
+            <input type="hidden" name="merType" :value="pageData.formData.merType">
+            <input type="hidden" name="merchantNo" :value="pageData.formData.merchantNo">
+            <input type="hidden" name="merchantOrderNo" :value="pageData.formData.merchantOrderNo">
+            <input type="hidden" name="noticeUrl" :value="pageData.formData.noticeUrl">
+            <input type="hidden" name="orderAmount" :value="pageData.formData.orderAmount">
+            <input type="hidden" name="productDetail" :value="pageData.formData.productDetail">
+            <input type="hidden" name="sign" :value="pageData.formData.sign">
+            <input type="hidden" name="timeStamp" :value="pageData.formData.timeStamp">
+            <input type="hidden" name="version" :value="pageData.formData.version">
+        </form>
+    </div>
+</template>
+
+<script setup>
+import { onMounted, ref, reactive, nextTick } from "vue";
+import {usdRechargeRequestByAchpay} from "@/http/account"
+import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
+
+let formDom = ref(null);
+
+let pageData = reactive({
+    formData: {
+        actionUrl: '',
+        callbackUrl: '',
+        currency: '',
+        merType: '',
+        merchantNo: '',
+        merchantOrderNo: '',
+        noticeUrl: '',
+        orderAmount: '',
+        productDetail: '',
+        sign: '',
+        timeStamp: '',
+        version: '',
+    }
+})
+
+const getLocalPayInfo = async () => {
+    let payInfo = await getChromeStorage('achPayInfo');
+
+    console.log(payInfo,'payInfo');
+    if(payInfo) {
+        chrome.storage.local.remove("achPayInfo");
+        usdRechargeRequestByAchpay({
+            params: {
+                amountValue: payInfo.amountValue
+            }
+        }).then(res => {
+            if(res.code == 0) {
+                pageData.formData = res.data;
+                nextTick(() => {
+                    console.log('form', formDom.value,   pageData.formData);
+                    formDom.value && formDom.value.submit();
+                })
+            }
+        })
+    }
+}
+
+
+onMounted(() => {
+    getLocalPayInfo();
+}) 
+
+</script>
+
+<style scoped lang="scss">
+.cashier-wrapper {
+}
+</style>

+ 20 - 18
src/view/iframe/publish/components/paypal-button.vue → src/view/iframe/publish/components/pay-button.vue

@@ -1,15 +1,18 @@
 <template>
-<!-- paypal 支付按钮 -->
+<!-- pay 支付按钮 -->
     <div class="pay-wrapper">
         <slot name="balance"></slot>
         <div class="pay-btn">
             <div class="iframe-pay"
-                v-show="currentCurrencyInfo.currencyCode == 'USD'"
-                @click="paypalPay">
-                <iframe
+                v-show="currentCurrencyInfo.currencyCode == 'USD'">
+                <div class="ach-pay" style="background: blue" @click="jumpAchPay">
+                    ACH Pay
+                </div>
+
+                <!-- <iframe
                     class="iframe-pay"
                     ref="iframe"
-                    :src="`${payConfig.paypalHtml}?paypalClientId=${payConfig.paypalClientId}&amount=${props.finalAmountData.finalAmountValue}`"></iframe>
+                    :src="`${payConfig.paypalHtml}?paypalClientId=${payConfig.paypalClientId}&amount=${props.finalAmountData.finalAmountValue}`"></iframe> -->
             </div>
             <div class="token-pay" 
                 :class="{ disabled: Number(currentCurrencyInfo.balance) < Number(payConfig.amount) }"
@@ -26,6 +29,7 @@ import { onMounted, ref, defineProps, defineEmits, watch } from "vue";
 
 import {payTaskLuckdropWithBalance} from "@/http/publishApi"
 import Report from "@/log-center/log"
+import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
 
 const props = defineProps({
     finalAmountData: {
@@ -73,17 +77,7 @@ watch(
     }
 );
 
-const emits = defineEmits(["payPalFinsh"]);
-
-const paypalPay = () => {
-    Report.reportLog({
-        pageSource: Report.pageSource.previewPage,
-        businessType: Report.businessType.buttonClick,
-        objectType: Report.objectType.confirmButton
-    }, {
-        type: 'paypal'
-    });  
-};
+const emits = defineEmits(["payFinish"]);
 
 const tokenPay = () => {  
     Report.reportLog({
@@ -104,7 +98,7 @@ const tokenPay = () => {
         }
     }).then(res => {
         if(res.code == 0) {
-            emits("payPalFinsh", {...res.data, payNetwork: 'bsc'});
+            emits("payFinish", {...res.data, payNetwork: 'token'});
         }
         payIng = false;
     }).catch(() => {
@@ -112,6 +106,14 @@ const tokenPay = () => {
     })
 }
 
+const jumpAchPay = () => {
+    let guideUrl = chrome.runtime.getURL('/iframe/ach-cashier.html');
+    setChromeStorage({ achPayInfo : JSON.stringify({'amountValue': 1})})    
+    chrome.tabs.create({
+        url: guideUrl
+    });
+}
+
 onMounted(() => {
     window.addEventListener("message", function (event) {
         if (event.data && event.data.actionType) {
@@ -122,7 +124,7 @@ onMounted(() => {
                         event.data.orderData,
                         event.data.transaction
                     );
-                    emits("payPalFinsh", {...event.data, payNetwork: 'paypal'});
+                    emits("payFinish", {...event.data, payNetwork: 'pay'});
                     break;
             }
         }

+ 33 - 53
src/view/iframe/publish/give-dialog.vue

@@ -406,18 +406,16 @@
 
                         <!-- paypal支付按钮 -->
                         <div class="payment" v-show="showComType == 'preview'">
-                            <paypal-button
+                            <pay-button
                                 v-if="isMoneyRewardCpd"
                                 :finalAmountData="finalAmountData"
                                 :payConfig="{
-                                    paypalClientId,
                                     feeDesc: payConfig.feeDesc,
-                                    paypalHtml,
                                     amount: baseFormData.amountValue,
                                     postId
                                 }"
                                 :currentCurrencyInfo="currentCurrencyInfo"
-                                @payPalFinsh="payPalFinsh">
+                                @payFinish="payFinish">
                                 <template v-slot:balance>
                                     <div class="balance" v-if="Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance)">
                                         <img class="icon" src="@/assets/subject/icon-balance.png" />
@@ -431,7 +429,7 @@
                                             @click="updateCurrencyBanlce"/>
                                     </div>
                                 </template>
-                            </paypal-button>
+                            </pay-button>
                             <div v-else class="btn-wrap" @click="payStatusHandle(1)"><div class="custom-submit">Confirm</div></div>
                         </div>
                         </template>
@@ -485,11 +483,11 @@
 </template>
 
 <script setup>
-import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick, provide, getCurrentInstance, computed } from "vue";
-import { postPublish, verifyPaypalResult, syncChainTokenRechargeRecord, getCurrencyInfoByCode } from "@/http/publishApi";
+import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick, provide, computed } from "vue";
+import { postPublish, syncChainTokenRechargeRecord, getCurrencyInfoByCode } from "@/http/publishApi";
 import { getInviteGuildInfo, getInviteGuildInfoByOpenApi, saveInviteGuildInfo } from "@/http/discordApi";
 import { payCalcFee, getPayConfig } from "@/http/pay";
-import { getFrontConfig } from "@/http/account";
+import { getFrontConfig, calcRechargePayAmount } from "@/http/account";
 import { uploadSignature, uploadFile } from '@/http/media';
 import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
 import { debounce, getBit } from "@/uilts/help"
@@ -507,7 +505,7 @@ import currencyList from "@/view/components/currency-list.vue";
 import currencySelect from "@/view/components/currency-select.vue";
 import previewCard from "@/view/iframe/publish/components/preview-card";
 import followInput from "@/view/iframe/publish/components/follow-input";
-import paypalButton from "@/view/iframe/publish/components/paypal-button";
+import payButton from "@/view/iframe/publish/components/pay-button";
 import topUp from "@/view/iframe/publish/components/top-up.vue";
 import topUp2 from "@/view/iframe/publish/components/top-up2.vue";
 import toolBox from '@/view/iframe/publish/tool-box/index.vue'
@@ -515,8 +513,6 @@ import giveawayPoster from '@/view/iframe/publish/components/giveaway-poster.vue
 import GlobalTip from '@/view/components/global-tip.vue'
 import customCardCover from '@/view/components/custom-card-cover.vue'
 
-const currentInstance = getCurrentInstance();
-
 import CustomizedRewardEditPopup from '@/view/iframe/publish/components/customized-reward-edit';
 
 const config = {
@@ -528,9 +524,7 @@ const math = create(all, config);
 let tempCurrentCurrencyInfo = ref({});
 let tempCurrentCurrencyList = ref([]);
 
-let paypalClientId = ref("");
 let payConfig = ref({});
-let paypalHtml = ref("");
 let installStatus = ref(false);
 let timer = ref(null);
 provide('installStatus', installStatus)
@@ -920,7 +914,7 @@ const getPayAmount = async (amountValue) => {
         params: {
             amountValue,
             currencyCode: currentCurrencyInfo.value.currencyCode,
-            payChannel: 'paypal',
+            payChannel: 'ach',
         },
     });
     if (res.code == 0) {
@@ -1223,8 +1217,10 @@ const submitRequest = async () => {
 
     // 法币支付需要计算费率
     if(formData.amountCurrencyCode == "USD") { 
-        let payAmountRes = await getPayAmount(amountValue);
-        formData["payAmountValue"] = payAmountRes.finalAmountValue;
+        // 获取充值金额
+
+        // let payAmountRes = await getPayAmount(amountValue);
+        // formData["payAmountValue"] = payAmountRes.finalAmountValue;
     }
     let data = {
         params: {
@@ -1294,37 +1290,34 @@ const setDiscordIptTxt = ({text}) => {
     formList[index]['text'] = text;
 }
 
+const calcRechPayAmount = async (params) => {
+    let res = await calcRechargePayAmount({
+        params : {
+            
+        }
+    })
+
+    if (res.code == 0) {
+        let { finalAmountValue, feeDesc } = res.data;
+        payConfig.value.feeDesc = feeDesc;
+        if (finalAmountValue > 0) {
+            finalAmountData.value = res.data;
+        }
+    }
+    return res.data;
+}
+
 /**
  * 支付完成回调
  */
-const payPalFinsh = (params) => {
+const payFinish = (params) => {
     let {payNetwork, payStatus} = params;
     // token 支付
-    if(payNetwork == 'bsc') {
+    if(payNetwork == 'token') {
         payStatusHandle(payStatus);
     } else {
         // 法币支付
-        let transaction = params.transaction;
-        let loadingInstance = ElLoading.service({
-            background: "rgba(0,0,0,.3)",
-        });
-        verifyPaypalResult({
-            params: {
-                paypalTransactionId: transaction.id,
-                postId: publishRes.postId,
-                paypalClientId: paypalClientId.value,
-            },
-        }).then((res) => {
-            loadingInstance.close();
-            if (res.code == 0) {
-                if (res.data) {
-                    payStatusHandle(res.data.payStatus)
-                }
-            }
-        })
-        .catch(() => {
-            loadingInstance.close();
-        });
+        payStatusHandle(1);
     }
 };
 
@@ -1337,22 +1330,10 @@ const payStatusHandle = (payStatus) => {
             initParams();
             break;
         case 2:
-            // ElMessage({
-            //     message: "Pay Fail",
-            //     type: "warning",
-            // });
             break;
         case 3:
-            // ElMessage({
-            //     message: "Pay Exceptions",
-            //     type: "warning",
-            // });
             break;
         case 4:
-            // ElMessage({
-            //     message: "Pay Exceptions",
-            //     type: "warning",
-            // });
             break;
     }
 }
@@ -1803,7 +1784,6 @@ const setPayConfig = () => {
     }).then((res) => {
         if (res.code == 0) {
             payConfig.value = res.data;
-            paypalClientId.value = res.data.paypalClientId;
         }
     });
 };
@@ -1816,7 +1796,6 @@ const setFrontConfig = () => {
         params: {},
     }).then((res) => {
         if (res.code == 0) {
-            paypalHtml.value = res.data.paypalHtml;
             lotteryMaxHourDuration = res.data.lotteryMaxHourDuration;
             toolBoxPageData.postEditorLinkInputDescImage = res.data.postEditorLinkInputDescImage;
         }
@@ -2541,6 +2520,7 @@ onMounted(() => {
                         height: 60px;
                         margin-left: 14px;
                         margin-right: 14px;
+                        position: relative;
                     }
                     .show-font {
                         position: relative;