October 2017
Intermediate to advanced
370 pages
8h 57m
English
The next thing we need to do is set up the iframe source page. This will be a non-AMP page that:
There's some JavaScript to work through in this example. We'll only highlight the important parts here and you can see the full code for the amp-iframe at /ch9/checkout.html.
The first part is easy. We can add a button like this:
<button id="btn-pay">Checkout</button>
Before we do anything with the Payment Request API, we should check for support using window.PaymentRequest. If it's not supported, the user should be redirected to a non-AMP alternative checkout:
if (!window.PaymentRequest) ...
Read now
Unlock full access