我正在尝试使用此处的教程实现Paypal结帐按钮:
我在页面上有checkout.js文件:
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
按钮代码为:
<div id="paypal-button"></div>
<script>
paypal.Button.render({
env: 'sandbox', // 'sandbox' Or 'production',
client: {
sandbox: '<sandbox id>',
production: ''
},
locale: 'en_GB',
commit: true, // Show a 'Pay Now' button
payment: function() {
// Set up the payment here
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'GBP' }
}
]
}
});
},
onAuthorize: function(data, actions) {
// Execute the payment here
return actions.payment.execute().then(function(payment) {
// The payment is complete!
// You can now show a confirmation message to the customer
});
}
}, '#paypal-button');
</script>
但是,当我点击按钮时,我得到&#34; ReferenceError:动作未定义&#34;在控制台中没有任何反应。我是否应该包含另一个Javascript文件,因为教程中没有提到它?
答案 0 :(得分:5)
{
应该是
.factory('Config', function() {
var config = {};
var baseUrl = '';
config.setBaseUrl = function(url) {
baseUrl = url;
}
config.getBaseUrl = function() {
return baseUrl;
}
return config;
})
.factory('GetData', function($resource, Config) {
return {
get: function () {
var url = Config.getBaseUrl() + '/dkajskldas';
return $resource(url);
}
}
})