我试图将Paypal付款方式添加到我的应用中。这是我的JS代码。
app.controller('PaypalController',function($scope){
var output = function() {
var menuorder = '';
angular.forEach($scope.filtereditem, function(item) {
var size = " ";
var size2 = " ";
var size3 = " ";
var size4 = " ";
var size5 = " ";
angular.forEach(item.sizes, function(option) {
if (option && option.active) {
size += option.name + " in #1<br>";
}
if (option && option.active2) {
size2 += option.name + " in #2<br>";
}
if (option && option.active3) {
size3 += option.name + " in #3<br>";
}
if (option && option.active4) {
size4 += option.name + " in #4<br>";
}
if (option && option.active5) {
size5 += option.name + " in #5<br>";
}
});
menuorder += item.name + "<br/>Side: " + item.type + ", Qty: " + item.qty + ", Modifiers: " + item.modifier + "<br/><br/>Add-Ons:<br/>" + size + size2 + size3 + size4 + size5 + "<br/><br/>";
});
return menuorder;
}
$scope.filteredmenu = output();
var init_defer;
/**
* Service object
* @type object
*/
var service = {
initPaymentUI: initPaymentUI,
createPayment: createPayment,
configuration: configuration,
onPayPalMobileInit: onPayPalMobileInit,
};
function initPaymentUI(){
var clientIDs = {
"PayPalEnvironmentProduction": "XXXXXXXXXXXXXXXX",
"PayPalEnvironmentSandbox": "XXXXXXXXXXXXXXXX"
};
PayPalMobile.init(clientIDs, onPayPalMobileInit);
}
function createPayment() {
var paymentDetails = new PayPalPaymentDetails(scope.pricetotal, "0.00", "0.00");
var payment = new PayPalPayment(scope.pricetotal, "CAD", scope.filteredmenu, "Sale", paymentDetails);
return payment;
}
function configuration() {
var config = new PayPalConfiguration({merchantName: "SIGNS Store", merchantPrivacyPolicyURL: "https://mytestshop.com/policy", merchantUserAgreementURL: "https://mytestshop.com/agreement"});
return config;
}
function onPayPalMobileInit() {
PayPalMobile.prepareToRender("PayPalEnvironmentSandbox", configuration());
}
function onUserCanceled(result) {
console.log(result);
}
return {
initPaymentUI : initPaymentUI,
createPayment : createPayment,
configuration : configuration,
onPayPalMobileInit: onPayPalMobileInit,
}
$scope.pay = function(){
PayPalMobile.renderSinglePaymentUI(createPayment(), onSuccesfulPayment, onUserCanceled);
}
if(typeof PayPalMobile != 'undefined')
initPaymentUI();
page_load();
我的HTML代码如下:
<label>Payment Method: </label>
<md-select placeholder="Select a Payment Method" ng-model="item.payment" ng-change="selectChanged()">
<md-option aria-label="side set" class="md-accent" value="1">Pay at SIGNS</md-option>
<md-option aria-label="side set" class="md-accent" value="2">Pay Now</md-option>
</md-select>
<md-button class="md-raised md-primary" ng-controller="PaypalController" ng-show="item.payment==2" ng-click="pay()">
Pay with PayPal
</md-button>
所以基本上,我已将$ scope.pricetotal定义为其他地方的总价格并定义了$ scope.filteredmenu(我已经显示了代码)。这些是基于html选择的JSON变化元素,但最终分别作为数值和字符串,我试图将它们作为paypal价格和项目描述推送。
我已添加到我的索引中并添加了paypal插件以及在我的config.xml中使用(我使用phonegap构建)。我还添加了我的paypal沙盒和生产ID。然而,出于某种原因,贝宝似乎根本没有兴起。任何帮助都将不胜感激。
我的config.xml请求:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.signsrestaurant.app"
versionCode="1.00"
version = "1.00">
<name>Signs Restaurant</name>
<description>
Where Noise Meets Silence </description>
<author href="http://signsrestaurant.ca" email="gmanikumar@umhs-sk.net">
Signs Restaurant
</author>
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="orientation" value="default" />
<preference name="fullscreen" value="false" />
<preference name="target-device" value="universal" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="true" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="true" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="EnableViewportScale" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="true" />
<preference name="AllowInlineMediaPlayback" value="true" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="HideKeyboardFormAccessoryBar" value="true" />
<preference name="SuppressesIncrementalRendering" value="true" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="internalOnly" />
<preference name="SplashScreenDelay" value="5000" />
<preference name="ErrorUrl" value=""/>
<preference name="BackgroundColor" value="0x000000"/>
<preference name="KeepRunning" value="true"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="LoadingDialog" value=","/>
<preference name="LoadUrlTimeoutValue" value="20000" />
<preference name="disable-cursor" value="true" />
<gap:platform name="ios" />
<gap:platform name="android" />
<gap:platform name="winphone" />
<feature name="http://api.phonegap.com/1.0/battery"/>
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/device"/>
<gap:plugin name="org.apache.cordova.file" spec="1.3.3" source="pgb" />
<gap:plugin name="org.apache.cordova.file-transfer" spec="0.5.0" source="pgb" />
<gap:plugin name="org.apache.cordova.geolocation" source="npm" />
<gap:plugin name="org.apache.cordova.inappbrowser" source="npm" />
<gap:plugin name="org.apache.cordova.network-information" source="npm" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<gap:plugin name="com.paypal.cordova.mobilesdk" version="3.1.9" source="npm"/>
<gap:plugin name="nl.x-services.plugins.socialsharing" />
<gap:plugin name="com.plugin.datepicker" />
<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.2" />
<icon src="images/icon-57.png" gap:platform="ios" width="57" height="57" />
<icon src="images/icon-72.png" gap:platform="ios" width="72" height="72" />
<icon src="images/icon-114.png" gap:platform="ios" width="114" height="114" />
<icon src="images/icon-144.png" gap:platform="ios" width="144" height="144" />
<icon src="images/icon-76.png" gap:platform="ios" width="76" height="76" />
<icon src="images/icon-120.png" gap:platform="ios" width="120" height="120" />
<icon src="images/icon-152.png" gap:platform="ios" width="152" height="152" />
<icon src="images/icon-36.png" gap:platform="android" gap:density="ldpi" />
<icon src="images/icon-48.png" gap:platform="android" gap:density="mdpi" />
<icon src="images/icon-72.png" gap:platform="android" gap:density="hdpi" />
<icon src="images/icon-96.png" gap:platform="android" gap:density="xhdpi" />
<icon src="images/icon-144.png" gap:platform="android" gap:density="xxhdpi" />
<icon src="images/icon-192.png" gap:platform="android" gap:density="xxxhdpi" />
<icon src="images/icon-62.png" gap:platform="winphone" />
<icon src="images/icon-173.png" gap:platform="winphone" gap:role="background" />
<icon src="icon.png" />
<gap:splash src="images/splash-480-320.png" gap:platform="ios" width="320" height="480" />
<gap:splash src="images/splash-320-480.png" gap:platform="ios" width="480" height="320" />
<gap:splash src="images/splash-960-640.png" gap:platform="ios" width="640" height="960" />
<gap:splash src="images/splash-640-960.png" gap:platform="ios" width="960" height="640" />
<gap:splash src="images/splash-1136-640.png" gap:platform="ios" width="640" height="1136" />
<gap:splash src="images/splash-640-1136.png" gap:platform="ios" width="1136" height="640" />
<gap:splash src="images/splash-1024-768.png" gap:platform="ios" width="768" height="1024 " />
<gap:splash src="images/splash-768-1024.png" gap:platform="ios" width="1024" height="768" />
<gap:splash src="images/splash-400-240.png" gap:platform="android" gap:density="ldpi" />
<gap:splash src="images/splash-480-320.png" gap:platform="android" gap:density="mdpi" />
<gap:splash src="images/splash-800-480.png" gap:platform="android" gap:density="hdpi" />
<gap:splash src="images/splash-960-720.png" gap:platform="android" gap:density="xhdpi" />
<gap:splash src="images/splash-1920-1080.png" gap:platform="android" gap:density="xxhdpi" />
<gap:splash src="images/splash-800-480.png" gap:platform="winphone" />
<gap:splash src="splash.png" />
<access origin="*" />
</widget>
我的标题:
<head>
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://maps.google.com https://maps.googleapis.com https://s.ytimg.com">
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>Signs Restaurant and Bar</title>
<!-- All our CSS -->
<!-- onsen-css-components.css is the skin of your app, you can generate one custom skin with this generator: http://components.onsen.io/ -->
<link rel="stylesheet" href="lib/onsen/css/onsenui.css">
<link rel="stylesheet" href="css/onsen-css-components.css">
<link rel="stylesheet" href="css/plugins.css"/>
<link rel="stylesheet" href="css/roots.css"/>
<link rel="stylesheet" href="css/app.css"/>
<link rel="stylesheet" href="css/style.css">
<!-- These are our JS libraries that make all the magic in our App -->
<script src="js/maps.js"></script>
<script src="js/youtube.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular-animate.min.js"></script>
<script src="js/angular-aria.min.js"></script>
<script src="js/angular-messages.min.js"></script>
<script src="js/angular-material.min.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<script src="js/angular-sanitize.min.js"></script>
<script src="lib/onsen/js/angular/angular-touch.js"></script>
<script src="lib/onsen/js/onsenui.js"></script>
<script src="js/plugins.js"></script>
<script src="js/app.js"></script>
<script src="cordova.js"></script>
<script type="text/javascript" src="js/paypal-mobile-js-helper.js"></script>
</head>
答案 0 :(得分:0)
好的,这是你需要做的。
<feature (...)>
已被弃用。whitelist
系统<feature (...)>
。不要再使用它了。 SEE
删除强>
<feature name="http://api.phonegap.com/1.0/battery"/>
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/device"/>
所有核心插件现在都在NPM。 但是,现在,您应该使用的列表(对于&#34;核心&#34;插件)是:http://cordova.apache.org/docs/en/latest/cordova/plugins/pluginapis.html 此外,它现在被认为是最佳实践&#34; Phonegap Build 始终使用您想要的版本。
此外,一个多星期前,有some big changes to config.xml
。它们不会影响你的想法,但我已经为你做了一个改进,通过为你做出改变 - 哪里有意义。
<强>更换强>
<!--
<gap:plugin name="org.apache.cordova.file" spec="1.3.3" source="pgb" />
<gap:plugin name="org.apache.cordova.file-transfer" spec="0.5.0" source="pgb" />
<gap:plugin name="org.apache.cordova.geolocation" source="npm" />
<gap:plugin name="org.apache.cordova.inappbrowser" source="npm" />
<gap:plugin name="org.apache.cordova.network-information" source="npm" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
-->
有了这个
<plugin name="cordova-plugin-file" source="npm" spec="2.1.0" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="1.2.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="1.0.1" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="1.0.1" />
<plugin name="cordova-plugin-network-information" source="npm" spec="1.0.1" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="1.1.0" />
我已经更新了所有第三方插件。 如果他们无法建立或无法工作,请返回原始设置。 解释很长,为什么它们可能不起作用。
第三方插件
<!-- https://www.npmjs.com/package/com.paypal.cordova.mobilesdk -->
<plugin name="com.paypal.cordova.mobilesdk" source="npm" spec="3.1.9" />
<!-- https://www.npmjs.com/package/cordova-plugin-x-socialsharing -->
<plugin name="cordova-plugin-x-socialsharing" source="npm" spec="5.0.7" />
<!-- https://www.npmjs.com/package/cordova-plugin-datepicker -->
<gap:plugin name="cordova-plugin-datepicker" source="npm" spec="0.9.3" />
<!-- https://www.npmjs.com/package/cordova-plugin-email-composer -->
<gap:plugin name="cordova-plugin-email-composer" source="npm" version="0.8.2" />
whitelist
系统您需要实施白名单系统。
此白名单工作表应该有所帮助。
HOW TO apply the Cordova/Phonegap the whitelist system
与此同时,要做好工作,请做以下事项 注意您的应用程序现在不安全。由您来保护您的APP。
将以下内容添加到config.xml
更改强>
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" /> <!-- Required for iOS9 -->
将以下内容添加到index.html
更新时间:2015-12-01 以前,我忘记在*
元标记中添加外卡(CSP
)。我现在包括这个。此元标记应添加到播放音频的index.html
文件的标题中。
注意您的应用程序现在已不确定。由您来保护您的APP。
<meta http-equiv="Content-Security-Policy"
content="default-src *;
style-src * 'self' 'unsafe-inline' 'unsafe-eval';
script-src * 'self' 'unsafe-inline' 'unsafe-eval';">