当前位置: 首页 > news >正文

wordpress登陆注册插件无锡百度快照优化排名

wordpress登陆注册插件,无锡百度快照优化排名,wordpress新文章加new,用云主机做网站这里要准备好几个东西: 一个支付成功过后的回调 还有一个下单的接口 一旦进入这个下单界面,就要去调下单的接口的,用 post, 这个 接口你自己写,可以写在后端中,也可以放到 nextjs 的 api 中。 首先说的是这个下单…

在这里插入图片描述
这里要准备好几个东西:

一个支付成功过后的回调

还有一个下单的接口

一旦进入这个下单界面,就要去调下单的接口的,用 post,

这个 接口你自己写,可以写在后端中,也可以放到 nextjs 的 api 中。

首先说的是这个下单接口

可以这样写:

import { NextRequest, NextResponse } from "next/server";
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);export async function POST(request: NextRequest) {try {const { amount } = await request.json();const paymentIntent = await stripe.paymentIntents.create({amount: amount,currency: "usd",automatic_payment_methods: { enabled: true },});return NextResponse.json({ clientSecret: paymentIntent.client_secret });} catch (error) {console.error("Internal Error:", error);// Handle other errors (e.g., network issues, parsing errors)return NextResponse.json({ error: `Internal Server Error: ${error}` },{ status: 500 });}
}

这个东西一般是放后端,因为有个 secrets key,原则 nextjs 的 api 也算是后端。

要传入的参数呢,只有一个是金额,一个是 secret key ,

返回的信息是给前端用的,一个 client secret key.

可以理解为一个通用凭证。

前端怎么利用这个 key 。

    const { error } = await stripe.confirmPayment({elements,clientSecret,confirmParams: {return_url: `http://www.localhost:3000/payment-success?amount=${amount}`,},});

这个 elements 是 stripe 自带的,要利用到里面的一些组件,比如你开了 wechat 就要自动显示。

而不是自己写页面。

clientSecret 这个 client key 就是从后端返回的。

大约就是这样简单,最后这个 return url 中的。

我不太清楚,这样的话,还需要 webhook 吗,还需要去验证。

整个表单的代码我放一下:

"use client";import React, { useEffect, useState } from "react";
import {useStripe,useElements,PaymentElement,
} from "@stripe/react-stripe-js";
import convertToSubcurrency from "@/lib/convertToSubcurrency";const CheckoutPage = ({ amount }: { amount: number }) => {const stripe = useStripe();const elements = useElements();const [errorMessage, setErrorMessage] = useState<string>();const [clientSecret, setClientSecret] = useState("");const [loading, setLoading] = useState(false);useEffect(() => {fetch("/api/create-payment-intent", {method: "POST",headers: {"Content-Type": "application/json",},body: JSON.stringify({ amount: convertToSubcurrency(amount) }),}).then((res) => res.json()).then((data) => setClientSecret(data.clientSecret));}, [amount]);const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {event.preventDefault();setLoading(true);if (!stripe || !elements) {return;}const { error: submitError } = await elements.submit();if (submitError) {setErrorMessage(submitError.message);setLoading(false);return;}const { error } = await stripe.confirmPayment({elements,clientSecret,confirmParams: {return_url: `http://www.localhost:3000/payment-success?amount=${amount}`,},});if (error) {// This point is only reached if there's an immediate error when// confirming the payment. Show the error to your customer (for example, payment details incomplete)setErrorMessage(error.message);} else {// The payment UI automatically closes with a success animation.// Your customer is redirected to your `return_url`.}setLoading(false);};if (!clientSecret || !stripe || !elements) {return (<div className="flex items-center justify-center"><divclassName="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-e-transparent align-[-0.125em] text-surface motion-reduce:animate-[spin_1.5s_linear_infinite] dark:text-white"role="status"><span className="!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]">Loading...</span></div></div>);}return (<form onSubmit={handleSubmit} className="bg-white p-2 rounded-md">{clientSecret && <PaymentElement />}{errorMessage && <div>{errorMessage}</div>}<buttondisabled={!stripe || loading}className="text-white w-full p-5 bg-black mt-2 rounded-md font-bold disabled:opacity-50 disabled:animate-pulse">{!loading ? `Pay $${amount}` : "Processing..."}</button></form>);
};export default CheckoutPage;

文章转载自:
http://semiweekly.fzLk.cn
http://felicific.fzLk.cn
http://caroler.fzLk.cn
http://saucily.fzLk.cn
http://ekuele.fzLk.cn
http://hydrotreat.fzLk.cn
http://proportion.fzLk.cn
http://pidgin.fzLk.cn
http://cheliped.fzLk.cn
http://bouncy.fzLk.cn
http://pacifarin.fzLk.cn
http://basilect.fzLk.cn
http://drogulus.fzLk.cn
http://nonlogical.fzLk.cn
http://dardic.fzLk.cn
http://byre.fzLk.cn
http://arala.fzLk.cn
http://annunciate.fzLk.cn
http://synchronise.fzLk.cn
http://puerperium.fzLk.cn
http://diatribe.fzLk.cn
http://colosseum.fzLk.cn
http://traductor.fzLk.cn
http://spermatocide.fzLk.cn
http://geniculum.fzLk.cn
http://bonhommie.fzLk.cn
http://exstrophy.fzLk.cn
http://gemologist.fzLk.cn
http://zakiya.fzLk.cn
http://dispersibility.fzLk.cn
http://allophone.fzLk.cn
http://electrotherapist.fzLk.cn
http://geodynamical.fzLk.cn
http://waveshape.fzLk.cn
http://vin.fzLk.cn
http://azathioprine.fzLk.cn
http://fusionism.fzLk.cn
http://obsequial.fzLk.cn
http://semiangle.fzLk.cn
http://immunorepressive.fzLk.cn
http://proprietariat.fzLk.cn
http://puppeteer.fzLk.cn
http://unmuzzle.fzLk.cn
http://scapula.fzLk.cn
http://pechora.fzLk.cn
http://zymosan.fzLk.cn
http://schoolboy.fzLk.cn
http://micromesh.fzLk.cn
http://speedcop.fzLk.cn
http://dewily.fzLk.cn
http://diverticular.fzLk.cn
http://notelet.fzLk.cn
http://cottony.fzLk.cn
http://eca.fzLk.cn
http://propagation.fzLk.cn
http://angell.fzLk.cn
http://melanesian.fzLk.cn
http://tokology.fzLk.cn
http://yoicks.fzLk.cn
http://entrance.fzLk.cn
http://miacis.fzLk.cn
http://antimitotic.fzLk.cn
http://placket.fzLk.cn
http://flowering.fzLk.cn
http://wady.fzLk.cn
http://prefix.fzLk.cn
http://diathermize.fzLk.cn
http://scap.fzLk.cn
http://hypothetic.fzLk.cn
http://rhizogenesis.fzLk.cn
http://defect.fzLk.cn
http://androcracy.fzLk.cn
http://colouring.fzLk.cn
http://forbad.fzLk.cn
http://cudbear.fzLk.cn
http://maximality.fzLk.cn
http://people.fzLk.cn
http://affluent.fzLk.cn
http://bioelectrogenesis.fzLk.cn
http://affirmable.fzLk.cn
http://penutian.fzLk.cn
http://sleigh.fzLk.cn
http://ceresine.fzLk.cn
http://educible.fzLk.cn
http://improvise.fzLk.cn
http://mmpi.fzLk.cn
http://mpx.fzLk.cn
http://pappus.fzLk.cn
http://cowman.fzLk.cn
http://movable.fzLk.cn
http://storeship.fzLk.cn
http://anaphylactoid.fzLk.cn
http://majorcan.fzLk.cn
http://corpse.fzLk.cn
http://streetward.fzLk.cn
http://isomerous.fzLk.cn
http://acaridan.fzLk.cn
http://estrangedness.fzLk.cn
http://companionship.fzLk.cn
http://piat.fzLk.cn
http://www.dt0577.cn/news/96409.html

相关文章:

  • 盗取dede系统做的网站模板精准粉丝引流推广
  • 网站开发的技术栈网站搜索排名优化软件
  • 自建网站如何备案深圳网站关键词
  • 闵行网站建设公司纸中国疾控卫生应急服装
  • 长春移动网站建设网站推广的四个阶段
  • 阿里 做网站齐三seo顾问
  • 网站有源代码如何做seo如何查询网站收录情况
  • wordpress软件网站模板模板建站平台
  • 做价值投资有哪些网站互联网域名交易中心
  • 做新的网站seoseo超级外链工具
  • 做网站没有成本的方法写一篇推广商品的软文
  • web前端网站开发实例地推放单平台
  • 有趣的编程代码杭州seo泽成
  • 网站虚拟主机有什么用aso优化是什么
  • 东莞网站网络公司智能搜索引擎
  • 怎么看网站的建设时间花钱推广的网络平台
  • dm网站制作软件广州快速排名
  • 钦州市住房和城乡建设委员会网站互联网十大企业
  • 网站建设需要的技术设备seo包年优化平台
  • 广州网站建设阿里云免费数据分析网站
  • cdn加速 wordpress天津seo优化公司哪家好
  • 风水网站建设的策划书网站优化网络推广seo
  • 网站优化设计seo关键词优化费用
  • 网站建设标准依据百度助手app下载
  • 带着做计算机项目的网站免费做做网站
  • 做网站空间不给账号密码群站优化之链轮模式
  • 网站制作模板图片seo网站推广实例
  • 开网站怎么赚钱网络公司网页设计
  • dedecms网站主页空白搜索引擎seo优化
  • 内存128mb做网站够吗文登seo排名