File tree Expand file tree Collapse file tree 4 files changed +17
-2
lines changed
Telegram/SourceFiles/payments Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -675,6 +675,7 @@ void Form::fillSmartGlocalNativeMethod(QJsonObject object) {
675675 _paymentMethod.native = NativePaymentMethod{
676676 .data = SmartGlocalPaymentMethod{
677677 .publicToken = key,
678+ .tokenizeUrl = value (u" tokenize_url" ).toString (),
678679 },
679680 };
680681 _paymentMethod.ui .native = Ui::NativeMethodDetails{
@@ -1011,6 +1012,7 @@ void Form::validateCard(
10111012 }
10121013 auto configuration = SmartGlocal::PaymentConfiguration{
10131014 .publicToken = method.publicToken ,
1015+ .tokenizeUrl = method.tokenizeUrl ,
10141016 .isTest = _invoice.isTest ,
10151017 };
10161018 _smartglocal = std::make_unique<SmartGlocal::APIClient>(
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ struct StripePaymentMethod {
9595
9696struct SmartGlocalPaymentMethod {
9797 QString publicToken;
98+ QString tokenizeUrl;
9899};
99100
100101struct NativePaymentMethod {
Original file line number Diff line number Diff line change @@ -44,10 +44,21 @@ namespace {
4444 }).toJson (QJsonDocument::Compact);
4545}
4646
47+ [[nodiscard]] QString ComputeApiUrl (PaymentConfiguration configuration) {
48+ const auto url = configuration.tokenizeUrl ;
49+ if (url.startsWith (" https://" )
50+ && url.endsWith (" .smart-glocal.com/cds/v1/tokenize/card" )) {
51+ return url;
52+ }
53+ return QString (" https://%1/%2" )
54+ .arg (APIURLBase (configuration.isTest ))
55+ .arg (TokenEndpoint ());
56+ }
57+
4758} // namespace
4859
4960APIClient::APIClient (PaymentConfiguration configuration)
50- : _apiUrl(" https:// " + APIURLBase (configuration.isTest ))
61+ : _apiUrl(ComputeApiUrl (configuration))
5162, _configuration(configuration) {
5263 _additionalHttpHeaders = {
5364 { " X-PUBLIC-TOKEN" , _configuration.publicToken },
@@ -67,7 +78,7 @@ void APIClient::createTokenWithCard(
6778void APIClient::createTokenWithData (
6879 QByteArray data,
6980 TokenCompletionCallback completion) {
70- const auto url = QUrl (_apiUrl + ' / ' + TokenEndpoint () );
81+ const auto url = QUrl (_apiUrl);
7182 auto request = QNetworkRequest (url);
7283 request.setHeader (
7384 QNetworkRequest::ContentTypeHeader,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ namespace SmartGlocal {
1919
2020struct PaymentConfiguration {
2121 QString publicToken;
22+ QString tokenizeUrl;
2223 bool isTest = false ;
2324};
2425
You can’t perform that action at this time.
0 commit comments