将Paymill集成到Angular JS中

时间:2014-10-30 12:02:30

标签: angularjs paymill

我正在使用WordPress的AngularJs。我不使用人们只能通过角形预订的商店。我通过节点安装了这个库 https://github.com/paymill/paymill-js

脚本js通过wordpress集成:

WORDPRESS:

wp_register_script('paymill', get_bloginfo('template_directory').'/angular/node_modules/paymill-wrapper/paymill.node.js', array(), null, false);
wp_enqueue_script('paymill');

正确加载。 Angular也适用于我的Wordpress设置。

然后我在控制器中创建了一个付款对象:

ANGULARJS:

myAppControllers.controller('PaymentCtrl', function ($scope) {
  var paymill = new PaymillContext();
  //paymill.getContext('613687880697af015308b1a6f864aeb1');
});

HTML:

 <div id="payment-group" class="form-group" ng-controller="PaymentCtrl" ng-class="{ 'has-error' : errorPayment }"></div>

不幸的是我的控制器抛出错误。 未捕获的ReferenceError:在paymill.node.js第3行中未定义require

我认为它与Angular不加载脚本有关,因为它是在前端执行的?

问题: 如何使这个工作?

1 个答案:

答案 0 :(得分:0)

您不应直接从Angular调用PAYMILL Rest API,因为这会将您的私钥暴露给公众。有一个官方支持的Wordpress插件,https://developers.paymill.com/en/reference/plugins-and-extensions/,你不能使用它吗?