Angular使用BraintreePayPalDropin无法触发提交事件
创始人
2024-10-29 12:30:55
0

在使用Braintree PayPal Dropin时,需要在Angular中手动触发提交事件。具体实现方法如下:

  1. 在HTML模板中添加一个按钮,用于触发提交事件。

  1. 在组件中定义submitPayPal()函数,并在该函数中手动触发表单提交事件。

import { Component, ViewChild, ElementRef } from '@angular/core';

@Component({ selector: 'app-payment', templateUrl: './payment.component.html', styleUrls: ['./payment.component.css'] }) export class PaymentComponent { @ViewChild('paypalForm', {static: false}) paypalForm: ElementRef;

submitPayPal() { this.paypalForm.nativeElement.submit(); } }

  1. 在HTML模板中添加一个隐藏的表单,在表单中设置相关参数和回调函数。注意,表单的action需要设置为Braintree的服务器URL。

  1. 在组件中定义相关变量和方法,用于获取相关参数并生成Braintree客户端控件。

import { Component, ViewChild, ElementRef } from '@angular/core';

@Component({ selector: 'app-payment', templateUrl: './payment.component.html', styleUrls: ['./payment.component.css'] }) export class PaymentComponent { @ViewChild('paypalForm', {static: false}) paypalForm: ElementRef; paymentURL = 'https://example.com/payment/process'; // 设置Braintree服务器URL nonce: string; amount: string; orderId: string;

// 生成Braintree客户端控件

相关内容

热门资讯

第1分钟指南!wepoker插... 第1分钟指南!wepoker插件程序激活码(透视)总是是有辅助插件(哔哩哔哩)1、玩家可以在wepo...
第3分钟资料!aapoker透... 第3分钟资料!aapoker透视脚本(透视)原来有辅助神器(哔哩哔哩)1、进入到aapoker透视脚...
7分钟攻略!pokemmo辅助... 7分钟攻略!pokemmo辅助工具(透视)真是存在有辅助透视(哔哩哔哩)pokemmo辅助工具透视方...
1分钟模板!微扑克微乐辅助(透... 1分钟模板!微扑克微乐辅助(透视)本来是有辅助辅助(哔哩哔哩)1、微扑克微乐辅助脚本辅助下载、微扑克...
4分钟操作!aapoker如何... 4分钟操作!aapoker如何设置胜率(透视)切实是有辅助辅助(哔哩哔哩)1、下载好aapoker如...
七分钟举措!云扑克有透视吗(透... 七分钟举措!云扑克有透视吗(透视)本来是真的有辅助工具(哔哩哔哩)1、云扑克有透视吗脚本辅助下载、云...
第四分钟大纲!wpk模拟器(透... 第四分钟大纲!wpk模拟器(透视)好像是真的有辅助下载(哔哩哔哩)1、全新机制【wpk模拟器ai辅助...
第7分钟举措!pokemmo辅... 第7分钟举措!pokemmo辅助器手机版下载(透视)都是真的是有辅助下载(哔哩哔哩)1、打开软件启动...
第五分钟模板!newpoker... 第五分钟模板!newpoker脚本(透视)一贯有辅助教程(哔哩哔哩)1、打开软件启动之后找到中间准星...
3分钟手筋!wejoker辅助... 3分钟手筋!wejoker辅助软件价格(透视)总是是真的有辅助脚本(哔哩哔哩)1、实时wejoker...