feat: stripe支付
This commit is contained in:
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { AlipayOutlined, WechatOutlined, WalletOutlined } from '@ant-design/icons-vue';
|
import { AlipayOutlined, WechatOutlined, WalletOutlined } from '@ant-design/icons-vue';
|
||||||
import { Modal } from 'ant-design-vue';
|
import { Modal } from 'ant-design-vue';
|
||||||
import PaypalButton from '@/components/payment/paypal-button.vue';
|
import PaypalButton from '@/components/payment/paypal-button.vue';
|
||||||
|
import { stripePay } from '@/service/api/payment';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ const isBalancePayDisabled = computed(() => {
|
|||||||
return props.loading || false;
|
return props.loading || false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleConfirm = (paymentMethod: 'alipay' | 'wxpay' | 'balance') => {
|
const handleConfirm = async (paymentMethod: 'alipay' | 'wxpay' | 'balance') => {
|
||||||
if (paymentMethod === 'balance') {
|
if (paymentMethod === 'balance') {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: t('page.order.confirmPayment'),
|
title: t('page.order.confirmPayment'),
|
||||||
@@ -49,6 +50,9 @@ const handleConfirm = (paymentMethod: 'alipay' | 'wxpay' | 'balance') => {
|
|||||||
emit('confirm', paymentMethod);
|
emit('confirm', paymentMethod);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if(paymentMethod === 'stripe') {
|
||||||
|
const response = await stripePay(props.orderInfo.orderId);
|
||||||
|
window.location.href = response.data
|
||||||
} else {
|
} else {
|
||||||
emit('confirm', paymentMethod);
|
emit('confirm', paymentMethod);
|
||||||
}
|
}
|
||||||
@@ -129,6 +133,14 @@ const handleCancel = () => {
|
|||||||
<WechatOutlined class="payment-icon wxpay-icon" />
|
<WechatOutlined class="payment-icon wxpay-icon" />
|
||||||
<span>{{ t('page.order.wxpay') }}</span>
|
<span>{{ t('page.order.wxpay') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="method-item"
|
||||||
|
:class="{ disabled: loading }"
|
||||||
|
@click="!loading && handleConfirm('stripe')"
|
||||||
|
>
|
||||||
|
<WechatOutlined class="payment-icon wxpay-icon" />
|
||||||
|
<span>{{ t('page.order.stripe') }}</span>
|
||||||
|
</div>
|
||||||
<PaypalButton
|
<PaypalButton
|
||||||
:order-info="props.orderInfo"
|
:order-info="props.orderInfo"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -728,6 +728,7 @@ const local: any = {
|
|||||||
selectPayment:'Payment',
|
selectPayment:'Payment',
|
||||||
alipay:'Alipay',
|
alipay:'Alipay',
|
||||||
wxpay:'WeChat Pay',
|
wxpay:'WeChat Pay',
|
||||||
|
stripe:'Stripe',
|
||||||
balancePay:'Balance Pay',
|
balancePay:'Balance Pay',
|
||||||
availableBalance:'Balance',
|
availableBalance:'Balance',
|
||||||
paymentSuccess:'Payment successful',
|
paymentSuccess:'Payment successful',
|
||||||
|
|||||||
@@ -728,6 +728,7 @@ const local:any = {
|
|||||||
selectPayment:'支付方式',
|
selectPayment:'支付方式',
|
||||||
alipay:'支付宝支付',
|
alipay:'支付宝支付',
|
||||||
wxpay:'微信支付',
|
wxpay:'微信支付',
|
||||||
|
stripe:'Stripe',
|
||||||
balancePay:'余额支付',
|
balancePay:'余额支付',
|
||||||
availableBalance:'可用余额',
|
availableBalance:'可用余额',
|
||||||
paymentSuccess:'支付成功',
|
paymentSuccess:'支付成功',
|
||||||
|
|||||||
@@ -54,3 +54,11 @@ export function payPalCapture(paypalOrderId: string, orderId: number) {
|
|||||||
method: 'post'
|
method: 'post'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Stripe pay with orderId */
|
||||||
|
export function stripePay(orderId: number) {
|
||||||
|
return request({
|
||||||
|
url: `/payment/stripe/pay/${orderId}`,
|
||||||
|
method: 'post'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
1
src/typings/auto-imports.d.ts
vendored
1
src/typings/auto-imports.d.ts
vendored
@@ -214,6 +214,7 @@ declare global {
|
|||||||
const shallowRef: typeof import('vue')['shallowRef']
|
const shallowRef: typeof import('vue')['shallowRef']
|
||||||
const sortRoutesByOrder: typeof import('../store/modules/route/shared')['sortRoutesByOrder']
|
const sortRoutesByOrder: typeof import('../store/modules/route/shared')['sortRoutesByOrder']
|
||||||
const storeToRefs: typeof import('pinia')['storeToRefs']
|
const storeToRefs: typeof import('pinia')['storeToRefs']
|
||||||
|
const stripePay: typeof import('../service/api/payment')['stripePay']
|
||||||
const submitKYCVerification: typeof import('../service/api/auth')['submitKYCVerification']
|
const submitKYCVerification: typeof import('../service/api/auth')['submitKYCVerification']
|
||||||
const submitOrder: typeof import('../service/api/auth')['submitOrder']
|
const submitOrder: typeof import('../service/api/auth')['submitOrder']
|
||||||
const submitPackageOrder: typeof import('../service/api/auth')['submitPackageOrder']
|
const submitPackageOrder: typeof import('../service/api/auth')['submitPackageOrder']
|
||||||
|
|||||||
Reference in New Issue
Block a user