Sandbox user not working

I'm trying to spin up the Apple Pay Web magic, and I can't seem to get can make payments to return true. I've got my sandbox test account signed in on both my iPad and sierra MBP, with the latest beta on both. On the iPad, I have two different test cards from the documentation in place, and I definitely see sandbox under Wallet and Apple Pay. I went ahead and ran the same code on Safari on the ipad, and I get the same result. Thanks.

if (window.ApplePaySession) { // returns true
  console.log("supports version: " + ApplePaySession.supportsVersion(1)); // returns true
  var merchantIdentifier = 'merchant.blah';
  var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
  promise.then(function (canMakePayments) {
  if (canMakePayments) { // returns false
  $("#applePay").show();
  console.log('hi, I can do ApplePay');
  } else {
  $("#applePay").after('<p>ApplePay is possible on this browser, but not currently activated.</p>');
  console.log('ApplePay is possible on this browser, but not currently activated.'); /
  }
  });
} else {
  console.log('ApplePay not available on this browser');
  $("#applePay").after('ApplePay not available on this browser');
}

Can you post the rest of your page? Need to see if you're including query source, and what element you have id="applePay" on.

Here you go!


I'm getting the text appended onto the #applePay element ("not possible in the browser"), and the console.log is populating the same message.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"><head>
  <script src="./jquery-3.1.0.min.js"></script>
  <script type="text/javascript">

  $( document ).ready( function( )
  {
  if (window.ApplePaySession) {
  console.log("supports version: " + ApplePaySession.supportsVersion(1));

  var merchantIdentifier = 'merchant.blah';
  var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
  promise.then(function (canMakePayments) {
  if (canMakePayments) {
  $("#applePay").show();
  console.log('hi, I can do ApplePay');
  } else {
  $("#applePay").after('<p>ApplePay is possible on this browser, but not currently activated.</p>');
  console.log('ApplePay is possible on this browser, but not currently activated.');
  }
  });
  } else {
  console.log('ApplePay not available on this browser');
  $("#applePay").after('ApplePay not available on this browser');
  }

  $("#applePay").click( function(evt) {

  var paymentRequest = {
  currencyCode: 'USD',
  countryCode: 'US',
  total: {
  label: 'stuff and things',
  amount: '3.00'
  },
  supportedNetworks: ['amex', 'discover', 'masterCard', 'visa' ],
  merchantCapabilities: [ 'supports3DS' ]
  };

  var session = new ApplePaySession(1, paymentRequest);

  // Merchant Validation
  session.onvalidatemerchant = function (event) {
  console.log(event);
  var promise = performValidation(event.validationURL);
  promise.then(function (merchantSession) {
  session.completeMerchantValidation(merchantSession);
  console.log('Starting session.completeMerchantValidation');
  });
  };

  function performValidation(valURL) {
  return new Promise(function(resolve, reject) {
  // hitting validation service here
  console.log("status" + status);
  console.log("data" + data);

// console.log('starting function performValidation()');
// console.log(valURL);
  resolve;
  });
  }

  session.begin();
  });
  });
  </script>
  <style>
  #applePay {
  width: 280px;
  height: 64px;
  display: inline-block;
  border: 1px solid black;
  box-sizing: border-box;
  background-image: url(../img/ApplePayBTN_32pt__black_textLogo_@2x.png);
  background-size: 100%;
  background-repeat: no-repeat;
  }
  </style>
</head>
<body>
<button type="button" id="applePay" style="display:none"></button>
</body>
</html>

New data point! I can get the payment sheet to appear on the iphone simulator in xcode, so the problem appears to be isolated to my IRL ipad and MBP.

My full code post is still in moderation, but now it's wildly out of date. 🙂


But! I was able to get pretty far using the simulator; I'm now stuck on payment not completed. Got the onpaymentmethodselected et. al. events captured / fleshed out, and I've done some hosts file manipulation to mimic my verified domain.


session.onvalidatemerchant = function(event) {
  console.log("Validate url : " + event.validationURL);
  performValidation(event.validationURL).then(function (merchantSession) {
  console.log("validation promise returned");
  session.completeMerchantValidation(merchantSession);
  });
};


The merchant session coming back from performValidation appears to be valid. I'm continuing to fiddle, but the fact that my devices can't use the account that's working in the simulator seems fishy to me...

So are you able to see the payment sheet on your computer, but not on your iPad?


I wasn't sure that the iPad was supported, but mine is SUPER old!

I can see it on the iPhone simulator on my computer. No dice on Safari in the iPad, nor on Safari on my MBP running the beta.

Okay, I was able to get a full end to end payment within the simulator. Still no dice on the "real" devices:


payment token: {"transactionIdentifier":"Simulated Identifier","paymentMethod":{"displayName":"Simulated Instrument"}}


Does that seem correct for the sandbox payment tokens? I was expecting something more...encrypted.

That looks like local reply from the simulator. The real servers give realistic tokens

A couple of things i had to play around with to get mine to work:

1) Make sure you're on the same wifi network

2) Make sure you have paired your device with your MBP



When you visit your website on your iPad, you don't even see the button ?

Did you say you have a domain verified with apple, can you put the code/pages all up there to test it for reals? the service isn't live yet so no chance of anyone getting charged anything, and you eliminate any issues due to mockup environments and mimicked responses.

I didn't need to pair the iPhone/MBP to get it working, but it wouldn't work with an older iMac. I was guessing it used BTLE, which my MBP supports but my iMac doesn't.


They both have to be logged into the same iCloud account, obvs.

Yeah, that's my next step. Given that I was able to verify the flow via the simulator, albeit with the simulated token responses, I should be good to go with the initial implementation. Next comes the fun part of integrating auth / cap scenarios. 🙂


Thanks everyone!

Yeah, 2013 MBP and iPad Mini 3, which both should be BTLE. Same sandbox iCloud account, same wifi, no button appearing. It's the damndest thing. I've reached out to our support contact to see if they can provide any additional guidence. Now that I've got the APW flow proof of concept, I can hand it off to the people who code better than me™, and hopefully get some more iOS / macOS data points.

A couple of things I have experienced. Since I am now able to receive a merchantSessionIdentifier via the JSON response from the certification Apple Pay for web endpoint of https://apple-pay-gateway-cert.apple.com/paymentservices/startSession


I thought I would be able to use my personal iPhone 6S Plus to perform an end-to-end Apple Pay for web transaction in against my development environment web server. In my case, I am resolving to my private IP of https://10.0.1.24. So, I create an iTunes Connect Sandbox User account and verify it via link sent in email. I then sign out of of Settings -> iTunes & App Stores for my personal account on my iPhone 6S Plus and then attempt to sign in using the new sandbox user account I created. It doesn't let me do that and always returns an alert the reads "iTunes account creation not allowed. This Apple ID cannot be used with the iTunes Store at this time. Please try again later." http://stackoverflow.com/questions/38266084/itunes-account-creation-not-allowed-when-trying-to-test-in-app-purchases


So, I am thinking my newly created sandbox user isn't quite ready for use????


In the meantime, I did try and add some of these Apple Pay test card numbers manually on my iPhone 6S Plus and I get a UIAlert titled:


"Your Issuer Does Not Yet Offer Support for This Card"

Learn more about current supports..blah blah blah

The other experience I see on both a real iPhone 6S Plus and the iPhone simulator running (iOS 10 beta) is that when the payment sheet appears, I quickly see a "Payment Not Completed" with a red circle and a red exclamation point and the payment sheet dissapears as I see the Apple Pay Session "oncancel" event is fired. At this point, I am not sure what I missing in my web code for the payment to not complete.

Sandbox user not working
 
 
Q