2
votes

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.

  1. Both devices are on the same WIFI, bluetooth is on, handoff is on and AirDrop is on.
  2. I created a sandbox user and logged in with it to icould on both devices.
  3. I added a test credit card to the Wallet app in my iPad
  4. 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";
    }
}
2

2 Answers

1
votes

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.

0
votes

Apple Pay: sandbox vs production: I also implemented it. So for sandbox you only need:

  1. a sandbox merchant id
  2. a sandbox user -> log in into the testing device with that user (you can create sandbox test user in your apple pay developer account)
  3. you dont need to host the certificate for the sandbox environment
  4. 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)
  5. 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 :)