Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
goxiaoy committed Nov 7, 2023
1 parent 94e5b68 commit bf4710b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
13 changes: 9 additions & 4 deletions config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,18 @@
],
},
{
path: '/order',
name: 'order',
path: '/payment',
name: 'payment',
icon: 'smile',
routes: [
{
name: 'order.orders',
path: '/order/orders',
name: 'payment.orders',
path: '/payment/orders',
component: './Order/Order',
},
{
name: 'payment.subscriptions',
path: '/payment/subscriptions',
component: './Order/Order',
},
],
Expand Down
15 changes: 9 additions & 6 deletions src/components/PlanDropdown/PriceTable.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
CheckoutServiceApi,
StripePaymentIntent,
SubscriptionServiceApi,
type V1Plan,
type V1Price,
} from '@gosaas/api';
import styles from './index.less';
import React, { useState, useEffect } from 'react';
import { Button, message, InputNumber, Radio } from 'antd';
import { ProCard } from '@ant-design/pro-components';
import { useIntl } from '@umijs/max';
import { useIntl, useModel } from '@umijs/max';
import { useStripe, PaymentElement, Elements, ElementsConsumer } from '@stripe/react-stripe-js';

export type PriceTableProps = {
Expand All @@ -19,7 +19,7 @@ export type PriceTableProps = {
};

const PriceTable: React.FC<PriceTableProps> = (props) => {
const subscriptionSrv = new SubscriptionServiceApi();
const checkoutSrv = new CheckoutServiceApi();
const [messageApi] = message.useMessage();
const groupedData = props.data;
const currentPeriod = props.currentPeriod;
Expand All @@ -28,6 +28,7 @@ const PriceTable: React.FC<PriceTableProps> = (props) => {
const [quantity, setQuantity] = useState<number>(1);
const [currentPrice, setCurrentPrice] = useState<{ plan: V1Plan; price: V1Price }>();
const intl = useIntl();
const { initialState } = useModel('@@initialState');

let btnMsg = intl.formatMessage({
id: 'product.price.subscribeNow',
Expand Down Expand Up @@ -140,13 +141,15 @@ const PriceTable: React.FC<PriceTableProps> = (props) => {
setLoading(true);
setCurrentPrice(p);
try {
const resp = await subscriptionSrv.subscriptionServiceCreateMySubscription({
const resp = await checkoutSrv.checkoutServiceCheckoutNow({
body: {
provider: 'stripe',
items: [{ priceId: p.price.id, quantity: quantity }],
items: [{ priceId: p.price.id, quantity: quantity.toString(),bizPayload:{
"tenant_id":initialState?.currentTenant?.tenant?.id
} }],
},
});
setPaymentIntent(resp.data.providerInfo?.stripe?.latestInvoice?.paymentIntent);
setPaymentIntent(resp.data.subscription?.providerInfo?.stripe?.subscription?.latestInvoice?.paymentIntent || resp.data.order?.paymentProviderInfo?.stripe?.paymentIntent);
} finally {
setLoading(false);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/PlanDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const PlanDropdown: React.FC = () => {
onCancel={() => {
setIsModalOpen(false);
}}
destroyOnClose
>
<PriceTable
data={groupedData}
Expand Down
10 changes: 0 additions & 10 deletions src/pages/Order/Order/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ const TableList: React.FC = () => {
dataIndex: ['originalPrice', 'text'],
valueType: 'text',
},
{
title: (
<FormattedMessage
id="ticketing.order.originalPriceInclTax"
defaultMessage="originalPrice with Tax"
/>
),
dataIndex: ['originalPriceInclTax', 'text'],
valueType: 'text',
},
{
title: (
<FormattedMessage id="ticketing.order.paidPrice" defaultMessage="paidPrice with Tax" />
Expand Down

0 comments on commit bf4710b

Please sign in to comment.