Angular生产环境中的DynamicsCRM营销活动网站上没有显示Paypal按钮。
创始人
2024-10-29 10:30:31
0

问题可能是由于使用Angular生产环境时未正确加载Paypal SDK库文件导致的。为确保正确加载Paypal SDK库文件并在Angular生产环境中显示Paypal按钮,请按照以下步骤操作:

  1. 安装Paypal SDK库文件:使用以下命令安装Paypal SDK库文件:
npm install @paypal/checkout-sdk --save
  1. 导入Paypal SDK库文件:在app.module.ts文件中导入Paypal SDK库文件:
import { PayPalScriptService, PayPalScriptLoaderOptions } from '@paypal/angular-components/paypal-script.service';
import { PAYPAL_SCRIPT_URL, PAYPAL_CLIENT_ID } from './app.config'; // Replace with your own PayPal configuration
 
const payPalScriptOptions: PayPalScriptLoaderOptions = {
    'client-id': PAYPAL_CLIENT_ID,
    'currency': 'USD'
};
 
@NgModule({
    imports: [
        PayPalButtonModule.forRoot(payPalScriptOptions)
    ]
})
export class AppModule {
    constructor(scriptsLoader: PayPalScriptService) {
        scriptsLoader.loadPayPalScript({ url: PAYPAL_SCRIPT_URL });
    }
}
  1. 在HTML文件中添加Paypal按钮:在需要添加Paypal按钮的HTML文件中添加以下代码:
  1. 在TS文件中调用Paypal API:在需要调用Paypal API的TS文件中添加以下代码:
import { PayPalScriptService } from '@paypal/angular-components/paypal-script.service';
import { PAYPAL_CLIENT_ID } from './app.config'; // Replace with your own PayPal configuration
 
constructor(private paypalScriptService: PayPalScriptService) {}
 
this.paypalScriptService.loadPayPalScript().subscribe(() => {
    // Render the PayPal button
    paypal.Buttons({
        createOrder: (data, actions) => {
            // Set up the transaction
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: '0.01'
                    }
               }]
            });
        },
        onApprove: (data, actions) => {
            // Capture the funds from the transaction

相关内容

热门资讯

最新技巧!wepoker俱乐部... 最新技巧!wepoker俱乐部辅助器,wepoker开脚本视频,2025新版技巧(有挂辅助)关于we...
一分钟了解!德州私人局脚本,w... 1、一分钟了解!德州私人局脚本,wepoker透视底牌,教你教程(有挂方法)(UU poker、德州...
揭秘几款!hhpoker有没有... 揭秘几款!hhpoker有没有作弊挂,wepoker有辅助功能吗,2025教程(有挂辅助)这是由厦门...
重大通报!wepoker高级辅... 重大通报!wepoker高级辅助,德普之星辅助软件,玩家教程(有挂辅助)准备好在德普之星辅助软件ia...
玩家必看科普!wepoker正... 《玩家必看科普!wepoker正确养号方法,德州透视是真的吗,解密教程(有挂透明)》 wepoker...
每日必备!智星德州可以透视吗,... 每日必备!智星德州可以透视吗,sohoo poker辅助器,德州论坛(有挂技巧);智星德州可以透视吗...
最新技巧!hhpoker辅助软... 最新技巧!hhpoker辅助软件下载,hhpoker俱乐部是干嘛的,详细教程(有挂神器)1、许多玩家...
一分钟了解!we-poker辅... 1、一分钟了解!we-poker辅助器,pokerworld软件,解密教程(有挂攻略)。2、we-p...
一分钟了解!wpk刷入池率脚本... 一分钟了解!wpk刷入池率脚本,大菠萝辅助器,AA德州教程(有挂教程);大神普及一款德州ai内幕,确...
分享实测!来玩app 德州 辅... 分享实测!来玩app 德州 辅助,hh poker软件,大神讲解(有挂方法);1分钟了解详细教程(微...