Shopware6 icon indicating copy to clipboard operation
Shopware6 copied to clipboard

Apple Pay Direct: Error when requesting Apple Pay Payment Session

Open m-waes opened this issue 2 years ago • 1 comments

Hi, According to the documentation the Payment Session is requested like this: Endpoint (Global): POST https://apple-pay-gateway.apple.com/paymentservices/paymentSession

At the end of the page there is the following hint:

Note Start Session is being phased out and replaced by Payment Session.

When calling https://api.mollie.com/v2/wallets/applepay/sessions via Postman with the following payload:

{
    "domain": "cd8c-2003-dd-2f2b-1b00-d5ba-e7bf-dc7c-5e76.ngrok.io",
    "validationUrl": "https://apple-pay-gateway.apple.com/paymentservices/paymentSession"
}

the validation works.

The following call is made via JS by the Mollie Plugin: /mollie/apple-pay/validate

and the validationUrl is grabbed like this: $validationURL = (string)$content['validationUrl'];

when dumping this url, I get (note it's startSession not paymentSession): https://apple-pay-gateway-cert.apple.com/paymentservices/startSession

Using this url in the payload above, the validation fails like this:

{
    "status": 422,
    "title": "Unprocessable Entity",
    "detail": "Validation URL is not on the white list",
    "field": "validationUrl",
    "_links": {
        "documentation": {
            "href": "https://docs.mollie.com/overview/handling-errors",
            "type": "text/html"
        }
    }
}

I changed ApplePayController::createPaymentSession() like this: (hardcoding the validationUrl)

public function createPaymentSession(SalesChannelContext $context, Request $request): JsonResponse
{
    try {
        $content = json_decode($request->getContent(), true);

        $validationURL = (string)$content['validationUrl'];
        dump($validationURL);
        $validationURL = 'https://apple-pay-gateway.apple.com/paymentservices/paymentSession';

With this change, the validation also works inside the shop. image

Is this known behavior?

m-waes avatar Aug 26 '22 11:08 m-waes

Hi

thanks for this

i have to look it up I never had troubles with Apple Pay Direct (just tested it 2 days ago) except 2 times where the Mollie API had troubles with Apple and Domain registration

so there shouldnt be a real bug in it (except, what makes me curious is the phasing out text....maybe they switch to other endpoints? meh)

i will test it again next week

boxblinkracer avatar Aug 26 '22 13:08 boxblinkracer

so i've just tested it again for the release it all works as expected so i will close this issue, i only had some troubles with new domains again recently (Because of my dev account probably) but the code itself is all good

boxblinkracer avatar Oct 04 '23 08:10 boxblinkracer