Add phone number to makePayment and implement fallback logic for generating transaction IDs in payment scripts.
This commit is contained in:
parent
5d892ba19d
commit
43415e2599
@ -136,7 +136,7 @@ void PayByCardScript::doStart() {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(adbId, ++m_counter));
|
||||
}
|
||||
|
||||
makePayment(device.adbSerial, app.package, app.pinCode, device.screenWidth, device.screenHeight);
|
||||
makePayment(device.adbSerial, app.package, app.pinCode, app.phone, device.screenWidth, device.screenHeight);
|
||||
|
||||
emit finishedWithResult(m_error);
|
||||
}
|
||||
@ -145,6 +145,7 @@ void PayByCardScript::makePayment(
|
||||
const QString &deviceId,
|
||||
const QString &packageName,
|
||||
const QString &pinCode,
|
||||
const QString &bankProfilePhone,
|
||||
const int width,
|
||||
const int height
|
||||
) {
|
||||
@ -346,6 +347,7 @@ void PayByCardScript::makePayment(
|
||||
qDebug() << "[PayByCard] Saved transaction to DB, id:" << txId << "fee:" << fee;
|
||||
|
||||
// Ищем кнопку "Документы" и достаём ID операции
|
||||
QString externalId;
|
||||
Node docBtn = xmlScreenParser.findButtonNode("Документы", false);
|
||||
if (!docBtn.isEmpty() && txId != -1) {
|
||||
qDebug() << "[PayByCard] Tapping 'Документы'...";
|
||||
@ -377,13 +379,7 @@ void PayByCardScript::makePayment(
|
||||
const QString ocrText = recognizeTextFromImage(screenshot);
|
||||
if (!ocrText.isEmpty()) {
|
||||
qDebug() << "[PayByCard] OCR result:\n" << ocrText;
|
||||
const QString externalId = extractTransactionId(ocrText);
|
||||
if (!externalId.isEmpty()) {
|
||||
TransactionDAO::updateBankTrExternalId(txId, externalId);
|
||||
qDebug() << "[PayByCard] Extracted transaction ID:" << externalId;
|
||||
} else {
|
||||
qWarning() << "[PayByCard] Could not extract transaction ID from OCR text";
|
||||
}
|
||||
externalId = extractTransactionId(ocrText);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -394,6 +390,15 @@ void PayByCardScript::makePayment(
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
|
||||
if (externalId.isEmpty() && txId != -1) {
|
||||
externalId = "ozon_" + bankProfilePhone + "_" + QString::number(QDateTime::currentSecsSinceEpoch());
|
||||
qDebug() << "[PayByCard] Generated fallback transaction ID:" << externalId;
|
||||
}
|
||||
if (!externalId.isEmpty() && txId != -1) {
|
||||
TransactionDAO::updateBankTrExternalId(txId, externalId);
|
||||
qDebug() << "[PayByCard] Transaction ID:" << externalId;
|
||||
}
|
||||
|
||||
AdbUtils::goBack(deviceId);
|
||||
QThread::msleep(1000);
|
||||
AdbUtils::goBack(deviceId);
|
||||
|
||||
@ -29,6 +29,7 @@ private:
|
||||
const QString &deviceId,
|
||||
const QString &packageName,
|
||||
const QString &pinCode,
|
||||
const QString &bankProfilePhone,
|
||||
int width,
|
||||
int height
|
||||
);
|
||||
|
||||
@ -137,7 +137,7 @@ void PayByPhoneScript::doStart() {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(adbId, ++m_counter));
|
||||
}
|
||||
|
||||
makePayment(device.adbSerial, app.package, app.pinCode, device.screenWidth, device.screenHeight);
|
||||
makePayment(device.adbSerial, app.package, app.pinCode, app.phone, device.screenWidth, device.screenHeight);
|
||||
|
||||
emit finishedWithResult(m_error);
|
||||
}
|
||||
@ -146,6 +146,7 @@ void PayByPhoneScript::makePayment(
|
||||
const QString &deviceId,
|
||||
const QString &packageName,
|
||||
const QString &pinCode,
|
||||
const QString &bankProfilePhone,
|
||||
const int width,
|
||||
const int height
|
||||
) {
|
||||
@ -464,6 +465,7 @@ void PayByPhoneScript::makePayment(
|
||||
qDebug() << "[PayByPhone] Saved transaction to DB, id:" << txId;
|
||||
|
||||
// Ищем кнопку "Документы" и достаём ID операции
|
||||
QString externalId;
|
||||
Node docBtn = xmlScreenParser.findButtonNode("Документы", false);
|
||||
if (!docBtn.isEmpty() && txId != -1) {
|
||||
qDebug() << "[PayByPhone] Tapping 'Документы'...";
|
||||
@ -495,13 +497,7 @@ void PayByPhoneScript::makePayment(
|
||||
const QString ocrText = recognizeTextFromImage(screenshot);
|
||||
if (!ocrText.isEmpty()) {
|
||||
qDebug() << "[PayByPhone] OCR result:\n" << ocrText;
|
||||
const QString externalId = extractTransactionId(ocrText);
|
||||
if (!externalId.isEmpty()) {
|
||||
TransactionDAO::updateBankTrExternalId(txId, externalId);
|
||||
qDebug() << "[PayByPhone] Extracted transaction ID:" << externalId;
|
||||
} else {
|
||||
qWarning() << "[PayByPhone] Could not extract transaction ID from OCR text";
|
||||
}
|
||||
externalId = extractTransactionId(ocrText);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -512,6 +508,15 @@ void PayByPhoneScript::makePayment(
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
|
||||
if (externalId.isEmpty() && txId != -1) {
|
||||
externalId = "ozon_" + bankProfilePhone + "_" + QString::number(QDateTime::currentSecsSinceEpoch());
|
||||
qDebug() << "[PayByPhone] Generated fallback transaction ID:" << externalId;
|
||||
}
|
||||
if (!externalId.isEmpty() && txId != -1) {
|
||||
TransactionDAO::updateBankTrExternalId(txId, externalId);
|
||||
qDebug() << "[PayByPhone] Transaction ID:" << externalId;
|
||||
}
|
||||
|
||||
AdbUtils::goBack(deviceId);
|
||||
QThread::msleep(1000);
|
||||
AdbUtils::goBack(deviceId);
|
||||
|
||||
@ -31,6 +31,7 @@ private:
|
||||
const QString &deviceId,
|
||||
const QString &packageName,
|
||||
const QString &pinCode,
|
||||
const QString &bankProfilePhone,
|
||||
int width,
|
||||
int height
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user