Ingenico-ePayments / connect-sdk-php

Ingenico Connect PHP Server SDK
https://docs.connect.worldline-solutions.com/documentation/sdk/server/php/
MIT License
39 stars 16 forks source link

Hosted Checkout redirectUrl results in connection timeout #9

Closed internetztube closed 6 years ago

internetztube commented 6 years ago

I'm currently working on a very basic hosted checkout. The creation of the redirect url works just fine. The problem is, that the web server behind that redirect url does not respond in time. I'm getting a connection timeout.

I think that the problem is probably not due to my code, nevertheless here is the script.

<?php

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

use Ingenico\Connect\Sdk\Domain\Hostedcheckout\Definitions\HostedCheckoutSpecificInput;
use Ingenico\Connect\Sdk\Domain\Definitions\AmountOfMoney;
use Ingenico\Connect\Sdk\Domain\Definitions\Address;
use Ingenico\Connect\Sdk\Domain\Payment\Definitions\Customer;
use Ingenico\Connect\Sdk\Domain\Payment\Definitions\Order;
use Ingenico\Connect\Sdk\Domain\Hostedcheckout\CreateHostedCheckoutRequest;
use Ingenico\Connect\Sdk\CommunicatorConfiguration;
use Ingenico\Connect\Sdk\DefaultConnection;
use Ingenico\Connect\Sdk\Communicator;
use Ingenico\Connect\Sdk\Client;

$apiKeyId = "{{ apikey }}";
$apiSecret = "{{ api secret }}";
$baseUrl = "https://eu.sandbox.api-ingenico.com";

$communicatorConfiguration = new CommunicatorConfiguration($apiKeyId, $apiSecret, $baseUrl, 'Integrator');
$connection = new DefaultConnection();
$communicator = new Communicator($connection, $communicatorConfiguration);

$client = new Client($communicator);

$hostedCheckoutSpecificInput = new HostedCheckoutSpecificInput();
$hostedCheckoutSpecificInput->locale = "en_GB";
$hostedCheckoutSpecificInput->variant = "testVariant";

$amountOfMoney = new AmountOfMoney();
$amountOfMoney->amount = 2345;
$amountOfMoney->currencyCode = "USD";

$billingAddress = new Address();
$billingAddress->countryCode = "US";

$customer = new Customer();
$customer->billingAddress = $billingAddress;
$customer->merchantCustomerId = 234234;

$order = new Order();
$order->amountOfMoney = $amountOfMoney;
$order->customer = $customer;

$body = new CreateHostedCheckoutRequest();
$body->hostedCheckoutSpecificInput = $hostedCheckoutSpecificInput;
$body->order = $order;

/** @var CreateHostedCheckoutRequest $response */
$response = $client->merchant({{ merchantId }})->hostedcheckouts()->create($body);

$foo = $response;
print_r($foo);

Response:

Ingenico\Connect\Sdk\Domain\Hostedcheckout\CreateHostedCheckoutResponse Object
(
    [RETURNMAC] => hash1
    [hostedCheckoutId] => hash2
    [invalidTokens] => 
    [partialRedirectUrl] => pay1.sandbox.secured-by-ingenico.com/checkout/hash3:hash2:hash4?requestToken=hash5
)
bildschirmfoto 2018-05-02 um 10 54 26 bildschirmfoto 2018-05-02 um 10 54 24
rob-spoor commented 6 years ago

It's not your code, it appears to be an issue with the infrastructure. I've escalated this to the correct people.

rob-spoor commented 6 years ago

We think that you forgot to add the https:// prefix and your subdomain. Can you make sure you add these before redirecting? Remember that the response gives a partial redirect URL, you must add https:// and your own subdomain yourself.

internetztube commented 6 years ago

Well ...

bildschirmfoto 2018-05-02 um 14 05 16
ronaldmiddelkoop commented 6 years ago

Hi internetztube, looks like you've added https, but not your merchant's subdomain. You can request your own subdomain using the configuration center, but you can also always use payment.

So, your URL would be https://payment.pay1.sandbox.secured-by-ingenico.com/checkout/...

falloutxxx2 commented 5 years ago

https://+Subdomains+partialRedirectUrl

I also met this problem, I really want to swear.(this way is really easy to confuse)