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

建材网站建设 南宁php做听歌网站

建材网站建设 南宁,php做听歌网站,网站程序 wap pc 同步,免费建站 永久Vue3Ts#xff1a;实现paypal按钮 一、前端页面按钮实现第一步#xff1a;下载paypal.js依赖第二步#xff1a;引入要使用的vue页面#xff0c;并调用。 二、实现逻辑研究第一点#xff1a;了解下Buttons自带的style属性第二点#xff1a;了解下Buttons自带的处理方法第三… Vue3Ts实现paypal按钮 一、前端页面按钮实现第一步下载paypal.js依赖第二步引入要使用的vue页面并调用。 二、实现逻辑研究第一点了解下Buttons自带的style属性第二点了解下Buttons自带的处理方法第三点loadScript的参数这里主看PayPalScriptOptions 前言到了让我激动人心的时刻paypal支付按钮的前端处理唯一不足之处是没有后端处理有时间我研究下 先放代码如何实现再深研究一下逻辑。 一、前端页面按钮实现 第一步下载paypal.js依赖 npm install paypal/paypal-js第二步引入要使用的vue页面并调用。 template div idpaypal-buttons/div /template script langts import { loadScript } from paypal/paypal-js; import { nextTick, defineComponent, onMounted } from vueexport default defineComponent({setup(){ onMounted( async(){await 页面加载数据方法()await nextTick((){constructButton()})})const constructButton async (){await loadScript({clientId: clientId,disableFunding:[credit,card] // 禁止出现的按钮}).then((paypal) {if (paypal?.Buttons) {paypal.Buttons({style: { // 按钮样式自定义height: 40, },createOrder: (data, actions) {//调起创建支付订单的接口checkedValueRef.value选中购买的idreturn fetch(urlcheckedValueRef.value,{method: get, headers:{Authorization : userStore.getToken()}}).then((res) res.json()).then((json) {if(!json.msg){if(checkedValueRef.value null){message.error(请勾选)} }return json.msg}).catch((err){console.log(err)})},onApprove: (data, actions) {// 获得订单id去付款接口return fetch(url?orderId data.orderID,{method: get, headers:{Authorization : userStore.getToken()}}).then((res) res.json()).then((json) {if(json.code 0){checkedValueRef.value null// 购买成功}else{// 购买失败}})},onCancel(data){console.log(取消);}}).render(#paypal-buttons).catch((error) {console.error(failed to render the PayPal Buttons, error);});}}).catch((error) {console.error(failed to load the PayPal JS SDK script, error);});} } }) /script依赖地址 二、实现逻辑研究 其实上面这些就已经能满足操作了但是我们还需要了解三点细节 第一点了解下Buttons自带的style属性 style?: {color?: gold | blue | silver | white | black; // 按钮颜色// 该按钮的默认最大宽度为750px但您可以将按钮放大。//将style.disableMaxWidth设置为true。然后更改容器级别的最大宽度值。disableMaxWidth?: boolean;// 默认情况下按钮会根据其容器元素的大小进行调整。// 要自定义按钮高度请将style.height选项设置为25到55之间的值。// 您的按钮容器元素必须足够宽以容纳水平支付按钮。height?: number;label?: // 将style.label选项设置为以下值之一| paypal| checkout| buynow| pay| installment| subscribe| donate;// 设置style.layout选项以确定多个按钮可用时的按钮布局垂直|水平layout?: vertical | horizontal; shape?: rect | pill; // 按钮形状矩形/圆矩形tagline?: boolean;};可以参考网址 https://developer.paypal.com/docs/multiparty/checkout/standard/customize/buttons-style-guide/ 第二点了解下Buttons自带的处理方法 createOrder //当买家点击PayPal按钮时会调用此参数该按钮会启动PayPal Checkout窗口买家在PayPal.com网站上登录并批准交易。 createSubscription onApprove // 从交易中获取资金并向买家显示消息让他们知道交易成功。 onCancel // 当买家取消付款时他们通常会返回到父页面。您可以使用onCancel功能显示取消页面或返回购物车。 onError onInit/onClick onShippingChange onShippingAddressChange onShippingOptionsChange这里我只介绍用到的方法 网址参考https://developer.paypal.com/docs/business/checkout/reference/style-guide/#customize-the-payment-buttons 第三点loadScript的参数这里主看PayPalScriptOptions 按钮个数展示主要是这里设置 options: PayPalScriptOptions,PromisePonyfill?: PromiseConstructorexport interface PayPalScriptOptionsextends PayPalScriptQueryParameters,PayPalScriptDataAttributes,ScriptAttributes {sdkBaseUrl?: string; }interface PayPalScriptQueryParameters {buyerCountry?: string;clientId: string;commit?: boolean;components?: string[] | string;currency?: string;debug?: boolean | string;// loadScript() supports an array and will convert it// to the correct disable-funding and enable-funding string values// disableFunding被禁用的交易资金来源。您通过的任何资金来源都不会在结帐时显示为按钮。默认情况下资金来源资格是根据各种因素确定的。不要使用此查询参数禁用信用卡和借记卡的高级支付。disableFunding?: string[] | string; enableFunding?: string[] | string;integrationDate?: string;intent?: string;locale?: string;// loadScript() supports an array for merchantId, even though// merchant-id technically may not contain multiple values.// For an array with a length of 1 it automatically sets// merchantId to * and moves the actual values to dataMerchantIdmerchantId?: string[] | string;vault?: boolean | string; } 参考网址https://developer.paypal.com/sdk/js/configuration/#link-queryparameters
http://www.hkea.cn/news/14400256/

相关文章:

  • 万云网络网站做视频网站服务器配置
  • 网站怎么做海外推广移动端网站交互效果最好的
  • 网站开发属于什么资产app优化网站建设
  • 做毕业证教育网站网站建设与制作课后题答案
  • 鄂州正规网站建设学大教育一对一收费价格表
  • 优班图搭建网站网页界面设计中一般使用的分辨率的显示密度是多少dpi
  • 中英繁网站免费网站托管平台
  • 快速迁移网站手机网站平台
  • 聊城网站制作价格室内装修设计软件免费自学
  • 阳江房产网春天尚院深圳网络seo优化
  • 青岛哪家网站建设好网上开店创业计划书
  • 大连三大网络推广网站嘉兴网站排名优化报价
  • 网站 医院信息化建设软文写作经验
  • 建设网站开发方案个人网页设计作品手绘
  • 技术支持 桂林网站建设ui在线设计平台
  • 网站经营方案wordpress相关阅读禁止显示图片
  • wordpress主题站模板wordpress去除顶部工具栏
  • 泰州专一做淘宝网站网站开发公司建站源码
  • 如何做论坛网站成都效果图制作公司排行榜
  • 蓝色网站建设企业文化经典句子
  • 为什么要做响应式网站软件定制开发公司的商业模式
  • 公司网站建设工作通知wordpress 媒体库 显示
  • 360未经证实的网站如何做濮阳网络化
  • 好的宠物网站模板2014网站备案
  • 建设网站用外包模板可以上线吗seo关键词外包公司
  • 学做网站论坛VIP怎么样360浏览器直接进入网站
  • 电子商务网站建设 教学大纲唐山哪里建设飞机场
  • 网站开发可选择的方案中小型企业网站模板
  • 网站备案 地址阿里云linux服务器搭建多个网站
  • 绍兴 网站建设 电话无线网络设计实验报告