mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: Delete Stripe pamyent connection
This commit is contained in:
@@ -34,6 +34,12 @@ export class PaymentServicesController extends BaseController {
|
|||||||
this.validationResult,
|
this.validationResult,
|
||||||
asyncMiddleware(this.updatePaymentMethod.bind(this))
|
asyncMiddleware(this.updatePaymentMethod.bind(this))
|
||||||
);
|
);
|
||||||
|
router.delete(
|
||||||
|
'/:paymentMethodId',
|
||||||
|
[param('paymentMethodId').exists()],
|
||||||
|
this.validationResult,
|
||||||
|
this.deletePaymentMethod.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
@@ -141,4 +147,33 @@ export class PaymentServicesController extends BaseController {
|
|||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the given payment method.
|
||||||
|
* @param {Request<{ paymentMethodId: number }>} req - Request.
|
||||||
|
* @param {Response} res - Response.
|
||||||
|
* @param {NextFunction} next - Next function.
|
||||||
|
* @return {Promise<Response | void>}
|
||||||
|
*/
|
||||||
|
private async deletePaymentMethod(
|
||||||
|
req: Request<{ paymentMethodId: number }>,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
) {
|
||||||
|
const { tenantId } = req;
|
||||||
|
const { paymentMethodId } = req.params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.paymentServicesApp.deletePaymentMethod(
|
||||||
|
tenantId,
|
||||||
|
paymentMethodId
|
||||||
|
);
|
||||||
|
return res.status(204).send({
|
||||||
|
id: paymentMethodId,
|
||||||
|
message: 'The payment method has been deleted.',
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,10 +124,11 @@ function StripePaymentMethod() {
|
|||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
<Group spacing={10}>
|
<Group spacing={10}>
|
||||||
<Button small onClick={handleEditBtnClick}>
|
{isAccountActive && (
|
||||||
Edit
|
<Button small onClick={handleEditBtnClick}>
|
||||||
</Button>
|
Edit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
{!isAccountCreated && (
|
{!isAccountCreated && (
|
||||||
<Button intent={Intent.PRIMARY} small onClick={handleSetUpBtnClick}>
|
<Button intent={Intent.PRIMARY} small onClick={handleSetUpBtnClick}>
|
||||||
Set it Up
|
Set it Up
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const useDeletePaymentMethod = (
|
|||||||
return useMutation<void, Error, DeletePaymentMethodValues>(
|
return useMutation<void, Error, DeletePaymentMethodValues>(
|
||||||
({ paymentMethodId }) => {
|
({ paymentMethodId }) => {
|
||||||
return apiRequest
|
return apiRequest
|
||||||
.delete(`/payment-methods/${paymentMethodId}`)
|
.delete(`/payment-services/${paymentMethodId}`)
|
||||||
.then((res) => res.data);
|
.then((res) => res.data);
|
||||||
},
|
},
|
||||||
{ ...options },
|
{ ...options },
|
||||||
|
|||||||
@@ -91,9 +91,11 @@ export const useDrawerActions = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useAlertActions = () => {
|
export const useAlertActions = () => {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openAlert: useDispatchAction(openAlert),
|
openAlert: (name, payload) => dispatch(openAlert(name, payload)),
|
||||||
closeAlert: useDispatchAction(closeAlert),
|
closeAlert: (name, payload) => dispatch(closeAlert(name, payload)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user