【发布时间】:2020-02-18 06:35:22
【问题描述】:
这是我的代码,我收到错误付款未完成。我在 Condova 中使用 Apple Pay with Stripe。
我已经使用了这两个插件,但给了我错误。还请说明如何获得条带令牌。
ApplePay.makePaymentRequest($scope.order).then((paymentResponse) 传递 $scope 没有得到 paymentResponse
ApplePay.canMakePayments({
// supportedNetworks should not be an empty array. The supported networks currently are: amex, discover, masterCard, visa
supportedNetworks: ['visa', 'amex', 'masterCard', 'discover'],
// when merchantCapabilities is passed in, supportedNetworks must also be provided. Valid values: 3ds, debit, credit, emv
merchantCapabilities: ['3DS', 'debit', 'credit', 'emv']
}).then((message) => {
alert(message);
$scope.order = {};
$scope.order.items = [{
label: 'Subscription Charge',
amount: 1.00
}];
$scope.order.shippingMethods = [
{
"label": "Free Shipping",
"detail": "Subscription plan",
"amount": "0.00",
"identifier": "FreeShip"
}
];
$scope.order.supportedNetworks = ['visa', 'masterCard','discover'];
$scope.order.merchantCapabilities = ['3DS', 'debit', 'credit'];
$scope.order.merchantIdentifier = "merchant.com.appguys.foodroamer";
$scope.order.currencyCode = 'USD';
$scope.order.countryCode = 'US';
$scope.order.billingAddressRequirement = 'none';
$scope.order.shippingAddressRequirement = 'none';
$scope.order.shippingType = 'service';
ApplePay.makePaymentRequest($scope.order).then((paymentResponse) => {
alert(JSON.stringify(paymentResponse));
alert("Token Here",paymentResponse.paymentData);
httpService.userPost($scope.base_url+'domakeTestPayment',{'token':paymentResponse.paymentData}).then(function(paymentResponse){
alert(JSON.stringify(paymentResponse));
});
}).catch((e) => {
alert(4);
alert(e);
// Failed to open the Apple Pay sheet, or the user cancelled the payment.
})
}).catch((message) => {
alert(2);
alert(message);
console.log(message);
// There is an issue, examine the message to see the details, will be:
// 'This device cannot make payments.''
// 'This device can make payments but has no supported cards'
});
<plugin name="cordova-plugin-stripe-apple-pay" spec="https://github.com/asangadev/cordova-plugin-stripe-apple-pay">
<variable name="STRIPE_LIVE_PUBLISHABLE_KEY" value="xxxxxxxxxxx" />
<variable name="STRIPE_TEST_PUBLISHABLE_KEY" value="xxxxxxxx" />
<variable name="APPLE_MERCHANT_IDENTIFIER" value="xxxxxxxxxxx" />
</plugin>
【问题讨论】:
-
我没有具体使用过 Cordova,但是在 Apple Pay 中,您的代码通常需要调用一个完成函数,告诉工作表支付成功并且可以关闭工作表,例如 developer.apple.com/documentation/apple_pay_on_the_web/…例如。
-
我用 Braintree 代替了条纹。请记住,我还在 Apple id 和沙盒中将国家/地区更改为美国
标签: cordova stripe-payments phonegap-plugins phonegap applepay