braintree / braintree_aspnet_example

An example Braintree integration in the ASP.NET framework
MIT License
57 stars 50 forks source link

This Device is not capable of making Apple Pay payments #32

Closed khanrafay closed 5 years ago

khanrafay commented 5 years ago

General information

Issue description

Hi,

I am currently in the middle of integrating Apple pay javascript on the web. It is creating apple pay session and it does support v3 but it returns false on canMakePayment()

I am unable to find out the issue over here as i am following the exact code provided by braintree

https://developers.braintreepayments.com/guides/apple-pay/client-side/javascript/v3

I am also attaching the error i am facing right now.

braintree-error

------------------------- My Code --------------------------------------

if (!ApplePaySession.canMakePayments()) {
    console.error('This device is not capable of making Apple Pay payments');
}

braintree.client.create({
    authorization: '@BraintreeManager.Gateway.ClientToken.generate()'
}, function (clientErr, clientInstance) {
    if (clientErr) {
        console.error('Error creating client:', clientErr);
        return;
    }

    braintree.applePay.create({
        client: clientInstance
    }, function (applePayErr, applePayInstance) {
        if (applePayErr) {
            console.error('Error creating applePayInstance:', applePayErr);
            return;
        }

        // Alternatively, check if the device has an Apple Pay card available.
        // You can do this if your checkout flow defaults to Apple Pay
        // or if you are displaying Apple Pay buttons on a product detail page.

        // Use your Apple Pay merchant identifier
        // to check if payments can be made.

        var promise = ApplePaySession.canMakePaymentsWithActiveCard(applePayInstance.merchantIdentifier);
        promise.then(function (canMakePaymentsWithActiveCard) {
            if (canMakePaymentsWithActiveCard) {
                // Set up Apple Pay buttons
                var createApplePay = document.getElementById("create-apple-pay");
                createApplePay.innerHTML = '<div class="apple-pay-set-up-button apple-pay-setup-button-white-with-line">';
                console.log("Inside set up apple pay button");

            }
        });
    });
});
crookedneighbor commented 5 years ago

Contact our support team for help with your integration https://help.braintreepayments.com/