在使用Braintree PayPal Dropin时,需要在Angular中手动触发提交事件。具体实现方法如下:
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(); } }
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客户端控件