2
0

feat: paypal配置

This commit is contained in:
caiyuchao
2025-04-29 18:07:23 +08:00
parent b72bd2121a
commit 4d4727b17e
7 changed files with 52 additions and 7 deletions

View File

@@ -1,6 +1,31 @@
<script setup lang="ts">
import { onMounted } from 'vue';
import { constructPaypalBtn } from '@/utils/paypal';
import { getPaymentConfig, getPayPalConfig } from '@/service/api/payment';
import CryptoJS from 'crypto-js';
/**
* AES解密处理CBC模式
*/
function decryptCBC(word: string) {
word = (word + '').replace(/\n*$/g, '').replace(/\n/g, ''); // 这一行,将换行符替换为空
// 密钥
const keyStr = "EolSdjfd89v2PubN";
// 向量
const ivStr = "EjlnujOBvlv2PubN";
const key = CryptoJS.enc.Utf8.parse(keyStr);
let iv = CryptoJS.enc.Utf8.parse(ivStr);
const decrypt = CryptoJS.AES.decrypt(word, key,
{
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
)
return decrypt.toString(CryptoJS.enc.Utf8)
}
interface Props {
orderInfo: {
@@ -13,7 +38,14 @@ interface Props {
const props = defineProps<Props>();
onMounted(async()=>{
await constructPaypalBtn(props.orderInfo.orderId, "USD");
const response = await getPaymentConfig();
let currency = 'USD';
if (response && response.data) {
currency = response.data.currency || 'USD';
}
const configRes = await getPayPalConfig();
const clientId = decryptCBC(configRes.data);
await constructPaypalBtn(clientId, props.orderInfo.orderId, currency);
})
</script>