feat(subscription): include amount_rials in subscription payment mutation
This commit is contained in:
@@ -59,7 +59,7 @@ function SmsWalletPageInner() {
|
|||||||
mutationFn: ({ amount_rials }: ChargeForm) =>
|
mutationFn: ({ amount_rials }: ChargeForm) =>
|
||||||
api.post<{ data: { payment_url: string } }>('/api/v1/sms/wallet/charge', { gateway, amount_rials }),
|
api.post<{ data: { payment_url: string } }>('/api/v1/sms/wallet/charge', { gateway, amount_rials }),
|
||||||
onSuccess: (res: any) => {
|
onSuccess: (res: any) => {
|
||||||
const url = res?.data?.payment_url;
|
const url = res?.data?.redirect_url ?? res?.data?.payment_url;
|
||||||
if (url) window.location.href = url;
|
if (url) window.location.href = url;
|
||||||
else toast.error('خطا در دریافت لینک پرداخت');
|
else toast.error('خطا در دریافت لینک پرداخت');
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ export default function SubscriptionPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const purchaseMutation = useMutation({
|
const purchaseMutation = useMutation({
|
||||||
mutationFn: ({ period_uuid, gateway }: { period_uuid: string; gateway: string }) =>
|
mutationFn: ({ period_uuid, gateway, amount_rials }: { period_uuid: string; gateway: string; amount_rials: number }) =>
|
||||||
api.post<{ data: { payment_url: string } }>('/api/v1/subscription-payment', { period_uuid, gateway }),
|
api.post<{ data: { payment_url: string } }>('/api/v1/subscription-payment', { period_uuid, gateway, amount_rials }),
|
||||||
onSuccess: (res: any) => {
|
onSuccess: (res: any) => {
|
||||||
const url = res?.data?.payment_url;
|
const url = res?.data?.redirect_url ?? res?.data?.payment_url;
|
||||||
if (url) window.location.href = url;
|
if (url) window.location.href = url;
|
||||||
else toast.error('خطا در دریافت لینک پرداخت');
|
else toast.error('خطا در دریافت لینک پرداخت');
|
||||||
},
|
},
|
||||||
@@ -352,7 +352,7 @@ export default function SubscriptionPage() {
|
|||||||
style={{ flex: 1, height: 44 }}
|
style={{ flex: 1, height: 44 }}
|
||||||
disabled={purchaseMutation.isPending}
|
disabled={purchaseMutation.isPending}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
purchaseMutation.mutate({ period_uuid: purchaseTarget.period.uuid, gateway: selectedGateway })
|
purchaseMutation.mutate({ period_uuid: purchaseTarget.period.uuid, gateway: selectedGateway, amount_rials: purchaseTarget.period.price_rials })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{purchaseMutation.isPending
|
{purchaseMutation.isPending
|
||||||
|
|||||||
Reference in New Issue
Block a user