问题
I would like to implement Apple Pay for web. I was getting a little bit confused by the documentations of Sandbox and Production. I'm using Mac mini (late 2012) with Sierra and iPad mini 3 with IOS 10.
Can you please help me understand what is needed for Sandbox testing? I was following: Apple Pay Sandbox Testing.
- Both devices are on the same WIFI, bluetooth is on, handoff is on and AirDrop is on.
- I created a sandbox user and logged in with it to icould on both devices.
- I added a test credit card to the Wallet app in my iPad
- Do I need to configure merchant id, certificate and merchant domain?
I'm using this simple code that I found here. I can't get canMakePayments() to return true. I receive: "ApplePay is possible on this browser, but not currently activated."
window.onload = function() {
if (window.ApplePaySession) {
var merchantIdentifier = 'example.com.store';
var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
promise.then(function (canMakePayments) {
if (canMakePayments) {
console.log("Hi, I can do ApplePay");
document.getElementById("applePay").style.display = "block";
}
else {
console.log("ApplePay is possible on this browser, but not currently activated.");
document.getElementById("got_notactive").style.display = "block";
}
});
}
else {
console.log("ApplePay is not available on this browser");
document.getElementById("notgot").style.display = "block";
}
}
回答1:
I had similar issues with ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier)
not returning true
in the promise.
Using ApplePaySession.canMakePayments()
instead did return true
when the various conditions you mention for a sandbox user (pairing, iCloud etc.) were met on macOS Safari, and payments could be successfully handled with hand-off to iPhone and Apple Watch.
It would of course be good to determine what the missing thing is that makes ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier)
seemingly not return true
on macOS. It seems to work fine on iOS.
回答2:
Apple Pay: sandbox vs production: I also implemented it. So for sandbox you only need:
- a sandbox merchant id
- a sandbox user -> log in into the testing device with that user (you can create sandbox test user in your apple pay developer account)
- you dont need to host the certificate for the sandbox environment
- if you are integrating it through some third party payment provider (eg. braintree), you should set up your testing domain there (eg: http://my-sandbox-website.com)
- go to the apple pay on the web website and search for test credit cards -> go to your testing device -> Wallet and add one of those credit cards there
Thats it, you're good to go :)
来源:https://stackoverflow.com/questions/39728878/starting-with-apple-pay-on-the-web