-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(console): Handle 3D Secure Events (#2529)
- Loading branch information
Showing
25 changed files
with
954 additions
and
356 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { getRollupReqFunctionErrorWrapper } from '@proofzero/utils/errors' | ||
import { redirect, type ActionFunction } from '@remix-run/cloudflare' | ||
import { | ||
commitFlashSession, | ||
getFlashSession, | ||
requireJWT, | ||
} from '~/utilities/session.server' | ||
|
||
import { voidInvoice } from '~/services/billing/stripe' | ||
import { ToastType } from '@proofzero/design-system/src/atoms/toast' | ||
|
||
export const action: ActionFunction = getRollupReqFunctionErrorWrapper( | ||
async ({ request, context }) => { | ||
await requireJWT(request, context.env) | ||
|
||
const fd = await request.formData() | ||
|
||
const invoiceId = fd.get('invoice_id') as string | ||
|
||
const headers = request.headers | ||
let returnURL = headers.get('Referer') as string | ||
|
||
const flashSession = await getFlashSession(request, context.env) | ||
|
||
try { | ||
await voidInvoice(invoiceId, context.env.SECRET_STRIPE_API_KEY) | ||
flashSession.flash( | ||
'toastNotification', | ||
JSON.stringify({ | ||
type: ToastType.Success, | ||
message: 'Invoice successfully cancelled.', | ||
}) | ||
) | ||
} catch (e) { | ||
console.error(e) | ||
flashSession.flash( | ||
'toastNotification', | ||
JSON.stringify({ | ||
type: ToastType.Error, | ||
message: 'Invoice cancellation failed.', | ||
}) | ||
) | ||
} | ||
|
||
return redirect(returnURL, { | ||
headers: { | ||
'Set-Cookie': await commitFlashSession(flashSession, context.env), | ||
}, | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.