checkout / checkout-sdk-php

Checkout SDK for PHP
MIT License
48 stars 40 forks source link

Receiving error: payment_method_not_supported #226

Open adamjimenez opened 1 year ago

adamjimenez commented 1 year ago

I'm using the test card details and receive the error payment_method_not_supported when attempting a transaction in our test account.

Ths is an abridged version of my code:

        $requestTokenSource = new RequestTokenSource();
        $requestTokenSource->token = $token; // Token is posted from card form

        $threeDsRequest = new ThreeDsRequest();
        $threeDsRequest->enabled = true;

        $paymentInstrumentSender = new PaymentInstrumentSender();

        $paymentRequest = new PaymentRequest();
        $paymentRequest->source = $requestTokenSource;
        $paymentRequest->capture = true;
        $paymentRequest->capture_on = date('c', strtotime('tomorrow'));  // ISO 8601 e.g. "2019-09-10T10:11:12Z",
        $paymentRequest->reference = $ref;
        $paymentRequest->amount = $amount * 100;
        $paymentRequest->currency = Currency::$GBP;
        $paymentRequest->sender = $paymentInstrumentSender;
        $paymentRequest->three_ds = $threeDsRequest;
        $paymentRequest->success_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        $paymentRequest->failure_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        $paymentRequest->metadata = $metadata;
        $paymentRequest->processing_channel_id = 'pc_nfv2zwctplcejmdirobdx5abty';

    $customerRequest = new CustomerRequest();
    $customerRequest->email = $user['email'];
    $customerRequest->name = $user['name'] . ' ' . $user['surname'];
        $paymentRequest->customer = $customerRequest;

        $paymentResponse = $this->api->getPaymentsClient()->requestPayment($paymentRequest);
armando-rodriguez-cko commented 1 year ago

Hi @adamjimenez! We will take a look and get back to you as soon as possible. Thank you.

armando-rodriguez-cko commented 1 year ago

Hi @adamjimenez! Sandbox accounts come enabled for Visa and Mastercard tests only, if you need to enable other schemes, you need to be done in the account config, please check your test card(s).

armando-rodriguez-cko commented 1 year ago

Hi @adamjimenez, we close this issue due to inactivity, if you need it, please open a new issue. Thank you.

adamjimenez commented 1 year ago

Hi @adamjimenez, we close this issue due to inactivity, if you need it, please open a new issue. Thank you.

So it takes you 3 weeks to respond and you give me 2 days?

armando-rodriguez-cko commented 1 year ago

Hi @adamjimenez, we apologise, we reopen this issue, you can now publish a new comments.

adamjimenez commented 1 year ago

In answer to your question, I'm using the visa test card 4242424242424242 from the test cards list.

armando-rodriguez-cko commented 1 year ago

Thank you @adamjimenez. We are testing your example and the data. At the same time, please check in the SDK tests, there are some examples with 3DS.

armando-rodriguez-cko commented 10 months ago

Hi @adamjimenez! Happy new year. Please try this:


<?php

use Checkout\CheckoutApiException;
use Checkout\CheckoutSdk;
use Checkout\Common\Currency;
use Checkout\Common\CustomerRequest;
use Checkout\Environment;
use Checkout\Payments\Request\PaymentRequest;
use Checkout\Payments\Request\Source\RequestTokenSource;
use Checkout\Payments\Sender\PaymentInstrumentSender;
use Checkout\Payments\ThreeDsRequest;
use Checkout\Tokens\CardTokenRequest;

require __DIR__ . '/vendor/autoload.php';

$CheckoutAPI = CheckoutSdk::builder()->staticKeys()
    ->publicKey("pk_sbox_xxxx")
    ->secretKey('sk_sbox_xxxx')
    ->environment(Environment::sandbox())
    ->build();

$cardTokenRequest = new CardTokenRequest();
$cardTokenRequest->number = "4242424242424242";
$cardTokenRequest->expiry_month = 6;
$cardTokenRequest->expiry_year = 2025;

try {
    $tokenResponse = $CheckoutAPI->getTokensClient()->requestCardToken($cardTokenRequest);

    $requestTokenSource = new RequestTokenSource();
    $requestTokenSource->token = $tokenResponse["token"];

    $threeDsRequest = new ThreeDsRequest();
    $threeDsRequest->enabled = true;

    $paymentInstrumentSender = new PaymentInstrumentSender();

    $customerRequest = new CustomerRequest();
    $customerRequest->email = $user['email'];
    $customerRequest->name = $user['name'] . ' ' . $user['surname'];

    $paymentRequest = new PaymentRequest();
    $paymentRequest->source = $requestTokenSource;
    $paymentRequest->amount = $amount * 100;
    $paymentRequest->currency = Currency::$GBP;
    $paymentRequest->capture = true;
    $paymentRequest->capture_on = date('c', strtotime('tomorrow'));  // ISO 8601 e.g. "2019-09-10T10:11:12Z",
    $paymentRequest->reference = $ref;
    $paymentRequest->three_ds = $threeDsRequest;
    $paymentRequest->sender = $paymentInstrumentSender;
    $paymentRequest->customer = $customerRequest;
    $paymentRequest->processing_channel_id = 'pc_xxxx';
    $paymentRequest->metadata = $metadata;
    $paymentRequest->success_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $paymentRequest->failure_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

    try {
        $response = $CheckoutAPI->getPaymentsClient()->requestPayment($paymentRequest);
        print_r($response);
        exit;
    } catch (Exception $ex) {
        print_r($ex->getMessage());
    }

} catch (CheckoutApiException $ex) {
    print_r($ex->getMessage());
}
exit;

This is the response with my credentials and processing channel:


Array
(
    [http_metadata] => Checkout\HttpMetadata Object
        (
            [reason_phrase:Checkout\HttpMetadata:private] => Accepted
            [status_code:Checkout\HttpMetadata:private] => 202
            [headers:Checkout\HttpMetadata:private] => Array
                (
                    [Date] => Array
                        (
                            [0] => Fri, 12 Jan 2024 10:01:51 GMT
                        )

                    [Content-Type] => Array
                        (
                            [0] => application/json; charset=utf-8
                        )

                    [Content-Length] => Array
                        (
                            [0] => 542
                        )

                    [Connection] => Array
                        (
                            [0] => keep-alive
                        )

                    [Location] => Array
                        (
                            [0] => https://api.sandbox.checkout.com/payments/pay_xxxx
                        )

                    [Cko-Request-Id] => Array
                        (
                            [0] => xxxx-xxxx-xxxx-xxxx
                        )

                    [Cko-Version] => Array
                        (
                            [0] => 1.344.1+e6797bc63
                        )

                    [Strict-Transport-Security] => Array
                        (
                            [0] => max-age=16000000; includeSubDomains; preload;
                        )

                )

            [protocol:Checkout\HttpMetadata:private] => 1.1
        )

    [id] => pay_xxxx
    [status] => Pending
    [reference] => xxxx
    [customer] => Array
        (
            [id] => cus_xxxx
            [email] => email
            [name] => name
        )

    [3ds] => Array
        (
            [downgraded] => 
            [enrolled] => Y
        )

    [_links] => Array
        (
            [self] => Array
                (
                    [href] => https://api.sandbox.checkout.com/payments/pay_xxxx
                )

            [actions] => Array
                (
                    [href] => https://api.sandbox.checkout.com/payments/pay_xxxx/actions
                )

            [redirect] => Array
                (
                    [href] => https://api.sandbox.checkout.com/sessions-interceptor/sid_xxxx
                )

        )

)
adamjimenez commented 10 months ago

Hi,

Thanks for the reply. I've tried the code and am still getting the same 422 error.

I did a composer update and we're on 3.0.20 version of the sdk.

I checked the keys and processing id which appear to be correct.

Is there any way to get more information on this error?

armando-rodriguez-cko commented 10 months ago

Hi @adamjimenez!

Debugging you can find a detailed error in:

image

image

adamjimenez commented 10 months ago

Thanks!

It says:

3ds_not_configured

How do we resolve this?

On Mon, 15 Jan 2024 at 17:45, Armando Rodríguez @.***> wrote:

Hi @adamjimenez https://github.com/adamjimenez!

Debugging you can find a detailed error in:

image.png (view on web) https://github.com/checkout/checkout-sdk-php/assets/127134616/11f6d880-5364-4645-9659-4d30eacf8873

image.png (view on web) https://github.com/checkout/checkout-sdk-php/assets/127134616/a6c31f08-13af-4589-ad2b-22db6a1fcad0

— Reply to this email directly, view it on GitHub https://github.com/checkout/checkout-sdk-php/issues/226#issuecomment-1892576610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEL6CBKIT5N5P2R3YP4EG3YOVTK3AVCNFSM6AAAAAA64PBEAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJSGU3TMNRRGA . You are receiving this because you were mentioned.Message ID: @.***>

-- Best regards, Adam Jimenez

armando-rodriguez-cko commented 10 months ago

I think that this link can help you: https://www.checkout.com/docs/card-issuing/manage-cards/enroll-a-card-in-3d-secure

adamjimenez commented 10 months ago

Thanks,

The instructions mention "Go to the Card Issuing > Cards page." But this link doesn't exist in the Sandbox dashboard https://dashboard.sandbox.checkout.com/.

Will actual customer cards be automatically enrolled?

On Tue, 16 Jan 2024 at 11:17, Armando Rodríguez @.***> wrote:

I think that this link can help you:

https://www.checkout.com/docs/card-issuing/manage-cards/enroll-a-card-in-3d-secure

— Reply to this email directly, view it on GitHub https://github.com/checkout/checkout-sdk-php/issues/226#issuecomment-1893541167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEL6CA3HSMHLJTEJMHN5K3YOZOTRAVCNFSM6AAAAAA64PBEAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJTGU2DCMJWG4 . You are receiving this because you were mentioned.Message ID: @.***>

-- Best regards, Adam Jimenez

adamjimenez commented 10 months ago

I'm not sure if that link applies. How do we enable 3ds in the sandbox area?

armando-rodriguez-cko commented 8 months ago

Hi @adamjimenez, please check https://www.checkout.com/docs/card-issuing/manage-cards/enroll-a-card-in-3d-secure

inikoo commented 8 months ago

That documentation is nothing to do with the problem, he is using the test card 4242424242424242 , that documentations is for issuing other cards

lrotherfield-function commented 7 months ago

I too am receiving 422 responses using the sandbox. Here is a request payload:

URL: https://api.sandbox.checkout.com/payments

{
  "source": {
    "type": "token",
    "token": "***",
    "billing_address": {
      "address_line1": "***",
      "address_line2": "",
      "city": "***",
      "state": "***",
      "zip": "00000",
      "country": "AE"
    }
  },
  "amount": 159600,
  "currency": "AED",
  "payment_type": "Regular",
  "reference": "AE200005095",
  "description": "Payment request from ***",
  "capture": true,
  "capture_on": "2024-04-02T15:01:30Z",
  "customer": {
    "email": "***",
    "name": "***"
  },
  "shipping": {
    "address": {
      "address_line1": "***",
      "address_line2": "",
      "city": "***",
      "state": "***",
      "zip": "00000",
      "country": "AE"
    }
  },
  "3ds": {
    "enabled": true,
    "attempt_n3d": false
  },
  "processing_channel_id": "pc_jot***",
  "success_url": "***/checkout_com\/payment\/verify",
  "failure_url": "***/checkout_com\/payment\/fail",
  "metadata": {
    "methodId": "checkoutcom_card_payment",
    "quoteData": "{\"quote_id\":\"3079662\",\"store_id\":13,\"customer_email\":\"***\"}",
    "udf5": "{\"server_url\":\"***\",\"sdk_data\":\"PHP v8.1.14, SDK v3.0.6\",\"integration_data\":\"Checkout.com Magento 2 Module v5.2.0\",\"platform_data\":\"Magento 2.4.6-p4\"}"
  }
}

And the response:

{
  "request_id": "108aacaa-095b-4679-a7b5-6eedac4bab60",
  "error_type": "processing_error",
  "error_codes": [
    "payment_method_not_supported"
  ]
}

I used the following card details:

5588686116426417
03/30
100

I have tried the visa 3DS enabled test card 4485040371536584 and the standard visa test card 4242424242424242. Both times with the expiry date 03/30 and CVV 100. I receive the same response as above with these cards too.

armando-rodriguez-cko commented 2 weeks ago

Hi @lrotherfield-function this URL is in production, we can verify it, please contact checkout support at support@checkout.com