w3c / payment-request

Payment Request API
https://www.w3.org/TR/payment-request/
Other
488 stars 135 forks source link

canMakePayment always return false #708

Closed cozohar closed 6 years ago

cozohar commented 6 years ago

Hi, I'm trying to understand why canMakePayment always return false although I have setup a card in the broswer. (When testing locally it always return true).

I configured a Visa test card in Chrome 4111111111111111 and also a real mastercard. I'm attaching the browser console. Am I doing something wrong? Is there a problem maybe?

const methodData = [{
        supportedMethods: "basic-card",
        data: {
            supportedNetworks: ["mastercard","visa"],
            supportedTypes: ["debit", "credit"]
        }
    }
];
const details = {
    total: {
        label: "Total due",
        amount: {currency: "USD", value: "10.00"}
    }
};
var request = new PaymentRequest(methodData, details);
PaymentRequest {id: "c12d264e-f677-49c8-b050-2252e38f5e24", shippingAddress: null, shippingOption: null, shippingType: null, onshippingaddresschange: null, …}
request.canMakePayment().then((result) => {
console.log(result);
});
Promise {<pending>}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: undefined

false
ianbjacobs commented 6 years ago

@cozohar, in what browser(s) are you testing?

marcoscaceres commented 6 years ago

Closing, as this is a browser issue, not a spec issue.

Nevertheless, with a bit more info we can try to help @cozohar.

If this is Safari: basic-card is not supported, only ApplePay is.

cozohar commented 6 years ago

@ianbjacobs in Chrome

marcoscaceres commented 6 years ago

In Chrome Desktop, I think you need to be logged into Google itself via the browser... but then again, my understanding is that canMakePayment() doesn't work the same as in Chrome on Android (where cards a verified against Google Pay).... hence, canMakePayment() returns false.

Google folks can give a definitive answer.

cozohar commented 6 years ago

I'm using Chrome Desktop. I wasn't logged in, so I did and I cleared cache (made sure the cards are still configured) and I'm still getting false every time.

n3o77 commented 6 years ago

Are you using a valid ssl cert?

cozohar commented 6 years ago

Hi @n3o77 , my SSL cert wasn't valid. Now it works! Thank you so much

ianbjacobs commented 6 years ago

Thanks all. I've added a question on this to the FAQ: https://github.com/w3c/payment-request-info/wiki/FAQ#canmakepayment-always-returns-false-why

I welcome suggestions for improving the question and answer.

Ian