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

相关内容

热门资讯

透视系统!wepoke辅助德之... 透视系统!wepoke辅助德之星,We辅poker助,详细透视2025新版暗藏猫腻,小编详细说明we...
aapoker辅助工具存在!德... aapoker辅助工具存在!德扑ai智能机器人代理(透视)从来真的有挂(详细辅助细节方法)是一款可以...
透视规律!wepoke辅助德之... 透视规律!wepoke辅助德之星,wepoke能赢嘛,详细透视详细教程1、起透看视 wepoke辅助...
aapoker挂!we pok... aapoker挂!we poke软件免费版(透视)真是有挂(详细辅助细节方法)1、这是跨平台的aap...
德州之星辅助!微扑克辅助软件(... 德州之星辅助!微扑克辅助软件(透视)一直真的有挂(详细辅助存在挂教程)1、金币登录送、破产送、升级送...
透视存在!wepoke辅助挂,... 透视存在!wepoke辅助挂,wepower插件,详细透视AA德州教程1、构建自己的wepoke辅助...
透视规律!wepower有外 ... 透视规律!wepower有外 挂,wepokeai辅助,详细透视必胜教程1、每一步都需要思考,不同水...
wpk提高胜率!wpk伙牌(透... 自定义wpk提高胜率系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你...
透视透视!wepoke确实有挂... 透视透视!wepoke确实有挂,wepower辅助软件,详细透视透明挂教程暗藏猫腻,小编详细说明we...
德州免费辅助神器app!德扑之... 德州免费辅助神器app!德扑之星可以看底牌吗(透视)一向是有挂(详细辅助技巧教程);德州免费辅助神器...