Skip to content

Commit

Permalink
FIX: add checkout session to our example backend server. (#1441)
Browse files Browse the repository at this point in the history
Co-authored-by: Remon <>
  • Loading branch information
remonh87 authored Oct 16, 2023
1 parent fdcfb62 commit cbb6aeb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
59D21C0B270B725C007DE134 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

Check warning on line 1 in example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

View workflow job for this annotation

GitHub Actions / Typo CI

Filename: example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

"xcscheme" in the filename is a typo. Did you mean "scheme"?

Check warning on line 1 in example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

View workflow job for this annotation

GitHub Actions / Typo CI

Filename: example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

"xcschemes" in the filename is a typo. Did you mean "schemes"?

Check warning on line 1 in example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

View workflow job for this annotation

GitHub Actions / Typo CI

Filename: example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

"xcshareddata" in the filename is a typo. Did you mean "sharecropped"?
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
36 changes: 36 additions & 0 deletions example/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,42 @@ app.post('/payment-intent-for-payment-sheet', async (req, res) => {
}
});

app.post('/create-checkout-session', async (req, res) => {
console.log(`Called /create-checkout-session`)
const {
port,
}: { port?: string; } = req.body;
var effectivePort = port ?? 8080;
const { secret_key } = getKeys();

const stripe = new Stripe(secret_key as string, {
apiVersion: '2023-08-16',
typescript: true,
});

const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Stubborn Attachments',
images: ['https://i.imgur.com/EHyR2nP.png'],
},
unit_amount: 2000,
},
quantity: 1,
},
],
mode: 'payment',
success_url: `https://checkout.stripe.dev/success`,
cancel_url: `https://checkout.stripe.dev/cancel`,

});
return res.json({ id: session.id });
});

app.listen(4242, (): void =>
console.log(`Node server listening on port ${4242}!`)
);

0 comments on commit cbb6aeb

Please sign in to comment.