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

相关内容

热门资讯

透视插件!aapoker透视插... 透视插件!aapoker透视插件(透视)辅助插件工具(总是存在有挂)1.aapoker透视插件 ai...
透视插件!aapoker辅助软... 透视插件!aapoker辅助软件合法吗(透视)透视脚本(其实有挂);1、aapoker辅助软件合法吗...
透视软件!aapoker能控制... 透视软件!aapoker能控制牌吗(透视)透视插件(一贯真的是有挂);1、aapoker能控制牌吗a...
透视攻略!aapoker透视插... 透视攻略!aapoker透视插件(透视)透视方法(原来真的是有挂);该软件可以轻松地帮助玩家将aap...
透视模拟器!aapoker插件... 透视模拟器!aapoker插件(透视)插件(原来真的是有挂)1、aapoker插件ai辅助优化,aa...
透视实锤!aapoker发牌逻... 透视实锤!aapoker发牌逻辑(透视)透视脚本下载(果然有挂)1、aapoker发牌逻辑系统规律教...
透视讲解!aapoker脚本(... 透视讲解!aapoker脚本(透视)插件下载(真是是有挂)1、aapoker脚本系统规律教程、aap...
透视辅助!aapoker透视插... 透视辅助!aapoker透视插件(透视)辅助(果然有挂)1、aapoker透视插件机器人多个强度级别...
透视讲解!aapoker怎么开... 透视讲解!aapoker怎么开辅助器(透视)透视方法(都是真的有挂)1、全新机制【aapoker怎么...
透视插件!aapoker辅助插... 透视插件!aapoker辅助插件工具(透视)透视软件(都是有挂)1、aapoker辅助插件工具ai辅...