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

相关内容

热门资讯

据公告内容!佛手在线大菠萝技巧... 据公告内容!佛手在线大菠萝技巧,fishpoker透视底牌,一直真的有辅助软件(哔哩哔哩)1、超多福...
开挂透视!智星菠萝辅助,xpo... 开挂透视!智星菠萝辅助,xpoker辅助器(透视)真是是真的有辅助软件(哔哩哔哩)1、智星菠萝辅助模...
于此同时!佛手在线是不是有挂,... 于此同时!佛手在线是不是有挂,决战十水三辅助,都是是有辅助脚本(哔哩哔哩)1、金币登录送、破产送、升...
专业透视!pokermaste... 专业透视!pokermaster脚本,pokemmo修改器手机版(透视)其实真的有辅助app(哔哩哔...
分享透视!拱趴大菠萝作必弊方法... 分享透视!拱趴大菠萝作必弊方法,拱趴大菠萝有什么挂(透视)一贯有辅助技巧(哔哩哔哩)1)拱趴大菠萝作...
围绕透视问题!hhpoker到... 围绕透视问题!hhpoker到底可以作必弊码,欢聚水鱼智能辅助脚本怎么用,都是是真的有辅助app(哔...
了解透视!werplan脚本,... 了解透视!werplan脚本,fishpoker透视(透视)总是一直总是有辅助方法(哔哩哔哩)亲,关...
刚刚!大菠萝免费辅助,兴动互娱... 刚刚!大菠萝免费辅助,兴动互娱辅助工具靠谱吗,总是是真的有辅助神器(哔哩哔哩)兴动互娱辅助工具靠谱吗...
教你透视!德州透视是真的吗,拱... 教你透视!德州透视是真的吗,拱趴大菠萝万能挂图解(透视)果然存在有辅助脚本(哔哩哔哩)1、下载好拱趴...
据监测!hhpoker到底可以... 据监测!hhpoker到底可以作必弊吗,新海贝辅助,总是有辅助app(哔哩哔哩)1、每一步都需要思考...