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客户端控件

相关内容

热门资讯

一起来探讨!hhpoker有没... 一起来探讨!hhpoker有没有作弊辅助,破解辅助插件wepoker,必胜教程(有挂方法)是一款可以...
透视神器!hhpoker是正品... 透视神器!hhpoker是正品吗(透视)好像是真的有挂(详细辅助详细教程);1、玩家可以在软件透明挂...
盘点十款!wepoker私人局... 盘点十款!wepoker私人局开挂视频,xpoker辅助工具,玩家教你(有挂神器);1分钟了解详细教...
透视能赢!wepoker私人局... 透视能赢!wepoker私人局俱乐部怎么进(透视)切实是有挂(详细辅助力荐教程);1、系统规律教程、...
终于懂了!impoker辅助,... 终于懂了!impoker辅助,uupoker有透视吗,分享教程(有挂透视);1分钟了解详细教程(微信...
透视游戏!poker worl... 透视游戏!poker world辅助器(透视)确实存在有挂(详细辅助AI教程)1、每一步都需要思考,...
专业讨论!wepoker透视脚... 专业讨论!wepoker透视脚本视频,hhpoker辅助挂下载,玩家教程(有挂透明);wepoker...
透视透视!hh poker辅助... 透视透视!hh poker辅助器先试用(透视)真是存在有挂(详细辅助2025新版教程)是一种具有地方...
透视讲解!aapoker透视脚... 透视讲解!aapoker透视脚本入口(透视)原来是有挂(详细辅助wpk教程)1、aapoker透视脚...
分享一款!cloudpoker... 1、分享一款!cloudpoker外挂,wejoker透视方法,玩家教程(有挂神器);详细教程。2、...