{"docsConfig":{"theme":"almond","$schema":"https://mintlify.com/docs.json","name":"SampleApp.ai","description":"Infrastructure for custom API demos and sample apps that help developers reach their aha moment faster with your API/SDK","colors":{"primary":"#4cc9f0","light":"#4cc9f0","dark":"#4cc9f0"},"logo":{"light":"https://mintcdn.com/sampleappai/OuhPASQlHOE1qzMN/logo/light.png?fit=max\u0026auto=format\u0026n=OuhPASQlHOE1qzMN\u0026q=85\u0026s=fd66293534412d2d3c1249ae5d1b1f92","dark":"https://mintcdn.com/sampleappai/OuhPASQlHOE1qzMN/logo/dark.png?fit=max\u0026auto=format\u0026n=OuhPASQlHOE1qzMN\u0026q=85\u0026s=affb9da4276f1f36d588542b5443f9a6"},"favicon":"/favicon.png","appearance":{"default":"system","strict":false},"background":{"decoration":"gradient","color":{"light":"#EEEEEE","dark":"#222831"}},"navbar":{"links":[{"label":"Contact Us","href":"https://discord.gg/FnCBtjJSNj"}],"primary":{"type":"button","label":"Get Started","href":"https://sampleapp.ai/sign-up"}},"footer":{"socials":{"x":"https://x.com/sampleappai","github":"https://github.com/sampleappai","linkedin":"https://linkedin.com/company/sampleappai","discord":"https://discord.gg/FnCBtjJSNj"}},"search":{"prompt":"Search the docs..."},"styling":{"codeblocks":{"theme":{"light":"snazzy-light","dark":"dark-plus"}},"latex":false},"errors":{"404":{"redirect":false,"title":"Don't panic.","description":"You've wandered outside the context."}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity"]},"thumbnails":{"appearance":"light","background":"https://mintlify.s3.us-west-1.amazonaws.com/sampleappai/assets/brand/thumbnail-background.png"},"interaction":{"drilldown":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"sampleappai","hasAudioNarration":false,"actualSubdomain":"sampleappai","customDomains":["docs.sampleapp.ai"],"gitSource":{"type":"github","owner":"sampleapp-ai","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6ae945edfc206e01340acbac:success","clientVersion":"0.0.4344","searchFilterCounts":[{"language":"default","tag":"Documentation","count":11},{"language":"default","tag":"Samples","count":5},{"language":"default","tag":"Integration","count":3},{"language":"default","tag":"Products","count":3},{"language":"default","tag":"Social Media","count":3},{"language":"default","tag":"Other Stripe-like Sandbox Examples","count":2},{"language":"default","tag":"Sample Projects","count":2},{"language":"default","tag":"Getting Started","count":1},{"language":"default","tag":"Quickstarts","count":1},{"language":"default","tag":"Wide Samples","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":true},"customCss":[]}
{"page":{"pagePath":"wide-samples/sandbox","slug":"/wide-samples/sandbox","pageMetadata":{"title":"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)","description":"Build a checkout page with Payment Intents API","icon":"credit-card","mode":"custom","href":"/wide-samples/sandbox","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Build a checkout page with Payment Intents API\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];const DownloadAndOpenButtons=({downloadUrl,mainAppUrl=`https://sampleapp.ai`,className=``,gitUrl})=>{const[hasCopied,setHasCopied]=React.useState(false);const[showCommand,setShowCommand]=React.useState(false);const npxCommand=React.useMemo(()=>{let apiPath=downloadUrl;if(apiPath.startsWith(`http://`)||apiPath.startsWith(`https://`)){try{const url=new URL(apiPath);apiPath=url.pathname}catch(e){console.error(`Invalid URL:`,apiPath)}}if(apiPath.startsWith(`/public/`)){apiPath=apiPath.slice(`/public/`.length)}if(apiPath.startsWith(`/`)){apiPath=apiPath.slice(1)}if(apiPath.endsWith(`.zip`)){apiPath=apiPath.slice(0,-4)}return`npx sampleappai add \"${mainAppUrl}/api/code/static/${apiPath}\"`},[downloadUrl,mainAppUrl]);const handleDownload=()=>{window.open(downloadUrl,`_blank`)};const handleCopyCommand=async()=>{try{await navigator.clipboard.writeText(npxCommand);setHasCopied(true);setTimeout(()=>setHasCopied(false),2e3)}catch(err){const textArea=document.createElement(`textarea`);textArea.value=npxCommand;document.body.appendChild(textArea);textArea.select();try{document.execCommand(`copy`);setHasCopied(true);setTimeout(()=>setHasCopied(false),2e3)}catch(err){console.error(`Failed to copy:`,err)}document.body.removeChild(textArea)}};const handleOpenVSCode=()=>{try{window.location.href=`vscode://vscode.git/clone?url=${gitUrl}`}catch{}};return _jsxs(`div`,{className:`mint-flex mint-flex-col mint-gap-3 ${className}`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:[_jsxs(`button`,{type:`button`,className:`mint-inline-flex mint-items-center mint-gap-1.5 mint-px-3 mint-py-1.5 mint-text-xs mint-font-medium mint-rounded-md mint-text-white mint-transition-all hover:mint-opacity-90 active:mint-scale-[0.98] bg-primary dark:bg-primary-light`,onClick:handleDownload,children:[_jsx(`svg`,{className:`mint-w-3.5 mint-h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4`})}),`Download example`]}),_jsxs(`button`,{type:`button`,className:`mint-inline-flex mint-items-center mint-h-8 mint-gap-1.5 mint-px-3 mint-py-0.5 mint-text-xs mint-font-medium mint-rounded-md mint-border mint-transition-all hover:mint-bg-zinc-100 dark:hover:mint-bg-zinc-800 active:mint-scale-[0.98] mint-bg-white dark:mint-bg-zinc-900 mint-border-zinc-300 dark:mint-border-zinc-700 mint-text-zinc-900 dark:mint-text-zinc-100`,onClick:()=>handleOpenVSCode(),children:[_jsx(`img`,{src:`/assets/vscode.png`,alt:`VS Code`,className:`mint-w-3.5 mint-h-3.5`}),`Integrate in VS Code`]})]}),showCommand\u0026\u0026_jsx(`div`,{className:`mint-p-4 mint-border mint-border-zinc-300 dark:mint-border-zinc-700 mint-rounded-lg mint-bg-zinc-50 dark:mint-bg-zinc-900/50`,children:_jsxs(`div`,{className:`mint-flex mint-flex-col mint-gap-3`,children:[_jsxs(`div`,{className:`mint-flex mint-flex-col mint-gap-2`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:[_jsx(`div`,{className:`mint-flex-shrink-0 mint-w-5 mint-h-5 mint-rounded-full mint-flex mint-items-center mint-justify-center mint-text-[10px] mint-font-bold mint-text-white`,style:{backgroundColor:themeColor},children:`1`}),_jsx(`p`,{className:`mint-text-sm mint-font-medium mint-text-zinc-900 dark:mint-text-zinc-100`,children:`Copy this command`})]}),_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2 mint-overflow-hidden`,children:[_jsx(`code`,{className:`mint-flex-1 mint-bg-white dark:mint-bg-zinc-800 mint-px-3 mint-py-2.5 mint-rounded-md mint-text-xs mint-font-mono mint-truncate mint-block mint-max-w-[calc(100%-3rem)] mint-border mint-border-zinc-200 dark:mint-border-zinc-700 mint-text-zinc-900 dark:mint-text-zinc-100`,children:npxCommand}),_jsx(`button`,{type:`button`,onClick:handleCopyCommand,className:`mint-flex-shrink-0 mint-p-2 mint-rounded-md hover:mint-bg-zinc-200 dark:hover:mint-bg-zinc-700 mint-transition-colors mint-border mint-border-zinc-300 dark:mint-border-zinc-600`,title:`Copy command`,children:hasCopied?_jsx(`svg`,{className:`mint-w-4 mint-h-4 mint-text-green-500`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})}):_jsx(`svg`,{className:`mint-w-4 mint-h-4 mint-text-zinc-600 dark:mint-text-zinc-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})]})]}),_jsxs(`div`,{className:`mint-flex mint-flex-col mint-gap-2`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:[_jsx(`div`,{className:`mint-flex-shrink-0 mint-w-5 mint-h-5 mint-rounded-full mint-flex mint-items-center mint-justify-center mint-text-[10px] mint-font-bold mint-text-white`,style:{backgroundColor:themeColor},children:`2`}),_jsx(`p`,{className:`mint-text-sm mint-font-medium mint-text-zinc-900 dark:mint-text-zinc-100`,children:`Open VSCode and paste in terminal`})]}),_jsxs(`button`,{type:`button`,onClick:handleOpenVSCode,className:`mint-w-full mint-inline-flex mint-items-center mint-justify-center mint-gap-2 mint-px-4 mint-py-2.5 mint-text-sm mint-font-medium mint-rounded-md mint-text-white mint-transition-all hover:mint-opacity-90 active:mint-scale-[0.99]`,style:{backgroundColor:themeColor},children:[_jsxs(`svg`,{className:`mint-w-4 mint-h-4`,width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,children:[_jsx(`path`,{d:`M13.3333 0L5 3.33333V16.6667L13.3333 20V0Z`,fill:`currentColor`}),_jsx(`path`,{d:`M13.3333 0L18.3333 3.75V16.25L13.3333 20V0Z`,fill:`currentColor`,opacity:`0.8`})]}),`Open VSCode`]})]})]})})]})};const FrameworkGuide=({framework,label,children})=>{return children};const Architecture=({value,label,children})=>{return children};const iframeState={listeners:[],params:{},subscribe:fn=>{iframeState.listeners.push(fn);return()=>{iframeState.listeners=iframeState.listeners.filter(l=>l!==fn)}},setParams:params=>{iframeState.params=params;iframeState.listeners.forEach(fn=>fn(params))}};const CodeFocusSection=({docs=`mintlify`,themeColor,linesStart,linesEnd,activeFilePath,title,description,children})=>{const sectionRef=React.useRef(null);const hasTriggeredRef=React.useRef(false);const[isActive,setIsActive]=React.useState(false);const useProse=docs===`mintlify`;const getParams=React.useCallback(()=>{const params={};if(docs)params.docs=docs;if(docs===`custom`\u0026\u0026themeColor)params.theme=themeColor;if(linesStart!==undefined)params.linesStart=linesStart;if(linesEnd!==undefined)params.linesEnd=linesEnd;if(activeFilePath)params.activeFilePath=activeFilePath;return params},[docs,themeColor,linesStart,linesEnd,activeFilePath]);const handleFocus=React.useCallback(()=>{iframeState.setParams(getParams());setIsActive(true)},[getParams]);React.useEffect(()=>{const checkActive=params=>{const myParams=getParams();const isMatch=params.activeFilePath===myParams.activeFilePath\u0026\u0026params.linesStart===myParams.linesStart\u0026\u0026params.linesEnd===myParams.linesEnd;setIsActive(isMatch);if(params.platform!==undefined||params.framework!==undefined||params.activeFilePath!==myParams.activeFilePath){hasTriggeredRef.current=false}};checkActive(iframeState.params);return iframeState.subscribe(checkActive)},[getParams]);React.useEffect(()=>{const element=sectionRef.current;if(!element)return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting\u0026\u0026!hasTriggeredRef.current){hasTriggeredRef.current=true;handleFocus()}else if(!entry.isIntersecting){hasTriggeredRef.current=false}})},{threshold:0,rootMargin:`-40% 0px -40% 0px`});observer.observe(element);return()=>observer.disconnect()},[handleFocus]);return _jsxs(`div`,{ref:sectionRef,onClick:handleFocus,className:`mint-relative mint-py-6 mint-transition-colors mint-cursor-pointer`,style:{marginLeft:`-1.5rem`,marginRight:`-1.5rem`,paddingLeft:`1.5rem`,paddingRight:`1.5rem`},children:[_jsx(`div`,{className:`mint-absolute mint-top-0 mint-h-px`,style:{backgroundColor:`rgba(128,128,128,0.2)`,left:`-2rem`,right:`-2rem`}}),isActive\u0026\u0026_jsx(`div`,{className:`mint-absolute mint--left-2 mint-top-0 mint-bottom-0 mint-w-1 ${useProse?`bg-primary dark:bg-primary-light`:``}`,style:!useProse\u0026\u0026themeColor?{backgroundColor:themeColor}:undefined}),title\u0026\u0026_jsx(`div`,{className:`mint-flex mint-items-center mint-gap-2 mint-mb-2`,children:_jsx(`h4`,{className:`mint-text-base mint-font-semibold mint-m-0 ${useProse\u0026\u0026isActive?`text-primary dark:text-primary-light`:``}`,style:!useProse\u0026\u0026isActive\u0026\u0026themeColor?{color:themeColor}:undefined,children:title})}),description\u0026\u0026_jsx(`p`,{className:`mint-text-sm mint-text-gray-500 dark:mint-text-gray-400 mint-mt-1 mint-mb-0`,children:description}),children\u0026\u0026_jsx(`div`,{className:`mint-mt-3`,children})]})};const SideBySideLayout=({previewSrc,children})=>{const iframeRef=React.useRef(null);const pendingParams=React.useRef(null);const iframeReady=React.useRef(false);const baseUrlRef=React.useRef(previewSrc);const architectures=React.useMemo(()=>{const derived=[];React.Children.forEach(children,child=>{if(child?.type===Architecture){const archValue=child.props.value;const archLabel=child.props.label;const frameworks=[];React.Children.forEach(child.props.children,frameworkChild=>{if(frameworkChild?.type===FrameworkGuide){frameworks.push({value:frameworkChild.props.framework,label:frameworkChild.props.label||frameworkChild.props.framework})}});derived.push({value:archValue,label:archLabel,frameworks})}});return derived},[children]);const SettingsNavInternal=()=>{const parseFrameworkValue=(archValue,fwValue,fwLabel)=>{const archPrefix=archValue.toLowerCase().split(` `)[0];const archPrefixMap={javascript:`js`,ios:`ios`,android:`ad`};const prefix=archPrefixMap[archPrefix]||archPrefix;let remaining=fwValue;if(fwValue.startsWith(prefix+`-`)){remaining=fwValue.slice(prefix.length+1)}const labelParts=fwLabel.split(` + `);if(!fwLabel.includes(` + `)){return{frontend:remaining,frontendLabel:fwLabel,backend:null,backendLabel:null,isFullStack:true}}const parts=remaining.split(`-`);if(parts.length>=2){return{frontend:parts[0],frontendLabel:labelParts[0]||parts[0],backend:parts.slice(1).join(`-`),backendLabel:labelParts[1]||parts.slice(1).join(`-`),isFullStack:false}}return{frontend:remaining,frontendLabel:fwLabel,backend:null,backendLabel:null,isFullStack:true}};const[selections,setSelections]=React.useState(()=>{const defaults={};if(architectures\u0026\u0026architectures.length>0){const firstArch=architectures[0];defaults.platform=firstArch.value;if(firstArch.frameworks\u0026\u0026firstArch.frameworks.length>0){const firstFw=firstArch.frameworks[0];const parsed=parseFrameworkValue(firstArch.value,firstFw.value,firstFw.label);defaults.client=parsed.frontend;defaults.server=parsed.backend;defaults.framework=firstFw.value}}return defaults});const getAvailableOptions=React.useMemo(()=>{const selectedArch=architectures?.find(arch=>arch.value===selections.platform);const frameworks=selectedArch?.frameworks||[];const frontends=new Map;const backends=new Map;const fullStackFrameworks=[];frameworks.forEach(fw=>{const parsed=parseFrameworkValue(selectedArch?.value||``,fw.value,fw.label);if(parsed.isFullStack){fullStackFrameworks.push({value:parsed.frontend,label:parsed.frontendLabel,fullFrameworkValue:fw.value})}else{if(!frontends.has(parsed.frontend)){frontends.set(parsed.frontend,{value:parsed.frontend,label:parsed.frontendLabel})}if(parsed.backend\u0026\u0026!backends.has(parsed.backend)){backends.set(parsed.backend,{value:parsed.backend,label:parsed.backendLabel})}}});fullStackFrameworks.forEach(fs=>{if(!frontends.has(fs.value)){frontends.set(fs.value,{value:fs.value,label:fs.label,isFullStack:true,fullFrameworkValue:fs.fullFrameworkValue})}});return{frontends:Array.from(frontends.values()),backends:Array.from(backends.values()),fullStackFrameworks}},[architectures,selections.platform]);const isFullStackSelected=React.useMemo(()=>{const frontend=getAvailableOptions.frontends.find(f=>f.value===selections.client);return frontend?.isFullStack||false},[getAvailableOptions.frontends,selections.client]);const sections=[{id:`platform`,label:`Architecture:`,options:architectures||[]},{id:`client`,label:`Frontend:`,options:getAvailableOptions.frontends},...isFullStackSelected?[]:[{id:`server`,label:`Backend:`,options:getAvailableOptions.backends}]];React.useEffect(()=>{if(selections.platform||selections.framework){iframeState.setParams({...iframeState.params,...selections})}},[]);const handleSelect=(sectionId,value)=>{let newSelections={...selections,[sectionId]:value};const getArchPrefix=archValue=>{const archPrefix=archValue.toLowerCase().split(` `)[0];const archPrefixMap={javascript:`js`,ios:`ios`,android:`ad`};return archPrefixMap[archPrefix]||archPrefix};const getBackendsForArch=archValue=>{const arch=architectures?.find(a=>a.value===archValue);const backends=new Map;arch?.frameworks?.forEach(fw=>{const parsed=parseFrameworkValue(arch.value,fw.value,fw.label);if(!parsed.isFullStack\u0026\u0026parsed.backend){backends.set(parsed.backend,parsed.backendLabel)}});return Array.from(backends.keys())};if(sectionId===`platform`){const newArch=architectures?.find(arch=>arch.value===value);if(newArch?.frameworks\u0026\u0026newArch.frameworks.length>0){const firstFw=newArch.frameworks[0];const parsed=parseFrameworkValue(newArch.value,firstFw.value,firstFw.label);newSelections.client=parsed.frontend;newSelections.server=parsed.backend;newSelections.framework=firstFw.value}}if(sectionId===`client`){const selectedArch=architectures?.find(arch=>arch.value===newSelections.platform);const frameworks=selectedArch?.frameworks||[];const fullStackFw=frameworks.find(fw=>{const parsed=parseFrameworkValue(selectedArch?.value||``,fw.value,fw.label);return parsed.isFullStack\u0026\u0026parsed.frontend===value});if(fullStackFw){newSelections.server=null;newSelections.framework=fullStackFw.value}else{const prefix=getArchPrefix(newSelections.platform);let server=newSelections.server;if(!server){const availableBackends=getBackendsForArch(newSelections.platform);server=availableBackends[0]||null;newSelections.server=server}if(server){newSelections.framework=`${prefix}-${value}-${server}`}}}if(sectionId===`server`){const prefix=getArchPrefix(newSelections.platform);const client=newSelections.client;newSelections.framework=`${prefix}-${client}-${value}`}setSelections(newSelections);iframeState.setParams({...iframeState.params,...newSelections})};return _jsx(`div`,{className:`mint-w-full mint-sticky mint-top-0 mint-z-50 lg:mint--mx-8 mint-px-4 lg:mint-px-8 mint-py-6 mint-backdrop-blur-md`,children:_jsx(`div`,{className:`mint-flex mint-flex-wrap mint-items-center mint-justify-between`,children:_jsx(`div`,{className:`mint-flex mint-flex-wrap mint-items-center`,style:{marginLeft:`-24px`,marginTop:`-24px`},children:sections.map(section=>_jsxs(`div`,{className:`mint-flex mint-items-center mint-flex-wrap`,style:{marginTop:`24px`,marginLeft:`24px`},children:[_jsx(`span`,{className:`mint-text-sm mint-font-semibold mint-text-gray-700 dark:mint-text-gray-300 mint-whitespace-nowrap mint-mr-3`,children:section.label}),_jsxs(`fieldset`,{className:`mint-hidden 2xl:block mint-border-0 mint-p-0 mint-m-0`,children:[_jsx(`legend`,{className:`mint-sr-only`,children:section.label}),_jsx(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:section.options.map(option=>{const isSelected=selections[section.id]===option.value;return _jsxs(`div`,{className:`mint-relative`,children:[_jsx(`input`,{type:`radio`,id:`${section.id}-${option.value}`,name:section.id,value:option.value,checked:isSelected,onChange:()=>handleSelect(section.id,option.value),className:`mint-sr-only`}),_jsx(`label`,{htmlFor:`${section.id}-${option.value}`,className:`mint-inline-flex mint-items-center mint-px-3 mint-py-1.5 mint-text-xs mint-font-medium mint-rounded-md mint-border mint-transition-all mint-cursor-pointer active:mint-scale-[0.98] ${isSelected?`mint-bg-white dark:mint-bg-zinc-900 border-primary dark:border-primary-light text-primary dark:text-primary-light hover:mint-bg-zinc-100 dark:hover:mint-bg-zinc-800`:`mint-bg-white dark:mint-bg-zinc-900 mint-border-zinc-300 dark:mint-border-zinc-700 mint-text-zinc-900 dark:mint-text-zinc-100 hover:mint-bg-zinc-100 dark:hover:mint-bg-zinc-800`}`,children:option.label})]},option.value)})})]}),_jsxs(`div`,{className:`mint-block 2xl:hidden mint-relative`,children:[_jsx(`select`,{value:selections[section.id],onChange:e=>handleSelect(section.id,e.target.value),className:`mint-appearance-none mint-bg-white dark:mint-bg-zinc-900 mint-border mint-border-zinc-300 dark:mint-border-zinc-700 mint-rounded-md mint-px-3 mint-py-1.5 mint-pr-8 mint-text-xs mint-font-medium mint-text-zinc-900 dark:mint-text-zinc-100 focus:mint-outline-none focus:mint-ring-2 focus:ring-primary dark:focus:ring-primary-light focus:mint-border-transparent mint-transition-all hover:mint-bg-zinc-100 dark:hover:mint-bg-zinc-800`,children:section.options.map(option=>_jsx(`option`,{value:option.value,children:option.label},option.value))}),_jsx(`svg`,{\"aria-hidden\":`true`,width:`16`,height:`16`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,className:`mint-absolute mint-right-2 mint-top-1/2 mint--translate-y-1/2 mint-pointer-events-none mint-text-zinc-400`,children:_jsx(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M2.35 9.915a.875.875 0 0 1 1.235-.065L8 13.823l4.415-3.973a.875.875 0 0 1 1.17 1.3l-5 4.5a.873.873 0 0 1-1.17 0l-5-4.5a.875.875 0 0 1-.065-1.235ZM7.415.35a.873.873 0 0 1 1.17 0l5 4.5a.875.875 0 1 1-1.17 1.3L8 2.177 3.585 6.15a.875.875 0 0 1-1.17-1.3l5-4.5Z`,fill:`currentColor`})})]})]},section.id))})})})};const getCurrentColor=()=>{const temp=document.createElement(`div`);temp.className=document.documentElement.classList.contains(`dark`)?`dark:bg-primary-light`:`bg-primary`;document.body.appendChild(temp);const bgColor=getComputedStyle(temp).backgroundColor;document.body.removeChild(temp);return bgColor};function rgbToHex(rgb){const match=rgb.match(/\\d+/g);if(!match)return null;const[r,g,b]=match.map(Number);return`#`+[r,g,b].map(x=>x.toString(16).padStart(2,`0`)).join(``)}const getCurrentColorInHexadecimal=()=>{return`%23`+rgbToHex(getCurrentColor()).split(`#`)[1]};const updateIframeTheme=React.useCallback(()=>{if(iframeRef.current){const currentParams=iframeState.params;let newSrc=baseUrlRef.current+`\u0026theme=`+getCurrentColorInHexadecimal();if(currentParams.iframeUrl){newSrc+=`\u0026iframeUrl=`+encodeURIComponent(currentParams.iframeUrl)}iframeRef.current.src=newSrc}},[]);React.useEffect(()=>{const observer=new MutationObserver(mutations=>{mutations.forEach(mutation=>{if(mutation.attributeName===`class`){updateIframeTheme()}})});observer.observe(document.documentElement,{attributes:true,attributeFilter:[`class`]});return()=>observer.disconnect()},[updateIframeTheme]);React.useEffect(()=>{let lastFramework=iframeState.params.framework;let lastFilePath=iframeState.params.activeFilePath;let debounceTimer=null;const handleParamsChange=params=>{if(params.framework\u0026\u0026params.framework!==lastFramework){lastFramework=params.framework;if(iframeRef.current){const url=new URL(iframeRef.current.src);url.searchParams.set(`framework`,params.framework);iframeRef.current.src=url.toString();return}}if(debounceTimer){clearTimeout(debounceTimer)}const fileChanged=params.activeFilePath\u0026\u0026params.activeFilePath!==lastFilePath;if(fileChanged){lastFilePath=params.activeFilePath}const delay=fileChanged?150:0;debounceTimer=setTimeout(()=>{const message={type:`UPDATE_VIEW`,...params};if(iframeRef.current?.contentWindow){iframeRef.current.contentWindow.postMessage(message,`*`)}},delay)};const unsubscribe=iframeState.subscribe(handleParamsChange);return()=>{if(debounceTimer)clearTimeout(debounceTimer);unsubscribe()}},[]);const ActiveContent=()=>{const[currentState,setCurrentState]=React.useState(()=>{const params=iframeState.params;return{platform:params.platform||architectures[0]?.value,framework:params.framework||architectures[0]?.frameworks[0]?.value}});const[currentPageId,setCurrentPageId]=React.useState(`1`);React.useEffect(()=>{const handleUpdate=params=>{if(params.platform!==undefined||params.framework!==undefined){setCurrentState(prev=>({platform:params.platform??prev.platform,framework:params.framework??prev.framework}))}};return iframeState.subscribe(handleUpdate)},[]);let matchedContent=null;React.Children.forEach(children,child=>{if(child?.type===Architecture\u0026\u0026child.props.value===currentState.platform){React.Children.forEach(child.props.children,frameworkChild=>{if(frameworkChild?.type===FrameworkGuide\u0026\u0026frameworkChild.props.framework===currentState.framework){matchedContent=frameworkChild.props.children}})}});const isPageComponent=child=>{if(child?.props?.[`data-page-id`])return true;if(child?.type?.name===`Page`)return true;if(typeof child?.type===`function`\u0026\u0026child?.props?.id\u0026\u0026child?.props?.title){return true}return false};const pages=React.useMemo(()=>{const extracted=[];React.Children.forEach(matchedContent,child=>{if(isPageComponent(child)){let verificationSteps=null;const stepsData=child.props[`data-page-verification-steps`]||child.props.verificationSteps;if(stepsData){try{verificationSteps=typeof stepsData===`string`?JSON.parse(stepsData):stepsData}catch(e){console.warn(`Failed to parse verification steps:`,e)}}extracted.push({id:child.props[`data-page-id`]||child.props.id,title:child.props[`data-page-title`]||child.props.title,content:child.props.children,verificationSteps})}});return extracted},[matchedContent]);React.useEffect(()=>{if(pages.length>0\u0026\u0026!pages.find(p=>p.id===currentPageId)){setCurrentPageId(pages[0].id)}},[pages,currentPageId]);if(pages.length===0){return _jsx(_Fragment,{children:matchedContent})}if(pages.length===1){const currentPage=pages[0];return _jsx(_Fragment,{children:currentPage?.content})}const currentPageIndex=pages.findIndex(p=>p.id===currentPageId);const currentPage=pages[currentPageIndex];const nextPage=currentPageIndex\u003cpages.length-1?pages[currentPageIndex+1]:null;const[showStepsPopup,setShowStepsPopup]=React.useState(false);const[showVerificationPopup,setShowVerificationPopup]=React.useState(false);const[verificationSteps,setVerificationSteps]=React.useState([]);const[currentVerificationIndex,setCurrentVerificationIndex]=React.useState(0);const[verificationComplete,setVerificationComplete]=React.useState(false);const getVerificationStepsForPage=pageId=>{const page=pages.find(p=>p.id===pageId);if(page?.verificationSteps\u0026\u0026page.verificationSteps.length>0){return page.verificationSteps}const defaultSteps=[{id:1,label:`Checking configuration`},{id:2,label:`Validating setup`},{id:3,label:`Verifying connection`},{id:4,label:`Ready to continue`}];return defaultSteps};const goToPage=pageId=>{setCurrentPageId(pageId);setShowStepsPopup(false);window.scrollTo({top:0,behavior:`smooth`})};const handleNextClick=()=>{if(!nextPage)return;const steps=getVerificationStepsForPage(currentPage.id);setVerificationSteps(steps);setCurrentVerificationIndex(0);setVerificationComplete(false);setShowVerificationPopup(true);steps.forEach((_,index)=>{setTimeout(()=>{setCurrentVerificationIndex(index);if(index===steps.length-1){setTimeout(()=>{setVerificationComplete(true)},600)}},(index+1)*800)})};const handleVerificationComplete=()=>{setShowVerificationPopup(false);if(nextPage){goToPage(nextPage.id)}};const barContainerRef=React.useRef(null);React.useEffect(()=>{const handleClickOutside=event=>{if(barContainerRef.current\u0026\u0026!barContainerRef.current.contains(event.target)\u0026\u0026(showStepsPopup||showVerificationPopup)){if(showVerificationPopup\u0026\u0026!verificationComplete){return}setShowStepsPopup(false);if(verificationComplete){setShowVerificationPopup(false)}}};if(showStepsPopup||showVerificationPopup){document.addEventListener(`mousedown`,handleClickOutside);return()=>{document.removeEventListener(`mousedown`,handleClickOutside)}}},[showStepsPopup,showVerificationPopup,verificationComplete]);return _jsxs(`div`,{className:`page-container mint-relative`,children:[_jsx(`div`,{className:`page-content mint-pb-24`,children:currentPage?.content}),_jsx(`div`,{className:`mint-sticky mint-bottom-4 mint-z-40`,ref:barContainerRef,children:_jsxs(`div`,{className:`mint-relative`,children:[_jsx(`div`,{className:`mint-bg-white dark:mint-bg-zinc-900 mint-border mint-border-gray-200 dark:mint-border-zinc-700 mint-shadow-lg mint-rounded-xl mint-px-4 mint-py-3`,children:_jsxs(`div`,{className:`mint-flex mint-items-center mint-justify-between mint-gap-4`,children:[_jsxs(`button`,{onClick:()=>setShowStepsPopup(!showStepsPopup),className:`mint-flex mint-items-center mint-gap-3 mint-px-3 mint-py-2 mint-rounded-lg mint-bg-gray-100 dark:mint-bg-zinc-800 hover:mint-bg-gray-200 dark:hover:mint-bg-zinc-700 mint-transition-all`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:[_jsx(`div`,{className:`mint-w-6 mint-h-6 mint-rounded-full bg-primary dark:bg-primary-light mint-text-white mint-text-xs mint-font-bold mint-flex mint-items-center mint-justify-center`,children:currentPageIndex+1}),_jsx(`span`,{className:`mint-text-sm mint-font-medium mint-text-gray-700 dark:mint-text-gray-300`,children:currentPage?.title})]}),_jsx(`svg`,{className:`mint-w-4 mint-h-4 mint-text-gray-400 mint-transition-transform ${showStepsPopup?`mint-rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})]}),nextPage?_jsxs(`button`,{onClick:handleNextClick,className:`mint-flex mint-items-center mint-gap-2 mint-px-5 mint-py-2 mint-rounded-lg bg-primary dark:bg-primary-light mint-text-white mint-font-medium hover:mint-opacity-90 mint-transition-all`,children:[_jsx(`span`,{children:`Verify`}),_jsx(`svg`,{className:`mint-w-4 mint-h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]}):_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2 mint-px-5 mint-py-2 mint-rounded-lg mint-bg-green-500 mint-text-white mint-font-medium`,children:[_jsx(`svg`,{className:`mint-w-4 mint-h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}),_jsx(`span`,{children:`Complete`})]})]})}),showStepsPopup\u0026\u0026_jsx(`div`,{className:`mint-absolute mint-bottom-full mint-left-0 mint-right-0 mint-mb-2 mint-z-50`,children:_jsxs(`div`,{className:`mint-bg-white dark:mint-bg-zinc-900 mint-border mint-border-gray-200 dark:mint-border-zinc-700 mint-shadow-2xl mint-rounded-xl mint-overflow-hidden animate-expand-up`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-justify-between mint-px-3 mint-py-2 mint-border-b mint-border-gray-200 dark:mint-border-zinc-700 mint-bg-gray-50 dark:mint-bg-zinc-800/50`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:[_jsx(`div`,{className:`mint-w-5 mint-h-5 mint-rounded-full bg-primary dark:bg-primary-light mint-text-white mint-text-xs mint-font-bold mint-flex mint-items-center mint-justify-center mint-leading-none`,children:pages.length}),_jsx(`span`,{className:`mint-text-sm mint-font-semibold mint-text-gray-900 dark:mint-text-white mint-leading-none`,children:`Steps`})]}),_jsx(`button`,{onClick:()=>setShowStepsPopup(false),className:`mint-p-1 mint-rounded-md hover:mint-bg-gray-200 dark:hover:mint-bg-zinc-700 mint-transition-colors mint-flex-shrink-0`,children:_jsx(`svg`,{className:`mint-w-4 mint-h-4 mint-text-gray-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 18L18 6M6 6l12 12`})})})]}),_jsx(`div`,{className:`mint-p-3 mint-space-y-1 mint-max-h-80 mint-overflow-y-auto`,children:pages.map((page,index)=>{const isCompleted=index\u003ccurrentPageIndex;const isCurrent=page.id===currentPageId;const isDisabled=index>currentPageIndex;return _jsxs(`div`,{className:`mint-relative mint-group`,children:[_jsxs(`button`,{onClick:()=>!isDisabled\u0026\u0026goToPage(page.id),disabled:isDisabled,className:`mint-w-full mint-flex mint-items-center mint-gap-3 mint-p-2.5 mint-rounded-lg mint-text-left mint-transition-all ${isCurrent?`bg-primary/10 dark:bg-primary-light/10 mint-border border-primary/30 dark:border-primary-light/30`:isDisabled?`mint-opacity-50 mint-cursor-not-allowed`:`hover:mint-bg-gray-100 dark:hover:mint-bg-zinc-800`}`,children:[_jsx(`div`,{className:`mint-flex-shrink-0 mint-w-7 mint-h-7 mint-rounded-full mint-flex mint-items-center mint-justify-center mint-text-xs mint-font-bold mint-transition-all ${isCompleted?`bg-primary dark:bg-primary-light mint-text-white`:isCurrent?`bg-primary dark:bg-primary-light mint-text-white`:isDisabled?`mint-bg-gray-100 dark:mint-bg-zinc-800 mint-text-gray-400 dark:mint-text-gray-600`:`mint-bg-gray-200 dark:mint-bg-zinc-700 mint-text-gray-500 dark:mint-text-gray-400`}`,children:isCompleted?_jsx(`svg`,{className:`mint-w-3.5 mint-h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}):index+1}),_jsx(`span`,{className:`mint-text-sm mint-font-medium ${isCurrent?`text-primary dark:text-primary-light`:isCompleted?`mint-text-gray-500 dark:mint-text-gray-400`:isDisabled?`mint-text-gray-400 dark:mint-text-gray-600`:`mint-text-gray-700 dark:mint-text-gray-300`}`,children:page.title})]}),isDisabled\u0026\u0026_jsxs(`div`,{className:`mint-absolute mint-left-0 mint-bottom-full mint-mb-2 mint-w-64 mint-px-3 mint-py-2 mint-bg-gray-900 dark:mint-bg-gray-700 mint-text-white mint-text-xs mint-rounded-lg mint-shadow-lg mint-opacity-0 group-hover:mint-opacity-100 mint-transition-opacity mint-pointer-events-none mint-z-50`,children:[`Please complete all steps in this guide and press verify`,_jsx(`div`,{className:`mint-absolute mint-top-full mint-left-4 mint-w-0 mint-h-0 mint-border-l-4 mint-border-r-4 mint-border-t-4 mint-border-transparent mint-border-t-gray-900 dark:mint-border-t-gray-700`})]})]},page.id)})})]})}),showVerificationPopup\u0026\u0026_jsx(`div`,{className:`mint-absolute mint-bottom-full mint-left-0 mint-right-0 mint-mb-2 mint-z-50`,children:_jsxs(`div`,{className:`mint-bg-white dark:mint-bg-zinc-900 mint-border mint-border-gray-200 dark:mint-border-zinc-700 mint-shadow-2xl mint-rounded-xl mint-overflow-hidden animate-expand-up`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-justify-between mint-px-3 mint-py-2 mint-border-b mint-border-gray-200 dark:mint-border-zinc-700 mint-bg-gray-50 dark:mint-bg-zinc-800/50`,children:[_jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-2`,children:[_jsx(`div`,{className:`mint-w-5 mint-h-5 mint-rounded-full bg-primary dark:bg-primary-light mint-text-white mint-text-xs mint-font-bold mint-flex mint-items-center mint-justify-center mint-leading-none`,children:verificationSteps.length}),_jsx(`span`,{className:`mint-text-sm mint-font-semibold mint-text-gray-900 dark:mint-text-white mint-leading-none`,children:verificationComplete?`Verification Complete`:`Verifying...`})]}),verificationComplete\u0026\u0026_jsx(`button`,{onClick:()=>setShowVerificationPopup(false),className:`mint-p-1 mint-rounded-md hover:mint-bg-gray-200 dark:hover:mint-bg-zinc-700 mint-transition-colors mint-flex-shrink-0`,children:_jsx(`svg`,{className:`mint-w-4 mint-h-4 mint-text-gray-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 18L18 6M6 6l12 12`})})})]}),_jsx(`div`,{className:`mint-p-3 mint-space-y-2`,children:verificationSteps.map((step,index)=>{const isChecked=index\u003c=currentVerificationIndex;const isActive=index===currentVerificationIndex\u0026\u0026!verificationComplete;return _jsxs(`div`,{className:`mint-flex mint-items-center mint-gap-3 mint-p-2 mint-rounded-lg mint-transition-all mint-duration-300 ${isActive?`bg-primary/5 dark:bg-primary-light/5`:``}`,children:[_jsx(`div`,{className:`mint-flex-shrink-0 mint-w-6 mint-h-6 mint-rounded-md mint-border-2 mint-flex mint-items-center mint-justify-center mint-transition-all mint-duration-300 ${isChecked?`bg-primary dark:bg-primary-light border-primary dark:border-primary-light`:`mint-border-gray-300 dark:mint-border-zinc-600`}`,children:isChecked\u0026\u0026_jsx(`svg`,{className:`mint-w-4 mint-h-4 mint-text-white animate-check`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})})}),_jsx(`span`,{className:`mint-text-sm mint-font-medium mint-transition-all mint-duration-300 ${isChecked?`mint-text-gray-900 dark:mint-text-white`:`mint-text-gray-400 dark:mint-text-gray-500`}`,children:step.label}),isActive\u0026\u0026_jsx(`div`,{className:`mint-ml-auto`,children:_jsxs(`svg`,{className:`mint-w-4 mint-h-4 text-primary dark:text-primary-light mint-animate-spin`,fill:`none`,viewBox:`0 0 24 24`,children:[_jsx(`circle`,{className:`mint-opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),_jsx(`path`,{className:`mint-opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})})]},step.id)})}),verificationComplete\u0026\u0026_jsx(`div`,{className:`mint-px-3 mint-pb-3`,children:_jsxs(`button`,{onClick:handleVerificationComplete,className:`mint-w-full mint-flex mint-items-center mint-justify-center mint-gap-2 mint-px-4 mint-py-2.5 mint-rounded-lg bg-primary dark:bg-primary-light mint-text-white mint-font-medium hover:mint-opacity-90 mint-transition-all mint-text-sm`,children:[_jsxs(`span`,{children:[`Continue to `,nextPage?.title]}),_jsx(`svg`,{className:`mint-w-4 mint-h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:_jsx(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]})})]})})]})}),_jsx(`style`,{children:`\n @keyframes expand-up {\n from {\n transform: translateY(8px) scale(0.98);\n opacity: 0;\n }\n to {\n transform: translateY(0) scale(1);\n opacity: 1;\n }\n }\n .animate-expand-up {\n animation: expand-up 0.2s ease-out;\n }\n @keyframes check {\n from {\n transform: scale(0);\n }\n to {\n transform: scale(1);\n }\n }\n .animate-check {\n animation: check 0.2s ease-out;\n }\n `})]})};return _jsxs(`div`,{className:`mint-mx-auto mint-px-4 lg:mint-px-8 mint-flex mint-flex-col`,children:[_jsx(SettingsNavInternal,{}),_jsx(`div`,{className:`mint-rounded-2xl mint-shadow-sm mint-flex-1`,children:_jsxs(`div`,{className:`mint-grid mint-gap-8 lg:mint-gap-10 mint-items-start`,style:{gridTemplateColumns:`minmax(0, 0.8fr) minmax(0, 1.2fr)`},children:[_jsx(`div`,{className:`prose prose-gray dark:prose-invert mint-max-w-none mint-pr-2`,children:_jsx(ActiveContent,{})}),_jsx(`div`,{className:`mint-sticky mint-top-20`,children:_jsx(`div`,{style:{borderRadius:`0.5rem`,overflow:`hidden`,background:`#020617`,height:`calc(100vh - 180px)`},children:_jsx(`iframe`,{ref:iframeRef,src:(()=>{const src=previewSrc+`\u0026theme=`+getCurrentColorInHexadecimal()+(iframeState.params.iframeUrl?`\u0026iframeUrl=`+encodeURIComponent(iframeState.params.iframeUrl):``);return src})(),title:`App preview`,style:{width:`100%`,height:`calc(100vh - 180px)`,border:`0`},allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:true})})})]})})]})};function _createMdxContent(props){const _components={a:`a`,code:`code`,h1:`h1`,h3:`h3`,h4:`h4`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,_MdxComponentBoundary}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsx(_MdxComponentBoundary,{name:`SideBySideLayout`,children:_jsxs(SideBySideLayout,{previewSrc:`https://stripe-sandbox.sampleapp.ai/accept-payments-with-stripe-checkout?framework=js-html-ruby\u0026isFrame=true`,children:[_jsx(_MdxComponentBoundary,{name:`Architecture`,children:_jsxs(Architecture,{value:`JavaScript SDK`,label:`JavaScript SDK`,children:[_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-ruby`,label:`HTML + Ruby`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-ruby/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-ruby`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:2,linesEnd:4,title:`Install the Stripe Ruby library`,children:[_jsx(_components.p,{children:`Install the Stripe ruby gem and require it in your code. Alternatively, if you’re starting from scratch and need a Gemfile, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`gem`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Bundler (add to Gemfile):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`gem `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:82,linesEnd:103,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:89,linesEnd:91,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:9,linesEnd:9,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:14,linesEnd:24,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:2,linesEnd:2,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:15,linesEnd:35,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:27,linesEnd:27,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:33,linesEnd:34,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:37,linesEnd:62,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:41,linesEnd:48,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:50,linesEnd:59,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:72,linesEnd:86,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your Ruby server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`ruby`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` server.rb`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:79,linesEnd:86,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:92,linesEnd:98,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:70,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:84,linesEnd:85,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:41,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-nodejs`,label:`HTML + Node.js`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-nodejs/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-nodejs`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:3,linesEnd:4,title:`Install the Stripe Node library`,children:[_jsx(_components.p,{children:`Install the package and import it in your code. Alternatively, if you’re starting from scratch and need a package.json file, download the project files using the Download link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:86,linesEnd:108,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:92,linesEnd:95,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:10,linesEnd:15,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:20,linesEnd:25,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:1,linesEnd:3,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:5,linesEnd:15,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:17,linesEnd:25,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:27,linesEnd:35,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:52,linesEnd:60,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:62,linesEnd:75,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:77,linesEnd:85,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:1,linesEnd:20,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your Node server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:88,linesEnd:88,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:94,linesEnd:100,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:68,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:86,linesEnd:87,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:42,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:111,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:111,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:111,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:111,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-php`,label:`HTML + PHP`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-php/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-php`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:6,linesEnd:6,title:`Install the Stripe PHP library`,children:[_jsx(_components.p,{children:`Install the library with composer and initialize with your secret API key. Alternatively, if you’re starting from scratch and need a composer.json file, download the files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Composer:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`composer`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` require`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe/stripe-php`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:63,linesEnd:84,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:69,linesEnd:72,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:9,linesEnd:10,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:14,linesEnd:22,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:1,linesEnd:2,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:16,linesEnd:22,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:24,linesEnd:27,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:29,linesEnd:34,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:37,linesEnd:39,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:41,linesEnd:48,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:50,linesEnd:61,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:22,linesEnd:86,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your PHP server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`php`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -S`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` 127.0.0.1:4242`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --docroot=public`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:8,linesEnd:25,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:74,linesEnd:77,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:49,linesEnd:59,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:65,linesEnd:66,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`charge.php`,linesStart:14,linesEnd:28,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:41,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:41,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:41,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:41,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-python`,label:`HTML + Python`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:7,linesEnd:10,title:`Install the Stripe Python package`,children:[_jsx(_components.p,{children:`Install the Stripe package and import it in your code. Alternatively, if you’re starting from scratch and need a requirements.txt file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`pip:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`pip3`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:90,linesEnd:117,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:102,linesEnd:104,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:9,linesEnd:9,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:14,linesEnd:24,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:2,linesEnd:2,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:15,linesEnd:35,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:27,linesEnd:27,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:33,linesEnd:34,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:37,linesEnd:62,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:41,linesEnd:48,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:50,linesEnd:59,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:72,linesEnd:86,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your Python server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`python3`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -m`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` flask`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --port=4242`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:92,linesEnd:99,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:105,linesEnd:111,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:80,linesEnd:89,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:97,linesEnd:98,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:54,linesEnd:75,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-go`,label:`HTML + Go`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-go/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-go`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:17,linesEnd:19,title:`Set up your server`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a go.mod file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Go:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` get`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` github.com/stripe/stripe-go/v84`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:144,linesEnd:177,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:150,linesEnd:153,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:9,linesEnd:9,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:14,linesEnd:24,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:2,linesEnd:2,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:15,linesEnd:35,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:27,linesEnd:27,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:33,linesEnd:34,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:37,linesEnd:62,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:41,linesEnd:48,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:50,linesEnd:59,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:72,linesEnd:86,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your Go server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` server.go`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:148,linesEnd:148,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:156,linesEnd:163,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:11,linesEnd:12,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe customer and paymentmethod packages. Use these packages to store information about your customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:126,linesEnd:139,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:146,linesEnd:147,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:74,linesEnd:109,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-net`,label:`HTML + .NET`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-net/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-net`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:34,linesEnd:56,title:`Install the Stripe.net library`,children:[_jsx(_components.p,{children:`Install the package with .NET or NuGet. Alternatively, if you’re starting from scratch, download the files which contains a configured .csproj file.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`dotnet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`NuGet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`Install-Package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:82,linesEnd:99,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:88,linesEnd:92,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:9,linesEnd:9,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:14,linesEnd:24,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:2,linesEnd:2,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:15,linesEnd:35,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:27,linesEnd:27,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:33,linesEnd:34,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:37,linesEnd:62,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:41,linesEnd:48,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:50,linesEnd:59,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:72,linesEnd:86,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your ASP.NET MVC server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:102,linesEnd:147,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:93,linesEnd:96,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:60,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:84,linesEnd:85,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:149,linesEnd:187,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:203,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-html-java`,label:`HTML + Java`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-java/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-checkout-prebuilt-subscription-java`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:137,linesEnd:142,title:`Install the Stripe Java library`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a sample pom.xml file (for Maven), download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Maven:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`xml`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`xml`,children:_jsxs(_components.code,{language:`xml`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`com.stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`stripe-java`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`{VERSION}`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`implementation \"com.stripe:stripe-java:{VERSION}\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:170,linesEnd:210,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:181,linesEnd:187,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:9,linesEnd:9,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Use Stripe.js to remain PCI compliant by ensuring that payment details are sent directly to Stripe without hitting your server. Always load Stripe.js from `,_jsx(_components.code,{children:`js.stripe.com`}),` to remain compliant. Don’t include the script in a bundle or host it yourself.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:14,linesEnd:24,title:`Define the payment form`,children:_jsxs(_components.p,{children:[`Add one empty placeholder `,_jsx(_components.code,{children:`div`}),` to your checkout form for each Element that you’ll mount. Stripe inserts an iframe into each `,_jsx(_components.code,{children:`div`}),` to securely collect the customer’s email address and payment information.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:2,linesEnd:2,title:`Initialize Stripe.js`,children:[_jsx(_components.p,{children:`Initialize Stripe.js with your publishable API key. You’ll use Stripe.js to create the Payment Element and complete the payment on the client.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` This is a public sample test API key. Don’t submit any personally identifiable information in requests made with this key.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:15,linesEnd:35,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:27,linesEnd:27,title:`Initialize Stripe Elements`,children:_jsx(_components.p,{children:`Initialize the Stripe Elements UI library with the client secret. Elements manages the UI components you need to collect payment details.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:33,linesEnd:34,title:`Create the PaymentElement`,children:_jsxs(_components.p,{children:[`Create a `,_jsx(_components.code,{children:`PaymentElement`}),` and mount it to the placeholder `,_jsx(_components.code,{children:`\u003cdiv>`}),` in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the PaymentIntent, allowing your customer to select a payment method. The form automatically collects the associated payment details for the selected payment method type.`]})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:37,linesEnd:62,title:`Handle the submit event`,children:_jsx(_components.p,{children:`Listen to the form’s submit event to know when to confirm the payment through the Stripe API.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:41,linesEnd:48,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`confirmPayment`}),` with the Element instance and a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:50,linesEnd:59,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/complete.js`,linesStart:72,linesEnd:86,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run your server and go to `,_jsx(_components.code,{children:`localhost:4242/checkout.html`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`java`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -cp`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` target/sample-jar-with-dependencies.jar`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` com.stripe.sample.Server`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:172,linesEnd:179,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:188,linesEnd:203,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.html`,linesStart:15,linesEnd:15,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/checkout.js`,linesStart:46,linesEnd:46,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:25,linesEnd:27,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe PaymentMethod and Customer models. Use these models to store information about your Customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:146,linesEnd:169,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:177,linesEnd:178,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:111,linesEnd:134,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:213,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-ruby`,label:`React + Ruby`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-ruby/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-ruby`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Gemfile`,linesStart:1,linesEnd:4,title:`Install the Stripe Ruby library`,children:[_jsx(_components.p,{children:`Install the Stripe ruby gem and require it in your code. Alternatively, if you’re starting from scratch and need a Gemfile, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`gem`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Bundler (add to Gemfile):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`gem `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:67,linesEnd:104,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:88,linesEnd:91,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:5,linesEnd:11,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:14,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:52,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the ElementsConsumer instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:73,title:`Add the PaymentElement`,children:_jsx(_components.p,{children:`Add PaymentElement to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:_jsx(_components.p,{children:`Customise the Payment Element UI by creating an Appearance object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:17,linesEnd:49,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:42,linesEnd:46,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:47,linesEnd:105,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:67,linesEnd:104,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:8,title:`Run the server application`,children:[_jsx(_components.p,{children:`Run the React app and the server. Go to localhost:3000/checkout to see your checkout page.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`ruby`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` server.rb`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:15,linesEnd:19,title:`Run the application`,children:[_jsx(_components.p,{children:`Run the React app and go to localhost:3000/checkout.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:1,linesEnd:75,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:9,linesEnd:24,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:92,linesEnd:98,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:72,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:83,linesEnd:86,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:41,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-nodejs`,label:`React + Node.js`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-nodejs/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-nodejs`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:4,title:`Install the Stripe Node library`,children:[_jsx(_components.p,{children:`Install the package and import it in your code. Alternatively, if you’re starting from scratch and need a package.json file, download the project files using the Download link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:66,linesEnd:106,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:91,linesEnd:93,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:1,linesEnd:3,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:14,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:51,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the ElementsConsumer instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:74,title:`Add the PaymentElement`,children:_jsxs(_components.p,{children:[`Add `,_jsx(_components.code,{children:`PaymentElement`}),` to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:[_jsxs(_components.p,{children:[`Customise the Payment Element UI by creating an `,_jsx(_components.code,{children:`Appearance`}),` object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Make sure to open the preview on the right to see your changes live.`})})]})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:37,linesEnd:48,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:47,linesEnd:104,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:66,linesEnd:106,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:110,linesEnd:110,title:`Run the application`,children:[_jsx(_components.p,{children:`Run the React app and the server. Go to localhost:3000/checkout to see your checkout page.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:9,linesEnd:26,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:94,linesEnd:100,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:70,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:86,linesEnd:87,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:42,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:1,linesEnd:75,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-php`,label:`React + PHP`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-php/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-php`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`composer.json`,linesStart:1,linesEnd:7,title:`Install the Stripe PHP library`,children:[_jsx(_components.p,{children:`Install the library with composer and initialize with your secret API key. Alternatively, if you’re starting from scratch and need a composer.json file, download the files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Composer:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`composer`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` require`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe/stripe-php`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:64,linesEnd:80,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:70,linesEnd:72,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:5,linesEnd:7,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:14,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:49,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the ElementsConsumer instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:73,title:`Add the PaymentElement`,children:_jsxs(_components.p,{children:[`Add `,_jsx(_components.code,{children:`PaymentElement`}),` to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:[_jsx(_components.p,{children:`Customise the Payment Element UI by creating an Appearance object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` Parts of the preview demo might not match your actual checkout page. The above settings represent only a subset of the Appearance object’s variables and the Appearance object only controls certain attributes of Stripe Elements. You’re responsible for styling the rest of your checkout page.`]})]})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:42,linesEnd:48,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:53,linesEnd:74,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:42,linesEnd:90,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:92,title:`Run the server application`,children:[_jsxs(_components.p,{children:[`Run the React app and the server. Go to `,_jsx(_components.code,{children:`localhost:3000/checkout`}),` to see your checkout page.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`php`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -S`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` 127.0.0.1:4242`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --docroot=public`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:1,linesEnd:53,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run the React app and go to `,_jsx(_components.code,{children:`localhost:3000/checkout`}),`.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:1,linesEnd:75,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:76,linesEnd:105,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:8,linesEnd:25,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:73,linesEnd:79,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:30,linesEnd:34,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:49,linesEnd:59,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:65,linesEnd:66,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`charge.php`,linesStart:21,linesEnd:28,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_components.h4,{children:`Collect billing address details`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:65,linesEnd:65,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:92,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:92,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:92,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-python`,label:`React + Python`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-python/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-python`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:5,linesEnd:7,title:`Install the Stripe Python package`,children:[_jsx(_components.p,{children:`Install the Stripe package and import it in your code. Alternatively, if you’re starting from scratch and need a requirements.txt file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`pip:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`pip3`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:78,linesEnd:117,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:101,linesEnd:104,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:1,linesEnd:12,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:14,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:52,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the ElementsConsumer instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:73,title:`Add the PaymentElement`,children:_jsxs(_components.p,{children:[`Add `,_jsx(_components.code,{children:`PaymentElement`}),` to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:[_jsx(_components.p,{children:`Customise the Payment Element UI by creating an Appearance object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` Parts of the preview demo might not match your actual checkout page. The above settings represent only a subset of the Appearance object’s variables and the Appearance object only controls certain attributes of Stripe Elements. You’re responsible for styling the rest of your checkout page.`]})]})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:17,linesEnd:35,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:42,linesEnd:48,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:47,linesEnd:104,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:78,linesEnd:117,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:119,linesEnd:120,title:`Run the server application`,children:[_jsxs(_components.p,{children:[`Run the React app and the server. Go to `,_jsx(_components.code,{children:`localhost:3000/checkout`}),` to see your checkout page.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`python3`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -m`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` flask`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --port=4242`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/index.js`,linesStart:1,linesEnd:10,title:`Run the application`,children:[_jsxs(_components.p,{children:[`Run the React app and go to `,_jsx(_components.code,{children:`localhost:3000/checkout`}),`.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:18,linesEnd:34,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:105,linesEnd:111,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send email receipts`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:82,linesEnd:88,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:96,linesEnd:98,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:54,linesEnd:76,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-go`,label:`React + Go`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-go/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-go`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`go.mod`,linesStart:1,linesEnd:6,title:`Set up your server`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a go.mod file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Go:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` get`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` github.com/stripe/stripe-go/v84`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:111,linesEnd:178,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:150,linesEnd:154,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:5,linesEnd:11,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:1,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:52,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the ElementsConsumer instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:73,title:`Add the PaymentElement`,children:_jsxs(_components.p,{children:[`Add `,_jsx(_components.code,{children:`PaymentElement`}),` to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:_jsx(_components.p,{children:`Customise the Payment Element UI by creating an Appearance object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the return_url.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:42,linesEnd:48,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:47,linesEnd:104,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the return_url, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:111,linesEnd:178,title:`Use a webhook`,children:[_jsx(_components.p,{children:`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.`}),_jsxs(_components.p,{children:[`Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:19,linesEnd:28,title:`Run the server application`,children:[_jsx(_components.p,{children:`Run the React app and the server. Go to localhost:3000/checkout to see your checkout page.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Run the server:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` server.go`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:15,linesEnd:19,title:`Run the application`,children:[_jsx(_components.p,{children:`Run the React app and go to localhost:3000/checkout.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Run the client:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:35,linesEnd:58,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:156,linesEnd:162,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:11,linesEnd:14,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe customer and paymentmethod packages. Use these packages to store information about your customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:128,linesEnd:139,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:145,linesEnd:154,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:74,linesEnd:109,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-net`,label:`React + .NET`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-net/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-net`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:29,linesEnd:36,title:`Install the Stripe.net library`,children:[_jsx(_components.p,{children:`Install the package with .NET or NuGet. Alternatively, if you’re starting from scratch, download the files which contains a configured .csproj file.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`dotnet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`NuGet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`Install-Package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:82,linesEnd:100,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:88,linesEnd:92,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:5,linesEnd:7,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:14,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:49,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the `,_jsx(_components.code,{children:`ElementsConsumer`}),` instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:73,title:`Add the PaymentElement`,children:_jsxs(_components.p,{children:[`Add `,_jsx(_components.code,{children:`PaymentElement`}),` to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:_jsx(_components.p,{children:`Customise the Payment Element UI by creating an Appearance object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:17,linesEnd:35,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:42,linesEnd:48,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:53,linesEnd:74,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:47,linesEnd:56,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:18,linesEnd:26,title:`Run the server application`,children:[_jsx(_components.p,{children:`Run the React app and the server. Go to localhost:3000/checkout to see your checkout page.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`dotnet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:15,linesEnd:16,title:`Run the application`,children:[_jsx(_components.p,{children:`Run the React app and go to localhost:3000/checkout.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:1,linesEnd:6,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:76,linesEnd:103,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:111,linesEnd:136,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:93,linesEnd:97,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send email receipts`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:62,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:84,linesEnd:85,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:149,linesEnd:187,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:51,linesEnd:53,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:47,linesEnd:56,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-react-java`,label:`React + Java`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`/guardian/stripe-sandbox/stripe-accept-payments-with-stripe-checkout-js-react-java.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-react-java`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`pom.xml`,linesStart:33,linesEnd:39,title:`Install the Stripe Java library`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a sample pom.xml file (for Maven), download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Maven:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`xml`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`xml`,children:_jsxs(_components.code,{language:`xml`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`com.stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`stripe-java`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`{VERSION}`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`implementation \"com.stripe:stripe-java:{VERSION}\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(_components.p,{children:[`Add the following dependency to your POM and replace `,` with the version number you want to use.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:144,linesEnd:211,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:182,linesEnd:187,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:1,linesEnd:3,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:14,linesEnd:17,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:22,linesEnd:31,title:`Fetch a PaymentIntent`,children:_jsxs(_components.p,{children:[`Immediately make a request to the endpoint on your server to create a new PaymentIntent as soon as your checkout page loads. The `,_jsx(_components.code,{children:`clientSecret`}),` returned by your endpoint is used to complete the payment.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:39,linesEnd:52,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service with the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:15,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:8,linesEnd:10,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements with a class component, use the `,_jsx(_components.code,{children:`ElementsConsumer`}),` instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:55,linesEnd:73,title:`Add the PaymentElement`,children:_jsxs(_components.p,{children:[`Add `,_jsx(_components.code,{children:`PaymentElement`}),` to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:33,linesEnd:37,title:`(Optional) Style the Payment Element`,children:[_jsxs(_components.p,{children:[`Customise the Payment Element UI by creating an `,_jsx(_components.code,{children:`Appearance`}),` object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`]}),_jsx(_components.p,{children:`Make sure to open the preview on the right to see your changes live.`})]})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:28,linesEnd:35,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:42,linesEnd:48,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CompletePage.jsx`,linesStart:53,linesEnd:74,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent_client_secret`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:144,linesEnd:211,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:137,linesEnd:142,title:`Run the server application`,children:[_jsx(_components.p,{children:`Run the React app and the server. Go to localhost:3000/checkout to see your checkout page.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`java`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -cp`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` target/sample-jar-with-dependencies.jar`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` com.stripe.sample.Server`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/App.jsx`,linesStart:1,linesEnd:53,title:`Run the application`,children:[_jsx(_components.p,{children:`Run the React app and go to localhost:3000/checkout.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:137,linesEnd:138,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:75,linesEnd:95,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:188,linesEnd:203,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:57,linesEnd:63,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:12,linesEnd:12,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:30,linesEnd:34,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:23,linesEnd:27,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe PaymentMethod and Customer models. Use these models to store information about your Customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:148,linesEnd:169,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:177,linesEnd:178,title:`Add the customer to the PaymentIntent`,children:_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details. Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:111,linesEnd:134,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/CheckoutForm.jsx`,linesStart:1,linesEnd:75,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`js-nextjs`,label:`Next.js`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`/guardian/stripe-sandbox/stripe-accept-payments-with-stripe-checkout-js-nextjs.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-js-nextjs`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:8,linesEnd:17,title:`Install the Stripe libraries`,children:[_jsx(_components.p,{children:`Install the packages and import them in your code. Alternatively, if you’re starting from scratch and need a package.json file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Install the libraries:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` next`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:76,linesEnd:88,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:81,linesEnd:84,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout page on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:8,linesEnd:10,title:`Add Stripe to your React app`,children:[_jsx(_components.p,{children:`Use the Stripe.js and the Stripe Elements UI library to stay PCI compliant by ensuring that payment details go directly to Stripe and never reach your server.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/react-stripe-js`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` @stripe/stripe-js`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:14,linesEnd:15,title:`Load Stripe.js`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`loadStripe()`}),` with your Stripe publishable API key to configure the Stripe library.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:85,linesEnd:93,title:`Initialize Stripe Elements`,children:_jsxs(_components.p,{children:[`Pass the resulting promise from `,_jsx(_components.code,{children:`loadStripe`}),` to the Elements provider. This allows the child components to access the Stripe service through the Elements consumer. Additionally, pass the client secret as an option to the Elements provider.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:21,linesEnd:24,title:`Set up the state`,children:_jsx(_components.p,{children:`Initialize some state to keep track of the payment, show errors, and manage the user interface.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:18,linesEnd:19,title:`Store a reference to Stripe`,children:_jsxs(_components.p,{children:[`Access the Stripe library in your CheckoutForm component by using the `,_jsx(_components.code,{children:`useStripe()`}),` and `,_jsx(_components.code,{children:`useElements()`}),` hooks. If you need to access Elements through a class component, use the ElementsConsumer instead.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:64,linesEnd:82,title:`Add the PaymentElement`,children:_jsx(_components.p,{children:`Add the PaymentElement to your payment form. It embeds an iframe with a dynamic form that collects payment details for a variety of payment methods. Your customer can pick a payment method type, and the form automatically collects all necessary payments details for their selection.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:86,linesEnd:88,title:`(Optional) Style the Payment Element`,children:[_jsx(_components.p,{children:`Customise the Payment Element UI by creating an Appearance object and passing it as an option to the Elements provider. Use your company’s colour scheme and font to make it match with the rest of your checkout page. Use custom fonts (for example, from Google Fonts) by initialising Elements with a font set.`}),_jsx(_components.p,{children:`Make sure to open the preview on the right to see your changes live.`})]})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:37,linesEnd:44,title:`Complete the payment`,children:_jsxs(_components.p,{children:[`When your customer clicks the pay button, call `,_jsx(_components.code,{children:`confirmPayment`}),` with the PaymentElement and pass a `,_jsx(_components.code,{children:`return_url`}),` to indicate where Stripe redirects the customer after they complete the payment. For payments that require authentication, Stripe displays a modal for 3D Secure authentication or redirects the customer to an authentication page, depending on the payment method. After the customer completes the authentication process, they’re redirected to the `,_jsx(_components.code,{children:`return_url`}),`.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:46,linesEnd:57,title:`Handle errors`,children:_jsx(_components.p,{children:`If there are any immediate errors (for example, your customer’s card is declined), Stripe.js returns an error. Show that error message to your customer so they can try again.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/success/page.jsx`,linesStart:45,linesEnd:84,title:`Show a payment status message`,children:_jsxs(_components.p,{children:[`When Stripe redirects the customer to the `,_jsx(_components.code,{children:`return_url`}),`, the `,_jsx(_components.code,{children:`payment_intent`}),` query parameter is appended by Stripe.js. Use this to retrieve the PaymentIntent status update and determine what to show to your customer.`]})})}),_jsx(_components.h3,{children:`❹ Handle post-payment events`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`app/api/webhooks/route.js`,linesStart:1,linesEnd:50,title:`Use a webhook`,children:[_jsxs(_components.p,{children:[`Stripe sends multiple events during the payment process and after the payment is complete. Create an event destination for a webhook endpoint to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow. Stripe recommends handling the `,_jsx(_components.code,{children:`payment_intent.succeeded`}),`, `,_jsx(_components.code,{children:`payment_intent.processing`}),`, and `,_jsx(_components.code,{children:`payment_intent.payment_failed`}),` events.`]}),_jsx(_components.p,{children:`Listen for these events rather than waiting for a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.`})]})}),_jsx(_components.h3,{children:`❺ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`package.json`,linesStart:3,linesEnd:6,title:`Run the application`,children:[_jsx(_components.p,{children:`Run the Next.js app. Go to localhost:3000 to see your checkout page.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` dev`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:1,linesEnd:95,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:1,linesEnd:95,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:5,linesEnd:22,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:85,linesEnd:87,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Send an email receipt`}),_jsx(_components.p,{children:`Stripe can send an email receipt to your customer using your brand logo and colour theme, which are configurable in the Dashboard.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:66,linesEnd:72,title:`Collect the customer's email address`,children:_jsx(_components.p,{children:`Add an input field to your payment form to collect the email address.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:21,linesEnd:21,title:`Add email to the state`,children:_jsx(_components.p,{children:`Add a variable to keep track of the email the customer enters.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`components/checkout.jsx`,linesStart:42,linesEnd:42,title:`Provide the email address to Stripe`,children:_jsxs(_components.p,{children:[`Pass the provided email address as the `,_jsx(_components.code,{children:`receipt_email`}),` value. Stripe sends an email receipt when the payment succeeds in live mode (but won’t send one in a sandbox).`]})})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:67,linesEnd:67,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:77,linesEnd:78,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:42,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:1,linesEnd:95,title:`Collect billing address details`,children:_jsx(_components.p,{children:`By default, the Payment Element only collects the necessary billing address details. To collect a customer’s full billing address (to calculate the tax for digital goods and services, for example) or shipping address, use the Address Element.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:1,linesEnd:95,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/page.jsx`,linesStart:1,linesEnd:95,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`app/api/webhooks/route.js`,linesStart:1,linesEnd:50,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})})]})}),_jsx(_MdxComponentBoundary,{name:`Architecture`,children:_jsxs(Architecture,{value:`iOS SDK`,label:`iOS SDK`,children:[_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ios-swift-ruby`,label:`Swift + Ruby`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-ruby-minimal/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-ruby-minimal`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:4,title:`Install the Stripe Ruby library`,children:[_jsx(_components.p,{children:`Install the Stripe ruby gem and require it in your code. Alternatively, if you’re starting from scratch and need a Gemfile, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`gem`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Bundler (add to Gemfile):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`gem `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:67,linesEnd:104,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:88,linesEnd:91,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:1,linesEnd:2,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above. Import the Stripe SDK into your checkout screen’s View Controller.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Swift Package Manager:`})}),_jsxs(_components.p,{children:[`In Xcode, select File > Add Package Dependencies… and enter `,_jsx(_components.code,{children:`https://github.com/stripe/stripe-ios-spm`}),` as the repository URL. Select the latest version number from our releases page, and add the StripePaymentSheet module to your app’s target.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:42,linesEnd:44,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:66,linesEnd:102,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:112,linesEnd:134,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:135,linesEnd:145,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:9,linesEnd:24,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:92,linesEnd:98,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:118,linesEnd:121,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:122,linesEnd:125,title:`Enable Apple Pay`,children:_jsx(_components.p,{children:`To enable Apple Pay, provide your Apple Pay Merchant ID and your Stripe account’s country code.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:121,linesEnd:121,title:`Use a custom primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/Info.plist`,linesStart:1,linesEnd:1,title:`Enable card scanning`,children:[_jsxs(_components.p,{children:[`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, set `,_jsx(_components.code,{children:`NSCameraUsageDescription`}),` in your application’s Info.plist, and provide a reason for accessing the camera (for example, “To scan cards”).`]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` Card scanning is only supported on devices running iOS 13 or higher.`]})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:72,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:83,linesEnd:86,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:41,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:147,linesEnd:160,title:`Collect local and international addresses`,children:_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ios-swift-nodejs`,label:`Swift + Node.js`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-nodejs/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-nodejs`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:3,linesEnd:4,title:`Install the Stripe Node library`,children:[_jsx(_components.p,{children:`Install the package and import it in your code. Alternatively, if you’re starting from scratch and need a package.json file, download the project files using the Download link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:66,linesEnd:106,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:91,linesEnd:93,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:1,linesEnd:2,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above. Import the Stripe SDK into your checkout screen’s View Controller.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Swift Package Manager:`})}),_jsxs(_components.p,{children:[`In Xcode, select File > Add Package Dependencies… and enter `,_jsx(_components.code,{children:`https://github.com/stripe/stripe-ios-spm`}),` as the repository URL. Select the latest version number from our releases page, and add the StripePaymentSheet module to your app’s target.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:42,linesEnd:44,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:66,linesEnd:102,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:112,linesEnd:134,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:135,linesEnd:145,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:9,linesEnd:26,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:94,linesEnd:100,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:120,linesEnd:120,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:122,linesEnd:125,title:`Enable Apple Pay`,children:_jsx(_components.p,{children:`To enable Apple Pay, provide your Apple Pay Merchant ID and your Stripe account’s country code.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:121,linesEnd:121,title:`Customise the primary button colour`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/Info.plist`,linesStart:1,linesEnd:8,title:`Enable card scanning`,children:[_jsxs(_components.p,{children:[`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, set `,_jsx(_components.code,{children:`NSCameraUsageDescription`}),` in your application’s Info.plist, and provide a reason for accessing the camera (for example, “To scan cards”).`]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` Card scanning is only supported on devices running iOS 13 or higher.`]})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:70,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:86,linesEnd:87,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:42,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:9,linesEnd:17,title:`Collect local and international addresses`,children:_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ios-swift-php`,label:`Swift + PHP`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-php/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-php`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:3,linesEnd:6,title:`Install the Stripe PHP library`,children:[_jsx(_components.p,{children:`Install the library with composer and initialize with your secret API key. Alternatively, if you’re starting from scratch and need a composer.json file, download the files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Composer:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`composer`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` require`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe/stripe-php`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:64,linesEnd:80,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:69,linesEnd:72,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:1,linesEnd:2,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above. Import the Stripe SDK into your checkout screen’s View Controller.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Swift Package Manager:`})}),_jsxs(_components.p,{children:[`In Xcode, select File > Add Package Dependencies… and enter `,_jsx(_components.code,{children:`https://github.com/stripe/stripe-ios-spm`}),` as the repository URL. Select the latest version number from our releases page, and add the StripePaymentSheet module to your app’s target.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:42,linesEnd:44,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:66,linesEnd:102,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:112,linesEnd:134,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:135,linesEnd:145,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:8,linesEnd:25,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:73,linesEnd:79,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:118,linesEnd:121,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:122,linesEnd:125,title:`Enable Apple Pay`,children:_jsx(_components.p,{children:`To enable Apple Pay, provide your Apple Pay Merchant ID and your Stripe account’s country code.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:121,linesEnd:121,title:`Use a custom primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/Info.plist`,linesStart:6,linesEnd:7,title:`Enable card scanning`,children:[_jsxs(_components.p,{children:[`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, set `,_jsx(_components.code,{children:`NSCameraUsageDescription`}),` in your application’s Info.plist, and provide a reason for accessing the camera (for example, “To scan cards”).`]}),_jsx(_components.p,{children:`Note: Card scanning is only supported on devices running iOS 13 or higher.`})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:49,linesEnd:59,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:65,linesEnd:66,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`charge.php`,linesStart:14,linesEnd:28,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:147,linesEnd:160,title:`Collect local and international addresses`,children:_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ios-swift-python`,label:`Swift + Python`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-python/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-python`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:5,linesEnd:7,title:`Install the Stripe Python package`,children:[_jsx(_components.p,{children:`Install the Stripe package and import it in your code. Alternatively, if you’re starting from scratch and need a requirements.txt file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`pip:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`pip3`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:78,linesEnd:117,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:101,linesEnd:104,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:1,linesEnd:2,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above. Import the Stripe SDK into your checkout screen’s View Controller.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Swift Package Manager:`})}),_jsxs(_components.p,{children:[`In Xcode, select File > Add Package Dependencies… and enter `,_jsx(_components.code,{children:`https://github.com/stripe/stripe-ios-spm`}),` as the repository URL. Select the latest version number from our releases page, and add the StripePaymentSheet module to your app’s target.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:42,linesEnd:44,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:66,linesEnd:102,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:112,linesEnd:145,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:135,linesEnd:144,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Run the application`,children:[_jsx(_components.p,{children:`Run your Python server and go to your iOS simulator or device.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`python3`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -m`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` flask`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --port=4242`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:18,linesEnd:34,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:105,linesEnd:111,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:118,linesEnd:120,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Apple Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:122,linesEnd:125,title:`Enable Apple Pay`,children:_jsx(_components.p,{children:`To enable Apple Pay, provide your Apple Pay Merchant ID and your Stripe account’s country code.`})})}),_jsx(_components.h4,{children:`Custom primary button color`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:121,linesEnd:121,title:`Customize the primary button`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/Info.plist`,linesStart:1,linesEnd:9,title:`Enable card scanning`,children:[_jsxs(_components.p,{children:[`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, set `,_jsx(_components.code,{children:`NSCameraUsageDescription`}),` in your application’s Info.plist, and provide a reason for accessing the camera (for example, “To scan cards”).`]}),_jsx(_components.p,{children:`Note: Card scanning is only supported on devices running iOS 13 or higher.`})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:82,linesEnd:88,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:96,linesEnd:98,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:54,linesEnd:76,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:9,linesEnd:17,title:`Configure Address Element`,children:_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ios-swift-go`,label:`Swift + Go`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-go/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-go`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:6,title:`Set up your server`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a go.mod file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Go:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` get`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` github.com/stripe/stripe-go/v84`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:144,linesEnd:177,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:150,linesEnd:153,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:1,linesEnd:2,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above. Import the Stripe SDK into your checkout screen’s View Controller.`}),_jsxs(_components.p,{children:[`In Xcode, select File > Add Package Dependencies… and enter `,_jsx(_components.a,{href:`https://github.com/stripe/stripe-ios-spm`,children:`https://github.com/stripe/stripe-ios-spm`}),` as the repository URL. Select the latest version number from our releases page, and add the StripePaymentSheet module to your app’s target.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:42,linesEnd:44,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:66,linesEnd:102,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:112,linesEnd:145,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:135,linesEnd:144,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:35,linesEnd:58,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:156,linesEnd:162,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Payment customization options`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:120,linesEnd:120,title:`Enable delayed payment methods`,children:_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:122,linesEnd:125,title:`Enable Apple Pay`,children:_jsx(_components.p,{children:`Configure Apple Pay by setting the merchant ID and country code in the PaymentSheet configuration.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:121,linesEnd:121,title:`Custom primary button color`,children:_jsx(_components.p,{children:`Set a custom color for the primary button in the PaymentSheet configuration.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/Info.plist`,linesStart:1,linesEnd:9,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, set NSCameraUsageDescription in your application’s Info.plist, and provide a reason for accessing the camera (for example, “To scan cards”).`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` Card scanning is only supported on devices running iOS 13 or higher.`]})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:11,linesEnd:14,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe customer and paymentmethod packages. Use these packages to store information about your customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:128,linesEnd:139,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:145,linesEnd:154,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:74,linesEnd:109,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:127,linesEnd:129,title:`Collect shipping or billing addresses`,children:_jsx(_components.p,{children:`Configure the shipping details in the PaymentSheet configuration to collect addresses from your customers.`})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:192,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ios-swift-net`,label:`Swift + .NET`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-net/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ios-swift-net`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:29,linesEnd:36,title:`Install the Stripe.net library`,children:[_jsx(_components.p,{children:`Install the package with .NET or NuGet. Alternatively, if you’re starting from scratch, download the files which contains a configured .csproj file.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`dotnet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`NuGet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`Install-Package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:82,linesEnd:99,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:88,linesEnd:92,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:1,linesEnd:2,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above. Import the Stripe SDK into your checkout screen’s View Controller.`}),_jsxs(_components.p,{children:[`In Xcode, select File > Add Package Dependencies… and enter `,_jsx(_components.a,{href:`https://github.com/stripe/stripe-ios-spm`,children:`https://github.com/stripe/stripe-ios-spm`}),` as the repository URL. Select the latest version number from our releases page, and add the StripePaymentSheet module to your app’s target.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:42,linesEnd:44,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:66,linesEnd:102,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:112,linesEnd:134,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:135,linesEnd:145,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Run the application`,children:[_jsx(_components.p,{children:`Run your ASP.NET MVC server.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:111,linesEnd:136,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:93,linesEnd:97,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Payment customization options`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:120,linesEnd:120,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:122,linesEnd:125,title:`Enable Apple Pay`,children:_jsx(_components.p,{children:`To enable Apple Pay, provide your Apple Pay Merchant ID and your Stripe account’s country code.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:121,linesEnd:121,title:`Use a custom primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`ios/Info.plist`,linesStart:1,linesEnd:9,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, set NSCameraUsageDescription in your application’s Info.plist, and provide a reason for accessing the camera (for example, “To scan cards”).`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` Card scanning is only supported on devices running iOS 13 or higher.`]})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:62,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:84,linesEnd:85,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:149,linesEnd:187,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`ios/CheckoutViewController.swift`,linesStart:127,linesEnd:129,title:`Collect local and international shipping or billing addresses`,children:_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`})})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})})]})}),_jsx(_MdxComponentBoundary,{name:`Architecture`,children:_jsxs(Architecture,{value:`Android SDK`,label:`Android SDK`,children:[_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-kotlin-ruby`,label:`Kotlin + Ruby`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-ruby/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-ruby`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Gemfile`,linesStart:1,linesEnd:4,title:`Install the Stripe Ruby library`,children:[_jsx(_components.p,{children:`Install the Stripe ruby gem and require it in your code. Alternatively, if you’re starting from scratch and need a Gemfile, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`gem`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Bundler (add to Gemfile):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`gem `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:67,linesEnd:104,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:88,linesEnd:91,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:1,linesEnd:38,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.kt`,linesStart:1,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:183,linesEnd:225,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:183,linesEnd:225,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:9,linesEnd:24,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:92,linesEnd:98,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:249,linesEnd:251,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsxs(_components.p,{children:[`Enable Google Pay by passing a `,_jsx(_components.code,{children:`PaymentSheet.GooglePayConfiguration`}),` object with the Google Pay environment (production or test) and the country code of your business when initializing `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),`.`]})})}),_jsx(_components.h4,{children:`Customize the primary button color`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:252,linesEnd:262,title:`Customize button appearance`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:1,linesEnd:38,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:72,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:83,linesEnd:86,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:41,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-kotlin-nodejs`,label:`Kotlin + Node.js`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-nodejs/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-nodejs`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:4,title:`Install the Stripe Node library`,children:[_jsx(_components.p,{children:`Install the package and import it in your code. Alternatively, if you’re starting from scratch and need a package.json file, download the project files using the Download link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:66,linesEnd:106,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:91,linesEnd:93,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:21,linesEnd:29,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.kt`,linesStart:6,linesEnd:13,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:244,linesEnd:272,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:9,linesEnd:26,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:94,linesEnd:100,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:251,linesEnd:251,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay in AndroidManifest`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsxs(_components.p,{children:[`Enable Google Pay by passing a `,_jsx(_components.code,{children:`PaymentSheet.GooglePayConfiguration`}),` object with the Google Pay environment (production or test) and the country code of your business when initializing `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),`.`]})})}),_jsx(_components.h4,{children:`Customize the primary button`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:252,linesEnd:262,title:`Customize the primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:21,linesEnd:29,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:70,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:86,linesEnd:87,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:42,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-kotlin-php`,label:`Kotlin + PHP`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-php/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-php`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`composer.json`,linesStart:1,linesEnd:6,title:`Install the Stripe PHP library`,children:[_jsx(_components.p,{children:`Install the library with composer and initialize with your secret API key. Alternatively, if you’re starting from scratch and need a composer.json file, download the files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Composer:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`composer`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` require`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe/stripe-php`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:64,linesEnd:80,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:69,linesEnd:72,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:21,linesEnd:23,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.kt`,linesStart:1,linesEnd:13,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:244,linesEnd:272,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:183,linesEnd:225,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:82,linesEnd:86,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:8,linesEnd:25,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:73,linesEnd:79,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:251,linesEnd:251,title:`Enable delayed payment methods`,children:_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`allowsDelayedPaymentMethods`}),` to true to enable delayed payment methods.`]})})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:5,title:`Enable Google Pay in AndroidManifest`,children:_jsx(_components.p,{children:`Add the Google Pay API meta-data to your AndroidManifest.xml file.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize the primary button`}),_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:252,linesEnd:262,title:`Customize appearance`,children:_jsx(_components.p,{children:`Customize the Payment Sheet appearance by configuring colors, fonts, and other visual properties.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:21,linesEnd:23,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:49,linesEnd:59,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:65,linesEnd:66,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`charge.php`,linesStart:21,linesEnd:28,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect local and international addresses`}),_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-kotlin-python`,label:`Kotlin + Python`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-python/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-python`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:5,linesEnd:7,title:`Install the Stripe Python package`,children:[_jsx(_components.p,{children:`Install the Stripe package and import it in your code. Alternatively, if you’re starting from scratch and need a requirements.txt file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`pip:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`pip3`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:78,linesEnd:117,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:101,linesEnd:104,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/build.gradle`,linesStart:1,linesEnd:1,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.kt`,linesStart:6,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Run the application`,children:[_jsx(_components.p,{children:`Run your Python server and go to your Android simulator or device.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`python3`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -m`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` flask`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --port=4242`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:18,linesEnd:34,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:105,linesEnd:111,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:251,linesEnd:251,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay in AndroidManifest`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize appearance`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:252,linesEnd:262,title:`Customize primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/build.gradle`,linesStart:1,linesEnd:1,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:82,linesEnd:88,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:96,linesEnd:98,title:`Add the customer to the PaymentIntent`,children:_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details. Learn more about the most effective way to apply setup_future_usage. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:54,linesEnd:76,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-kotlin-go`,label:`Kotlin + Go`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-go/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-go`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`go.mod`,linesStart:1,linesEnd:6,title:`Set up your server`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a go.mod file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Go:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` get`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` github.com/stripe/stripe-go/v84`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:111,linesEnd:178,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:150,linesEnd:154,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:1,linesEnd:38,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.kt`,linesStart:1,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:19,linesEnd:28,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:28,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:35,linesEnd:58,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:156,linesEnd:162,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:249,linesEnd:251,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize appearance`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:252,linesEnd:262,title:`Customize primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:1,linesEnd:38,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:9,linesEnd:14,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe customer and paymentmethod packages. Use these packages to store information about your customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:126,linesEnd:139,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:144,linesEnd:154,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:74,linesEnd:109,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:44,linesEnd:53,title:`Collect shipping or billing addresses`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-kotlin-net`,label:`Kotlin + .NET`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-net/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-kotlin-net`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:29,linesEnd:36,title:`Install the Stripe.net library`,children:[_jsx(_components.p,{children:`Install the package with .NET or NuGet. Alternatively, if you’re starting from scratch, download the files which contains a configured .csproj file.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`dotnet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`NuGet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`Install-Package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:82,linesEnd:100,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:88,linesEnd:92,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:21,linesEnd:29,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.kt`,linesStart:6,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:183,linesEnd:225,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:18,linesEnd:26,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:111,linesEnd:136,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:93,linesEnd:97,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:249,linesEnd:262,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize appearance`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:252,linesEnd:261,title:`Customize primary button`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:39,linesEnd:61,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:62,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:84,linesEnd:85,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:149,linesEnd:187,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.kt`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:47,linesEnd:56,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-ruby`,label:`Java + Ruby`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-ruby/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-ruby`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Gemfile`,linesStart:1,linesEnd:4,title:`Install the Stripe Ruby library`,children:[_jsx(_components.p,{children:`Install the Stripe ruby gem and require it in your code. Alternatively, if you’re starting from scratch and need a Gemfile, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Terminal:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`gem`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Bundler (add to Gemfile):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`ruby`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`ruby`,children:_jsxs(_components.code,{language:`ruby`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`gem `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:67,linesEnd:104,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:88,linesEnd:91,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:1,linesEnd:25,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:1,linesEnd:15,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:89,linesEnd:128,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:142,linesEnd:154,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:166,linesEnd:177,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:89,linesEnd:128,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:9,linesEnd:24,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:92,linesEnd:98,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:143,linesEnd:144,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:147,linesEnd:149,title:`Configure Google Pay`,children:_jsxs(_components.p,{children:[`Enable Google Pay by passing a `,_jsx(_components.code,{children:`PaymentSheet.GooglePayConfiguration`}),` object with the Google Pay environment (production or test) and the country code of your business when initializing `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),`.`]})})}),_jsx(_components.h4,{children:`Customize the primary button color`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:146,linesEnd:146,title:`Customize button appearance`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:1,linesEnd:25,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:72,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:83,linesEnd:86,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:41,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:41,linesEnd:51,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.rb`,linesStart:1,linesEnd:104,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-nodejs`,label:`Java + Node.js`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-nodejs/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-nodejs`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:4,title:`Install the Stripe Node library`,children:[_jsx(_components.p,{children:`Install the package and import it in your code. Alternatively, if you’re starting from scratch and need a package.json file, download the project files using the Download link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`npm:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --save`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:66,linesEnd:106,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:91,linesEnd:93,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:1,linesEnd:25,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:6,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:102,linesEnd:127,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:142,linesEnd:154,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:166,linesEnd:177,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:9,linesEnd:26,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:94,linesEnd:100,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:144,linesEnd:144,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay in AndroidManifest`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:147,linesEnd:149,title:`Configure Google Pay`,children:_jsxs(_components.p,{children:[`Enable Google Pay by passing a `,_jsx(_components.code,{children:`PaymentSheet.GooglePayConfiguration`}),` object with the Google Pay environment (production or test) and the country code of your business when initializing `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),`.`]})})}),_jsx(_components.h4,{children:`Customize the primary button`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:143,linesEnd:150,title:`Customize the primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:1,linesEnd:25,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:70,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.js`,linesStart:86,linesEnd:87,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:42,linesEnd:64,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:41,linesEnd:51,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle (Groovy):`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.js`,linesStart:1,linesEnd:110,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-php`,label:`Java + PHP`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-php/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-php`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`composer.json`,linesStart:1,linesEnd:6,title:`Install the Stripe PHP library`,children:[_jsx(_components.p,{children:`Install the library with composer and initialize with your secret API key. Alternatively, if you’re starting from scratch and need a composer.json file, download the files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Composer:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`composer`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` require`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe/stripe-php`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:64,linesEnd:80,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:69,linesEnd:72,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:21,linesEnd:23,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:1,linesEnd:13,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:244,linesEnd:272,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:183,linesEnd:225,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:82,linesEnd:86,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:8,linesEnd:25,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:73,linesEnd:79,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:251,linesEnd:251,title:`Enable delayed payment methods`,children:_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`allowsDelayedPaymentMethods`}),` to true to enable delayed payment methods.`]})})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:5,title:`Enable Google Pay in AndroidManifest`,children:_jsx(_components.p,{children:`Add the Google Pay API meta-data to your AndroidManifest.xml file.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize the primary button`}),_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:252,linesEnd:262,title:`Customize appearance`,children:_jsx(_components.p,{children:`Customize the Payment Sheet appearance by configuring colors, fonts, and other visual properties.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:21,linesEnd:23,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:49,linesEnd:59,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:65,linesEnd:66,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`charge.php`,linesStart:21,linesEnd:28,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect local and international addresses`}),_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`public/create.php`,linesStart:1,linesEnd:91,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-python`,label:`Java + Python`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-python/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-python`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:5,linesEnd:7,title:`Install the Stripe Python package`,children:[_jsx(_components.p,{children:`Install the Stripe package and import it in your code. Alternatively, if you’re starting from scratch and need a requirements.txt file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`pip:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`pip3`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` stripe`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:78,linesEnd:117,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:101,linesEnd:104,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/build.gradle`,linesStart:1,linesEnd:1,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:6,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Run the application`,children:[_jsx(_components.p,{children:`Run your Python server and go to your Android simulator or device.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`python3`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -m`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` flask`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` --port=4242`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:18,linesEnd:34,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.py`,linesStart:105,linesEnd:111,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:251,linesEnd:251,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay in AndroidManifest`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize appearance`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:252,linesEnd:262,title:`Customize primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/build.gradle`,linesStart:1,linesEnd:1,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:82,linesEnd:88,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:96,linesEnd:98,title:`Add the customer to the PaymentIntent`,children:_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details. Learn more about the most effective way to apply setup_future_usage. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:54,linesEnd:76,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.py`,linesStart:1,linesEnd:120,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-go`,label:`Java + Go`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-go/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-go`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`go.mod`,linesStart:1,linesEnd:6,title:`Set up your server`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a go.mod file, download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Go:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`go`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` get`}),_jsx(_components.span,{style:{color:`#2DAE58`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` github.com/stripe/stripe-go/v84`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:111,linesEnd:178,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:150,linesEnd:154,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:1,linesEnd:38,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:1,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:19,linesEnd:28,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:1,linesEnd:28,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:35,linesEnd:58,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:156,linesEnd:162,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:249,linesEnd:251,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize appearance`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:252,linesEnd:262,title:`Customize primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:1,linesEnd:38,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:9,linesEnd:14,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe customer and paymentmethod packages. Use these packages to store information about your customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:126,linesEnd:139,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`server.go`,linesStart:144,linesEnd:154,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`server.go`,linesStart:74,linesEnd:109,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:44,linesEnd:53,title:`Collect shipping or billing addresses`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`README.md`,linesStart:1,linesEnd:1,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-net`,label:`Java + .NET`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-net/archive/refs/heads/main.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-net`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:29,linesEnd:36,title:`Install the Stripe.net library`,children:[_jsx(_components.p,{children:`Install the package with .NET or NuGet. Alternatively, if you’re starting from scratch, download the files which contains a configured .csproj file.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`dotnet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`dotnet`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`NuGet:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#09A1ED`,\"--shiki-dark\":`#DCDCAA`},children:`Install-Package`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:` Stripe.net`})]}),`\n`]})})})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:82,linesEnd:100,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:88,linesEnd:92,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:21,linesEnd:29,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note:`}),` For details on the latest SDK release and past versions, see the Releases page on GitHub.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:6,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:103,linesEnd:109,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:244,linesEnd:273,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsx(_components.p,{children:`Use the PaymentSheet.Configuration struct for customising the Payment Sheet.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:69,linesEnd:77,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:183,linesEnd:225,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:18,linesEnd:26,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:111,linesEnd:136,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:93,linesEnd:97,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:249,linesEnd:262,title:`Enable delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:263,linesEnd:268,title:`Configure Google Pay`,children:_jsx(_components.p,{children:`Enable Google Pay by passing a PaymentSheet.GooglePayConfiguration object with the Google Pay environment (production or test) and the country code of your business when initializing PaymentSheet.Configuration.`})})}),_jsx(_components.h4,{children:`Customize appearance`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:252,linesEnd:261,title:`Customize primary button`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:39,linesEnd:61,title:`Enable card scanning`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:62,linesEnd:78,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:84,linesEnd:85,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:149,linesEnd:187,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect shipping or billing addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:44,linesEnd:53,title:`Configure Address Element`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:1,linesEnd:27,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`Server.cs`,linesStart:47,linesEnd:56,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})}),_jsx(_MdxComponentBoundary,{name:`FrameworkGuide`,children:_jsxs(FrameworkGuide,{framework:`ad-java-java`,label:`Java + Java`,children:[_jsx(_components.h1,{children:`Build a checkout page with Payment Intents API`}),_jsx(_components.p,{children:`Learn how to embed a custom Stripe payment form in your website or application. The client- and server-side code builds a checkout form with Stripe’s Web or Mobile elements to let you accept payments. To build a custom integration that goes beyond the basics of this quickstart, see Accept a payment.`}),_jsx(_components.p,{children:`To learn about different payment scenarios, such as subscriptions, and other Stripe products, compare payment integrations.`}),_jsx(_MdxComponentBoundary,{name:`DownloadAndOpenButtons`,children:_jsx(DownloadAndOpenButtons,{downloadUrl:`/guardian/stripe-sandbox/stripe-accept-payments-with-stripe-checkout-ad-java-java.zip`,gitUrl:`https://github.com/sampleapp-ai/stripe-accept-payments-with-stripe-checkout-ad-java-java`,className:`mint-mt-4 mint-mb-6`})}),_jsx(_components.h3,{children:`❶ Set up the server`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`pom.xml`,linesStart:33,linesEnd:39,title:`Install the Stripe Java library`,children:[_jsx(_components.p,{children:`Add the dependency to your build and import the library. Alternatively, if you’re starting from scratch and need a sample pom.xml file (for Maven), download the project files using the link in the code editor.`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Maven:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`xml`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`xml`,children:_jsxs(_components.code,{language:`xml`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`com.stripe`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`stripe-java`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`{VERSION}`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#13BBB7`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`implementation \"com.stripe:stripe-java:{VERSION}\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(_components.p,{children:[`Add the following dependency to your POM and replace `,` with the version number you want to use.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:144,linesEnd:211,title:`Create a PaymentIntent`,children:_jsxs(_components.p,{children:[`Add an endpoint on your server that creates a `,_jsx(_components.code,{children:`PaymentIntent`}),`. A PaymentIntent tracks the customer’s payment lifecycle, keeping track of any failed payment attempts and ensuring the customer is only charged once. Return the PaymentIntent’s `,_jsx(_components.code,{children:`client_secret`}),` in the response to finish the payment on the client.`]})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:182,linesEnd:187,title:`Configure payment methods`,children:_jsx(_components.p,{children:`Stripe enables cards and other common payment methods by default with dynamic payment methods. You can update and configure payment methods from the Dashboard with no code required. Stripe filters payment methods based on eligibility and payment method preferences, then orders and displays them by probability based on factors including amount, currency, and buyer location.`})})}),_jsx(_components.h3,{children:`❷ Build a checkout screen on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:26,linesEnd:72,title:`Install the SDK`,children:[_jsx(_components.p,{children:`The Stripe Android SDK is open source and fully documented and compatible with devices running Android 5.0 (API level 21) and above.`}),_jsx(_components.p,{children:`To install the SDK, add stripe-android to the dependencies block of your build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripe-android:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})}),_jsx(_components.p,{children:`Note: For details on the latest SDK release and past versions, see the Releases page on GitHub.`})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/MyApp.java`,linesStart:6,linesEnd:14,title:`Setup the SDK`,children:_jsx(_components.p,{children:`Configure the Stripe SDK with your Stripe publishable API key. Hardcoding the publishable API key in the SDK is for demonstration only. In a production app, you must retrieve the API key from your server.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:89,linesEnd:128,title:`Fetch a PaymentIntent`,children:_jsx(_components.p,{children:`Make a request to your server for a PaymentIntent as soon as the view loads. Store a reference to the PaymentIntent’s client secret returned by the server; the Payment Sheet uses this secret to complete the payment later.`})})}),_jsx(_components.h3,{children:`❸ Complete the payment on the client`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:142,linesEnd:154,title:`Configure and present the Payment Sheet`,children:[_jsx(_components.p,{children:`Create a PaymentSheet instance using the client secret retrieved earlier, and present it from your view controller.`}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),` struct for customising the Payment Sheet.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:166,linesEnd:177,title:`Handle the payment result`,children:[_jsx(_components.p,{children:`Use the completion block for handling the payment result.`}),_jsx(_components.p,{children:`If payment fails with an error, display the appropriate message to your customer so they can take action and try again. If no error has occurred, tell your customer that the payment was successful.`})]})}),_jsx(_components.h3,{children:`❹ Test the integration`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:137,linesEnd:142,title:`Make a test payment`,children:[_jsx(_components.p,{children:`To verify that your integration works, make a test payment using test payment details.`}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment succeeds`}),`\n`,_jsx(_components.code,{children:`4242 4242 4242 4242`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment requires authentication`}),`\n`,_jsx(_components.code,{children:`4000 0025 0000 3155`})]}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Payment is declined`}),`\n`,_jsx(_components.code,{children:`4000 0000 0000 9995`})]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`See your payment in the Dashboard`,children:_jsx(_components.p,{children:`Navigate to the Stripe Dashboard to see your test payment.`})})}),_jsx(_components.h3,{children:`Accept payments and enhance your integration`}),_jsx(_components.p,{children:`You’re ready to accept payments with Stripe. Continue with the steps below to add more features.`}),_jsx(_components.h4,{children:`Calculate and collect the right amount of tax`}),_jsx(_components.p,{children:`Calculate and collect the right amount of tax on your Stripe transactions. Learn more about Stripe Tax and how to add it to your Payments integration.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:75,linesEnd:95,title:`Use the Stripe Tax API to calculate tax`,children:[_jsxs(_components.p,{children:[`Use the Stripe Tax API to calculate tax on the transaction. Provide the `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`customer_details`}),`, and the `,_jsx(_components.code,{children:`line_items`}),` of the order in the request body.`]}),_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`tax_amount_exclusive`}),` attribute of the resulting Tax Calculation to add the exclusive taxes to the order’s total.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:188,linesEnd:203,title:`Record a Tax Transaction upon successful Payment`,children:[_jsxs(_components.p,{children:[`Link the tax calculation to the PaymentIntent using `,_jsx(_components.code,{children:`hooks[inputs][tax][calculation]`}),`.`]}),_jsx(_components.p,{children:`This records the collected taxes in your Stripe account that you can later export for accounting purposes, and triggers other Stripe actions.`})]})}),_jsx(_components.h4,{children:`Enable delayed payment methods`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:144,linesEnd:144,title:`Allow delayed payment methods`,children:[_jsx(_components.p,{children:`Some payment methods can’t guarantee that you’ll receive funds from your customer at the end of the checkout because they take time to settle (for example, most bank debits, such as SEPA or ACH) or require customer action to complete (for example, OXXO, Konbini, Boleto). Use this flag to enable delayed payment methods.`}),_jsx(_components.p,{children:`If you enable this feature, make sure your server integration listens to webhooks for notifications on whether payment has succeeded or not.`})]})}),_jsx(_components.h4,{children:`Enable Google Pay`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/AndroidManifest.xml`,linesStart:1,linesEnd:6,title:`Enable Google Pay API`,children:_jsx(_components.p,{children:`To use Google Pay, first enable the Google Pay API in your AndroidManifest.xml.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:147,linesEnd:150,title:`Configure Google Pay`,children:_jsxs(_components.p,{children:[`Enable Google Pay by passing a `,_jsx(_components.code,{children:`PaymentSheet.GooglePayConfiguration`}),` object with the Google Pay environment (production or test) and the country code of your business when initializing `,_jsx(_components.code,{children:`PaymentSheet.Configuration`}),`.`]})})}),_jsx(_components.h4,{children:`Customize the primary button`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:146,linesEnd:146,title:`Custom primary button color`,children:_jsx(_components.p,{children:`Consider using a custom color for the primary button that better matches your brand or app’s visual identity.`})})}),_jsx(_components.h4,{children:`Enable card scanning`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:26,linesEnd:72,title:`Add card scanning dependency`,children:[_jsx(_components.p,{children:`Card scanning can help increase your conversion rate by removing the friction of manual card entry. To enable card scanning, add stripecardscan to the dependencies block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.stripe:stripecardscan:22.6.1`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h4,{children:`Save payment details after payment`}),_jsx(_components.p,{children:`Often used by SaaS or e-commerce businesses with recurring customers.`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:23,linesEnd:27,title:`Import additional Stripe resources`,children:_jsx(_components.p,{children:`Import the Stripe PaymentMethod and Customer models. Use these models to store information about your Customer.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:148,linesEnd:169,title:`Create a customer`,children:_jsx(_components.p,{children:`Stripe stores the card on an Account object representing the customer. Create a new Account before creating a PaymentIntent. You can also store name, email, shipping address, and other details on the Account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:175,linesEnd:178,title:`Add the customer to the PaymentIntent`,children:[_jsxs(_components.p,{children:[`Pass the Account ID to the PaymentIntent and set `,_jsx(_components.code,{children:`setup_future_usage`}),` to `,_jsx(_components.code,{children:`off_session`}),`. `,_jsx(_components.code,{children:`setup_future_usage`}),` tells Stripe how you plan to use the payment method – certain regions, such as Europe and India, have requirements around reusing payment details.`]}),_jsxs(_components.p,{children:[`Learn more about the most effective way to apply `,_jsx(_components.code,{children:`setup_future_usage`}),`. You can also view a list of supported payment methods. After the PaymentIntent succeeds, Stripe automatically attaches the payment details (in a PaymentMethod object) to the customer-configured Account.`]})]})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:111,linesEnd:134,title:`Charge the saved PaymentMethod`,children:_jsxs(_components.p,{children:[`When you’re ready to charge the PaymentMethod again, create a new PaymentIntent with the Customer ID, the ID of the PaymentMethod you want to charge, and set the `,_jsx(_components.code,{children:`off_session`}),` and `,_jsx(_components.code,{children:`confirm`}),` flags to true.`]})})}),_jsx(_components.h4,{children:`Collect local and international addresses`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsxs(CodeFocusSection,{activeFilePath:`android/CheckoutActivity.java`,linesStart:41,linesEnd:51,title:`Collect shipping or billing addresses`,children:[_jsx(_components.p,{children:`Collect local and international shipping or billing addresses from your customers.`}),_jsx(_components.p,{children:`If you use the Address Element, you can optionally use the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, add places to the dependency block of your app/build.gradle file:`}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`build.gradle:`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`groovy`,children:_jsx(_components.pre,{className:`shiki shiki-themes snazzy-light dark-plus`,style:{backgroundColor:`#FAFBFC`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#565869`,\"--shiki-dark\":`#D4D4D4`},language:`groovy`,children:_jsxs(_components.code,{language:`groovy`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#565869`,\"--shiki-dark\":`#D4D4D4`},children:`implementation `}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`}),_jsx(_components.span,{style:{color:`#CF9C00`,\"--shiki-dark\":`#CE9178`},children:`com.google.android.libraries.places:places:2.6.0`}),_jsx(_components.span,{style:{color:`#ADB1C2`,\"--shiki-dark\":`#CE9178`},children:`'`})]}),`\n`]})})})]})}),_jsx(_components.h3,{children:`Next steps`}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`Payouts`,children:_jsx(_components.p,{children:`Learn how to move funds out of your Stripe account into your bank account.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`Refunds`,children:_jsx(_components.p,{children:`Handle requests for refunds by using the Stripe API or Dashboard.`})})}),_jsx(_MdxComponentBoundary,{name:`CodeFocusSection`,children:_jsx(CodeFocusSection,{activeFilePath:`src/main/java/com/stripe/sample/Server.java`,linesStart:1,linesEnd:40,title:`Fulfilment`,children:_jsx(_components.p,{children:`Create an event destination to send events to your webhook endpoint to fulfil orders after a payment succeeds, and to handle other critical events.`})})})]})})]})})]})})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{DownloadAndOpenButtons,FrameworkGuide,Architecture,iframeState,CodeFocusSection,SideBySideLayout,default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"snazzy-light","dark":"dark-plus"}},"config":{},"pageMetadata":{"title":"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)","description":"Build a checkout page with Payment Intents API","icon":"credit-card","mode":"custom","href":"/wide-samples/sandbox","hidden":false}}},"mdxSourceWithNoJs":null,"noJsSplices":[[19,38,""],[158,35963,")=>null;const FrameworkGuide=()=>null;const Architecture=()=>null;const iframeState=undefined;const CodeFocusSection=()=>null;const SideBySideLayout=()=>null;fu"]]},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"dynamicCss":".mint-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0\n}\n.mint-pointer-events-none {\n pointer-events: none\n}\n.mint-absolute {\n position: absolute\n}\n.mint-relative {\n position: relative\n}\n.mint-sticky {\n position: sticky\n}\n.mint--left-2 {\n left: -0.5rem\n}\n.mint-bottom-0 {\n bottom: 0px\n}\n.mint-bottom-4 {\n bottom: 1rem\n}\n.mint-bottom-full {\n bottom: 100%\n}\n.mint-left-0 {\n left: 0px\n}\n.mint-left-4 {\n left: 1rem\n}\n.mint-right-0 {\n right: 0px\n}\n.mint-right-2 {\n right: 0.5rem\n}\n.mint-top-0 {\n top: 0px\n}\n.mint-top-1\\/2 {\n top: 50%\n}\n.mint-top-20 {\n top: 5rem\n}\n.mint-top-full {\n top: 100%\n}\n.mint-z-40 {\n z-index: 40\n}\n.mint-z-50 {\n z-index: 50\n}\n.mint-m-0 {\n margin: 0px\n}\n.mint-mx-auto {\n margin-left: auto;\n margin-right: auto\n}\n.mint-mb-0 {\n margin-bottom: 0px\n}\n.mint-mb-2 {\n margin-bottom: 0.5rem\n}\n.mint-mb-6 {\n margin-bottom: 1.5rem\n}\n.mint-ml-auto {\n margin-left: auto\n}\n.mint-mr-3 {\n margin-right: 0.75rem\n}\n.mint-mt-1 {\n margin-top: 0.25rem\n}\n.mint-mt-3 {\n margin-top: 0.75rem\n}\n.mint-mt-4 {\n margin-top: 1rem\n}\n.mint-block {\n display: block\n}\n.mint-flex {\n display: flex\n}\n.mint-inline-flex {\n display: inline-flex\n}\n.mint-grid {\n display: grid\n}\n.mint-hidden {\n display: none\n}\n.mint-h-0 {\n height: 0px\n}\n.mint-h-3\\.5 {\n height: 0.875rem\n}\n.mint-h-4 {\n height: 1rem\n}\n.mint-h-5 {\n height: 1.25rem\n}\n.mint-h-6 {\n height: 1.5rem\n}\n.mint-h-7 {\n height: 1.75rem\n}\n.mint-h-8 {\n height: 2rem\n}\n.mint-h-px {\n height: 1px\n}\n.mint-max-h-80 {\n max-height: 20rem\n}\n.mint-w-0 {\n width: 0px\n}\n.mint-w-1 {\n width: 0.25rem\n}\n.mint-w-3\\.5 {\n width: 0.875rem\n}\n.mint-w-4 {\n width: 1rem\n}\n.mint-w-5 {\n width: 1.25rem\n}\n.mint-w-6 {\n width: 1.5rem\n}\n.mint-w-64 {\n width: 16rem\n}\n.mint-w-7 {\n width: 1.75rem\n}\n.mint-w-full {\n width: 100%\n}\n.mint-max-w-\\[calc\\(100\\%-3rem\\)\\] {\n max-width: calc(100% - 3rem)\n}\n.mint-max-w-none {\n max-width: none\n}\n.mint-flex-1 {\n flex: 1 1 0%\n}\n.mint-flex-shrink-0 {\n flex-shrink: 0\n}\n.mint--translate-y-1\\/2 {\n --tw-translate-y: -50%;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))\n}\n.mint-rotate-180 {\n --tw-rotate: 180deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))\n}\n@keyframes mint-spin {\n to {\n transform: rotate(360deg)\n }\n}\n.mint-animate-spin {\n animation: mint-spin 1s linear infinite\n}\n.mint-cursor-not-allowed {\n cursor: not-allowed\n}\n.mint-cursor-pointer {\n cursor: pointer\n}\n.mint-appearance-none {\n appearance: none\n}\n.mint-flex-col {\n flex-direction: column\n}\n.mint-flex-wrap {\n flex-wrap: wrap\n}\n.mint-items-start {\n align-items: flex-start\n}\n.mint-items-center {\n align-items: center\n}\n.mint-justify-center {\n justify-content: center\n}\n.mint-justify-between {\n justify-content: space-between\n}\n.mint-gap-1\\.5 {\n gap: 0.375rem\n}\n.mint-gap-2 {\n gap: 0.5rem\n}\n.mint-gap-3 {\n gap: 0.75rem\n}\n.mint-gap-4 {\n gap: 1rem\n}\n.mint-gap-8 {\n gap: 2rem\n}\n.mint-space-y-1 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.25rem * var(--tw-space-y-reverse))\n}\n.mint-space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse))\n}\n.mint-overflow-hidden {\n overflow: hidden\n}\n.mint-overflow-y-auto {\n overflow-y: auto\n}\n.mint-truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap\n}\n.mint-whitespace-nowrap {\n white-space: nowrap\n}\n.mint-rounded-2xl {\n border-radius: 1rem\n}\n.mint-rounded-full {\n border-radius: 9999px\n}\n.mint-rounded-lg {\n border-radius: 0.5rem\n}\n.mint-rounded-md {\n border-radius: 0.375rem\n}\n.mint-rounded-xl {\n border-radius: 0.75rem\n}\n.mint-border {\n border-width: 1px\n}\n.mint-border-0 {\n border-width: 0px\n}\n.mint-border-2 {\n border-width: 2px\n}\n.mint-border-b {\n border-bottom-width: 1px\n}\n.mint-border-l-4 {\n border-left-width: 4px\n}\n.mint-border-r-4 {\n border-right-width: 4px\n}\n.mint-border-t-4 {\n border-top-width: 4px\n}\n.mint-border-gray-200 {\n --tw-border-opacity: 1;\n border-color: rgb(229 231 235 / var(--tw-border-opacity, 1))\n}\n.mint-border-gray-300 {\n --tw-border-opacity: 1;\n border-color: rgb(209 213 219 / var(--tw-border-opacity, 1))\n}\n.mint-border-transparent {\n border-color: transparent\n}\n.mint-border-zinc-200 {\n --tw-border-opacity: 1;\n border-color: rgb(228 228 231 / var(--tw-border-opacity, 1))\n}\n.mint-border-zinc-300 {\n --tw-border-opacity: 1;\n border-color: rgb(212 212 216 / var(--tw-border-opacity, 1))\n}\n.mint-border-t-gray-900 {\n --tw-border-opacity: 1;\n border-top-color: rgb(17 24 39 / var(--tw-border-opacity, 1))\n}\n.mint-bg-gray-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-gray-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(229 231 235 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-gray-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-gray-900 {\n --tw-bg-opacity: 1;\n background-color: rgb(17 24 39 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-green-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-zinc-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(250 250 250 / var(--tw-bg-opacity, 1))\n}\n.mint-p-0 {\n padding: 0px\n}\n.mint-p-1 {\n padding: 0.25rem\n}\n.mint-p-2 {\n padding: 0.5rem\n}\n.mint-p-2\\.5 {\n padding: 0.625rem\n}\n.mint-p-3 {\n padding: 0.75rem\n}\n.mint-p-4 {\n padding: 1rem\n}\n.mint-px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem\n}\n.mint-px-4 {\n padding-left: 1rem;\n padding-right: 1rem\n}\n.mint-px-5 {\n padding-left: 1.25rem;\n padding-right: 1.25rem\n}\n.mint-py-0\\.5 {\n padding-top: 0.125rem;\n padding-bottom: 0.125rem\n}\n.mint-py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem\n}\n.mint-py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem\n}\n.mint-py-2\\.5 {\n padding-top: 0.625rem;\n padding-bottom: 0.625rem\n}\n.mint-py-3 {\n padding-top: 0.75rem;\n padding-bottom: 0.75rem\n}\n.mint-py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem\n}\n.mint-pb-24 {\n padding-bottom: 6rem\n}\n.mint-pb-3 {\n padding-bottom: 0.75rem\n}\n.mint-pr-2 {\n padding-right: 0.5rem\n}\n.mint-pr-8 {\n padding-right: 2rem\n}\n.mint-text-left {\n text-align: left\n}\n.mint-font-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace\n}\n.mint-text-\\[10px\\] {\n font-size: 10px\n}\n.mint-text-base {\n font-size: 1rem;\n line-height: 1.5rem\n}\n.mint-text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem\n}\n.mint-text-xs {\n font-size: 0.75rem;\n line-height: 1rem\n}\n.mint-font-bold {\n font-weight: 700\n}\n.mint-font-medium {\n font-weight: 500\n}\n.mint-font-semibold {\n font-weight: 600\n}\n.mint-leading-none {\n line-height: 1\n}\n.mint-text-gray-400 {\n --tw-text-opacity: 1;\n color: rgb(156 163 175 / var(--tw-text-opacity, 1))\n}\n.mint-text-gray-500 {\n --tw-text-opacity: 1;\n color: rgb(107 114 128 / var(--tw-text-opacity, 1))\n}\n.mint-text-gray-700 {\n --tw-text-opacity: 1;\n color: rgb(55 65 81 / var(--tw-text-opacity, 1))\n}\n.mint-text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1))\n}\n.mint-text-green-500 {\n --tw-text-opacity: 1;\n color: rgb(34 197 94 / var(--tw-text-opacity, 1))\n}\n.mint-text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1))\n}\n.mint-text-zinc-400 {\n --tw-text-opacity: 1;\n color: rgb(161 161 170 / var(--tw-text-opacity, 1))\n}\n.mint-text-zinc-600 {\n --tw-text-opacity: 1;\n color: rgb(82 82 91 / var(--tw-text-opacity, 1))\n}\n.mint-text-zinc-900 {\n --tw-text-opacity: 1;\n color: rgb(24 24 27 / var(--tw-text-opacity, 1))\n}\n.mint-opacity-0 {\n opacity: 0\n}\n.mint-opacity-25 {\n opacity: 0.25\n}\n.mint-opacity-50 {\n opacity: 0.5\n}\n.mint-opacity-75 {\n opacity: 0.75\n}\n.mint-shadow-2xl {\n --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.mint-shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.mint-shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.mint-backdrop-blur-md {\n --tw-backdrop-blur: blur(12px);\n -webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);\n backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)\n}\n.mint-transition-all {\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.mint-transition-colors {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.mint-transition-opacity {\n transition-property: opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.mint-transition-transform {\n transition-property: transform;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.mint-duration-300 {\n transition-duration: 300ms\n}\n.hover\\:mint-bg-gray-100:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1))\n}\n.hover\\:mint-bg-gray-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(229 231 235 / var(--tw-bg-opacity, 1))\n}\n.hover\\:mint-bg-zinc-100:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(244 244 245 / var(--tw-bg-opacity, 1))\n}\n.hover\\:mint-bg-zinc-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(228 228 231 / var(--tw-bg-opacity, 1))\n}\n.hover\\:mint-opacity-90:hover {\n opacity: 0.9\n}\n.focus\\:mint-border-transparent:focus {\n border-color: transparent\n}\n.focus\\:mint-outline-none:focus {\n outline: 2px solid transparent;\n outline-offset: 2px\n}\n.focus\\:mint-ring-2:focus {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)\n}\n.active\\:mint-scale-\\[0\\.98\\]:active {\n --tw-scale-x: 0.98;\n --tw-scale-y: 0.98;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))\n}\n.active\\:mint-scale-\\[0\\.99\\]:active {\n --tw-scale-x: 0.99;\n --tw-scale-y: 0.99;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))\n}\n.mint-group:hover .group-hover\\:mint-opacity-100 {\n opacity: 1\n}\n.dark\\:mint-border-zinc-600:is(.dark *) {\n --tw-border-opacity: 1;\n border-color: rgb(82 82 91 / var(--tw-border-opacity, 1))\n}\n.dark\\:mint-border-zinc-700:is(.dark *) {\n --tw-border-opacity: 1;\n border-color: rgb(63 63 70 / var(--tw-border-opacity, 1))\n}\n.dark\\:mint-border-t-gray-700:is(.dark *) {\n --tw-border-opacity: 1;\n border-top-color: rgb(55 65 81 / var(--tw-border-opacity, 1))\n}\n.dark\\:mint-bg-gray-700:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1))\n}\n.dark\\:mint-bg-zinc-700:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(63 63 70 / var(--tw-bg-opacity, 1))\n}\n.dark\\:mint-bg-zinc-800:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(39 39 42 / var(--tw-bg-opacity, 1))\n}\n.dark\\:mint-bg-zinc-800\\/50:is(.dark *) {\n background-color: rgb(39 39 42 / 0.5)\n}\n.dark\\:mint-bg-zinc-900:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(24 24 27 / var(--tw-bg-opacity, 1))\n}\n.dark\\:mint-bg-zinc-900\\/50:is(.dark *) {\n background-color: rgb(24 24 27 / 0.5)\n}\n.dark\\:mint-text-gray-300:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(209 213 219 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-gray-400:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(156 163 175 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-gray-500:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(107 114 128 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-gray-600:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-white:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-zinc-100:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(244 244 245 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-zinc-400:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(161 161 170 / var(--tw-text-opacity, 1))\n}\n.dark\\:hover\\:mint-bg-zinc-700:hover:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(63 63 70 / var(--tw-bg-opacity, 1))\n}\n.dark\\:hover\\:mint-bg-zinc-800:hover:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(39 39 42 / var(--tw-bg-opacity, 1))\n}\n@media (min-width: 1024px) {\n .lg\\:mint--mx-8 {\n margin-left: -2rem;\n margin-right: -2rem\n }\n .lg\\:mint-gap-10 {\n gap: 2.5rem\n }\n .lg\\:mint-px-8 {\n padding-left: 2rem;\n padding-right: 2rem\n }\n}","subdomain":"sampleappai","siteName":"SampleApp.ai","title":"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout) - SampleApp.ai","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-02-04T10:51:38.342Z","originalFileLocation":"wide-samples/sandbox.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Build a checkout page with Payment Intents API\">\u003cmeta data-mint-head name=\"application-name\" content=\"SampleApp.ai\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout) - SampleApp.ai\">\u003cmeta data-mint-head property=\"og:description\" content=\"Build a checkout page with Payment Intents API\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SampleApp.ai\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.sampleapp.ai/wide-samples/sandbox\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://sampleappai.mintlify.site/_mintlify/api/og/v2?division=Samples\u0026amp;title=Example%3A+Stripe-like+Guided+Sandbox+%28Accept+Payments+with+Stripe+Checkout%29\u0026amp;description=Build+a+checkout+page+with+Payment+Intents+API\u0026amp;theme=6685ea28db03d89807b2d3eb\u0026amp;signature=3924938f76f6328676a43bab3ecd99ef542a825ad72ffd404539993f92acd0f9\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout) - SampleApp.ai\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Build a checkout page with Payment Intents API\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://sampleappai.mintlify.site/_mintlify/api/og/v2?division=Samples\u0026amp;title=Example%3A+Stripe-like+Guided+Sandbox+%28Accept+Payments+with+Stripe+Checkout%29\u0026amp;description=Build+a+checkout+page+with+Payment+Intents+API\u0026amp;theme=6685ea28db03d89807b2d3eb\u0026amp;signature=3924938f76f6328676a43bab3ecd99ef542a825ad72ffd404539993f92acd0f9\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/sampleappai/jJ45ss0iKrgyevCV/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SampleApp.ai\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#4cc9f0\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.sampleapp.ai/wide-samples/sandbox\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/wide-samples/sandbox.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.sampleapp.ai/#organization\",\"name\":\"SampleApp.ai\",\"url\":\"https://docs.sampleapp.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/sampleappai/OuhPASQlHOE1qzMN/logo/light.png?fit=max\u0026auto=format\u0026n=OuhPASQlHOE1qzMN\u0026q=85\u0026s=fd66293534412d2d3c1249ae5d1b1f92\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.sampleapp.ai#website\",\"name\":\"SampleApp.ai\",\"url\":\"https://docs.sampleapp.ai\",\"publisher\":{\"@id\":\"https://docs.sampleapp.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.sampleapp.ai/wide-samples/sandbox#webpage\",\"url\":\"https://docs.sampleapp.ai/wide-samples/sandbox\",\"name\":\"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)\",\"description\":\"Build a checkout page with Payment Intents API\",\"dateModified\":\"2026-02-04T10:51:38.342Z\",\"isPartOf\":{\"@id\":\"https://docs.sampleapp.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.sampleapp.ai/wide-samples/sandbox#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.sampleapp.ai/wide-samples/sandbox#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"SampleApp.ai\",\"item\":\"https://docs.sampleapp.ai\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)\",\"item\":\"https://docs.sampleapp.ai/wide-samples/sandbox\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.sampleapp.ai/wide-samples/sandbox#article\",\"headline\":\"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)\",\"name\":\"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)\",\"description\":\"Build a checkout page with Payment Intents API\",\"url\":\"https://docs.sampleapp.ai/wide-samples/sandbox\",\"mainEntityOfPage\":{\"@id\":\"https://docs.sampleapp.ai/wide-samples/sandbox#webpage\"},\"dateModified\":\"2026-02-04T10:51:38.342Z\",\"publisher\":{\"@id\":\"https://docs.sampleapp.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.sampleapp.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SampleApp.ai\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"SampleApp.ai\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/wide-samples/sandbox.md","siteName":"SampleApp.ai","nav":{"global":null,"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":""}]},{"tab":"Samples","pages":[{"title":"Samples","href":"/samples/library"}]},{"tab":"Wide Samples","groups":[{"group":"Samples","pages":[{"title":"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout)","icon":"credit-card","mode":"custom","href":"/wide-samples/sandbox"}]}]}]},"basePath":"","title":"Example: Stripe-like Guided Sandbox (Accept Payments with Stripe Checkout) - SampleApp.ai","deploymentId":"dpl_EwfxjeKENdVkfzdag8rM6mKzcTUJ","buildId":"dpl_EwfxjeKENdVkfzdag8rM6mKzcTUJ","dynamics":[],"chunks":[]}