Closed mathmul closed 3 years ago
Hi @mathmul – thanks for the report. ~You are right, setting the language code is currently not implemented in this library. A pull request to do so would be welcome.~
The language code is supported. See https://github.com/Ticketpark/SaferpayJsonApi/issues/50#issuecomment-897380588
Well that would be a first for me. Such a noob, I know. I am trying though..
Just added
/**
* @var string|null
* @SerializedName("LanguageCode")
*/
private $languageCode;
// ...
public function getLanguageCode(): ?string
{
return $this->languageCode;
}
public function setLanguageCode(?string $languageCode): self
{
$this->languageCode = $languageCode;
return $this;
}
to InitializeRequest.php, but I've no idea how to proceed so it will actually be sent in the Request.
But if someone would guide me through, I'd learn a lot faster and be very grateful for it :) Google here I come!
Great!
The @SerializedName
annotation should actually take care of sending it to the request. I suppose, your code should already work. If not, still submit it as a pr and we can debug together.
Alright alright alright :)
PR was easier than expected!
Hope it went through.
EDIT: Ugh... Scrutinizer sure has a lot 👎 to say about it ':)
As noticed over in #51, the behaviour is actually already implemented in the library. Setting the languageCode
is part of the Payer
container and can be used like this:
$initializeRequest = new InitializeRequest(
$requestConfig,
$terminalId,
$payment,
$returnUrls
);
$payer = new Container\Payer();
$payer->setLanguageCode('fr');
$initializeRequest->setPayer($payer);
Works great!
The story
I tried this package and everything works great. After Initialization I get a Response with a Redirect URL. Redirecting to that URL immediately re-redirects again (both on Saferpay's domain) and on that second site you may choose language via menu. The language is changed by means of a GET query parameter
VTLanguage={LanguageCode}
. I tried appending that to the Redirect URL given by Initialization Response, but to no avail. I then contacted Saferpay Integration Support and they tell me:How to reproduce
Trying the following snippet
results in Fatal Error: Method setLanguageCode() not found.
Expected behaviour
No error.
$initializeRequest
should be an object of classInitializeRequest
with the appropriate language code set for the Redirect URL.Note
If language code is not set, Saferpay determines language from browser agent's language preference list, so this issue is not that urgent. But let's say a client has a language preference of Slovene, but prefers to browse the e-commerce website in English, we can agree that they would prefer to stay with the English language when moved to Saferpay's domain.
Note 2
In Integration Support's email the corresponded also quoted a list of supported language codes: