thephpleague / omnipay-sagepay

Sage Pay driver for the Omnipay PHP payment processing library
MIT License
54 stars 78 forks source link

3200 : The BrowserAcceptHeader field is missing #180

Closed OccultScientist closed 2 years ago

OccultScientist commented 2 years ago

Hi,

Any idea what I'm missing here?

Getting the error: 3200 : The BrowserAcceptHeader field is missing I'm running this from a payment server so no browser details available.

Thanks in advance!

`$transactionId = "TEST-TRANSACTION-ID"; // Create the gateway object.

    $gateway = OmniPay::create('SagePay\Direct')->initialize([
        'vendor' => 'XXXXXX', // Removed for security
        'testMode' => true,
    ]);

    // Create the credit card object from details entered by the user.

    $card = new CreditCard([
        'firstName' => 'Card',
        'lastName' => 'User',

        'number' => '4929000000006',
        'expiryMonth' => '12',
        'expiryYear' => '2022',
        'CVV' => '123',

        // Billing address details are required.
        'billingFirstName' => 'Joe',
        'billingLastName' => 'Bloggs',
        'billingAddress1' => '88',
        'billingAddress2' => '',
        'billingState' => 'Place',
        'billingCity' => 'Somewhere',
        'billingPostcode' => '412',
        'billingCountry' => 'GB',
        'billingPhone' => '01234 567 890',
        'shippingFirstName' => 'Joe',
        'shippingLastName' => 'Bloggs',
        'shippingAddress1' => '88',
        'shippingAddress2' => '',
        'shippingState' => 'Place',
        'shippingCity' => 'Somewhere',
        'shippingPostcode' => '412',
        'shippingCountry' => 'GB',
        'shippingPhone' => '01234 567 890',

    ]);

    // Create the minimal request message.

    $requestMessage = $gateway->purchase([
        'apply3DSecure' => '1',
        'amount' => '99.99',
        'currency' => 'GBP',
        'card' => $card,
        'transactionId' => $transactionId,
        'description' => 'Test Payment',
        'clientIp' => 'XXX.XXX.XXX.XXX', // Removed for security
        'ThreeDSNotificationURL' => 'https://xxx.xxx.com/threedsnotification', // Removed for security

        // If 3D Secure is enabled, then provide a return URL for
        // when the user comes back from 3D Secure authentication.

        'returnUrl' => 'https://xxx.xxx..com/success', // Removed for security
    ]);

    // Send the request message.

    $responseMessage = $requestMessage->send();
    if ($responseMessage->isRedirect()) {
        $responseMessage->redirect();
    }

    print_r($responseMessage);`
dathwa commented 2 years ago

Hi. Did you get this working? Could you share? And did you manage using getThreeDSNotificationURL() with any success?

OccultScientist commented 2 years ago

Hi,

Probably not the best solution, but I ended up changing lines 62-63 in DirectAuthorizeRequest.php to be:

$data['BrowserAcceptHeader'] = $_SERVER['HTTP_ACCEPT'] ?? 'text/html, application/json'; $data['BrowserUserAgent'] = $_SERVER['HTTP_USER_AGENT'] ?? 'Unknown';

OccultScientist commented 2 years ago

After that I got a response and then used:

$data = $responseMessage->getRedirectData();

The data was then available in $data['threeDSSessionData']

OccultScientist commented 2 years ago

Once, you're there, let me know if you have this issue too, could do with another pair of eyes on it 😄 https://github.com/thephpleague/omnipay-sagepay/issues/181

dathwa commented 2 years ago

Once, you're there, let me know if you have this issue too, could do with another pair of eyes on it 😄 #181

I'm knee deep in this myself. Will defo share any progress I make. First off, I noticed in your other comments you still seem to be on protocol 3. You plan to update to 4?

OccultScientist commented 2 years ago

Haven't worked that bit out yet! The initial request does say the VPS Protocol is 4.00 but the final response says 3.00

dathwa commented 2 years ago

Haven't worked that bit out yet! The initial request does say the VPS Protocol is 4.00 but the final response says 3.00

Ahh really? And you are on latest omnipay/sagepay? I updated this then the protocol changed automatically. In your composer file it maybe says "omnipay/sagepay": "^3.0", ? Change it to "omnipay/sagepay": "^4.0", then composer update. Worked for me.

OccultScientist commented 2 years ago

Haven't worked that bit out yet! The initial request does say the VPS Protocol is 4.00 but the final response says 3.00

Ahh really? And you are on latest omnipay/sagepay? I updated this then the protocol changed automatically. In your composer file it maybe says "omnipay/sagepay": "^3.0", ? Change it to "omnipay/sagepay": "^4.0", then composer update. Worked for me.

Nice, thanks. It looks like I'm already on 4.0 :)