question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apple Pay does not work with xcomponent due to insecure parent frame

See original GitHub issue

Hi,

I’m using Stripe API to open Apple Pay within an xcomponent lightbox. However, it throws an error “Trying to call an ApplePaySession API from a document with an insecure parent frame” when it detects the outermost iframe is not secure (not starting with https) as below: <iframe name="__lightbox_container__ec6827b044__" scrolling="no" frameborder="0" style="display: block; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 2147483647;"></iframe>

Can you please look into?

Here is how I implement the Apply Pay:

<style>
  #apple-pay-button {
    display: none;
    background-color: black;
    background-image: -webkit-named-image(apple-pay-logo-white);
    background-size: 100% 100%;
    background-origin: content-box;
    background-repeat: no-repeat;
    width: 100%;
    height: 44px;
    padding: 10px 0;
    border-radius: 10px;
  }
</style>

<button id="apple-pay-button"></button>

<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script>
    Stripe.setPublishableKey('pk_test_6pRNASCoBOKtIshFeQd4XMUh');

    Stripe.applePay.checkAvailability(function(available) {
        if (available) {
            document.getElementById('apple-pay-button').style.display = 'block';
        }
    });

    document.getElementById('apple-pay-button').addEventListener('click', beginApplePay);


    function beginApplePay() {
        var paymentRequest = {
            countryCode: 'US',
            currencyCode: 'USD',
            total: {
                label: 'Stripe.com',
                amount: '19.99'
            }
        };
        var session = Stripe.applePay.buildSession(paymentRequest,
            function(result, completion) {

            $.post('/charges', { token: result.token.id }).done(function() {
                completion(ApplePaySession.STATUS_SUCCESS);
                //window.xchild.props.onComplete('Apple Pay succeeded!');

            }).fail(function() {
                completion(ApplePaySession.STATUS_FAILURE);
                //window.xchild.props.onComplete('Apple Pay error!');
                
            });

        }, function(error) {
            console.log(error.message);
        });

        session.oncancel = function() {
            console.log("User hit the cancel button in the payment window");
            //window.xchild.props.onComplete('Apple Pay canceled!');
        };

        session.begin();
    }
</script>

Thanks, Ky

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bluepnumecommented, Mar 23, 2017

OK, I’ve added an option for this: sandboxContainer: false

xcomponent.create({
    sandboxContainer: false
});

I tried this with your code and I now see the apple pay button. Can you give it a try on your side? Thanks!

screen shot 2017-03-22 at 6 08 26 pm
0reactions
ghostcommented, Mar 23, 2017

It works now. Much thanks for your effort.

– Ky

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apple Pay component security
Apple Pay uses several hardware and software features to provide secure, reliable purchases.
Read more >
Apple Pay security and privacy overview
Learn how Apple protects your personal information, transaction data, and payment information when you use Apple Pay.
Read more >
TN3103: Apple Pay on the Web troubleshooting guide
Troubleshooting guide for implementing Apple Pay on the Web. Overview. This document is intended to be used as a general guide to debugging...
Read more >
View and limit your child or teen's Apple Cash activity
With Apple Cash Family, you can view your child or teen's balance and transactions, choose who they can send money to, and lock...
Read more >
Can apple pay be tested on localhost? - Apple Developer
Even if I'm using a sandbox account, do I have to run this on an verified domain? and is it possible to somehow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found