diff --git a/GraftMobileClient/core/api/graftwallethandler.h b/GraftMobileClient/core/api/graftwallethandler.h index 6a27641c..b67f5ca4 100644 --- a/GraftMobileClient/core/api/graftwallethandler.h +++ b/GraftMobileClient/core/api/graftwallethandler.h @@ -18,9 +18,9 @@ public slots: signals: void saleDetailsReceived(int result, const QString &details); - void rejectPayReceived(int result); void payReceived(int result); - void payStatusReceived(int result, int status); + void rejectPayReceived(bool result); + void payStatusReceived(bool result); }; #endif // GRAFTWALLETHANDLER_H diff --git a/GraftMobileClient/core/api/v1/graftwallethandlerv1.cpp b/GraftMobileClient/core/api/v1/graftwallethandlerv1.cpp index a1e3f94d..ec426c20 100644 --- a/GraftMobileClient/core/api/v1/graftwallethandlerv1.cpp +++ b/GraftMobileClient/core/api/v1/graftwallethandlerv1.cpp @@ -6,6 +6,7 @@ GraftWalletHandlerV1::GraftWalletHandlerV1(const QString &dapiVersion, const QStringList addresses, QObject *parent) : GraftWalletHandler(parent) + ,mBlockNumber(0) { mApi = new GraftWalletAPIv1(addresses, dapiVersion, this); connect(mApi, &GraftWalletAPIv1::createAccountReceived, @@ -21,10 +22,10 @@ GraftWalletHandlerV1::GraftWalletHandlerV1(const QString &dapiVersion, const QSt connect(mApi, &GraftWalletAPIv1::getPOSDataReceived, this, &GraftWalletHandlerV1::saleDetailsReceived); connect(mApi, &GraftWalletAPIv1::rejectPayReceived, - this, &GraftWalletHandlerV1::rejectPayReceived); + this, &GraftWalletHandlerV1::receiveRejectPay); connect(mApi, &GraftWalletAPIv1::payReceived, this, &GraftWalletHandlerV1::payReceived); connect(mApi, &GraftWalletAPIv1::getPayStatusReceived, - this, &GraftWalletHandlerV1::payStatusReceived); + this, &GraftWalletHandlerV1::receivePayStatus); connect(mApi, &GraftWalletAPIv1::error, this, &GraftWalletHandlerV1::errorReceived); } @@ -130,6 +131,8 @@ void GraftWalletHandlerV1::pay(const QString &pid, const QString &address, doubl { if (mApi) { + mLastPID = pid; + mBlockNumber = blockNumber; mApi->pay(pid, address, amount, blockNumber); } } @@ -143,6 +146,37 @@ void GraftWalletHandlerV1::payStatus(const QString &pid, int blockNumber) } } +void GraftWalletHandlerV1::receiveRejectPay(int result) +{ + emit rejectPayReceived(result == 0); +} + +void GraftWalletHandlerV1::receivePayStatus(int result, int status) +{ + if (result == 0) + { + switch (status) { + case GraftWalletAPIv1::StatusProcessing: + payStatus(mLastPID, mBlockNumber); + break; + case GraftWalletAPIv1::StatusApproved: + emit payStatusReceived(true); + break; + case GraftWalletAPIv1::StatusNone: + case GraftWalletAPIv1::StatusFailed: + case GraftWalletAPIv1::StatusPOSRejected: + case GraftWalletAPIv1::StatusWalletRejected: + default: + emit payStatusReceived(false); + break; + } + } + else + { + emit payStatusReceived(false); + } +} + void GraftWalletHandlerV1::receiveBalance(double balance, double unlockedBalance) { QTimer::singleShot(20000, this, &GraftWalletHandlerV1::updateBalance); diff --git a/GraftMobileClient/core/api/v1/graftwallethandlerv1.h b/GraftMobileClient/core/api/v1/graftwallethandlerv1.h index 1ea9ec28..4f5a642c 100644 --- a/GraftMobileClient/core/api/v1/graftwallethandlerv1.h +++ b/GraftMobileClient/core/api/v1/graftwallethandlerv1.h @@ -34,10 +34,14 @@ public slots: void payStatus(const QString &pid, int blockNumber) override; private slots: + void receiveRejectPay(int result); + void receivePayStatus(int result, int status); void receiveBalance(double balance, double unlockedBalance); private: GraftWalletAPIv1 *mApi; + QString mLastPID; + int mBlockNumber; }; #endif // GRAFTWALLETHANDLERV1_H diff --git a/GraftMobileClient/core/api/v2/graftwallethandlerv2.cpp b/GraftMobileClient/core/api/v2/graftwallethandlerv2.cpp index 680ae772..f8925bc1 100644 --- a/GraftMobileClient/core/api/v2/graftwallethandlerv2.cpp +++ b/GraftMobileClient/core/api/v2/graftwallethandlerv2.cpp @@ -11,7 +11,7 @@ GraftWalletHandlerV2::GraftWalletHandlerV2(const QString &dapiVersion, const QSt connect(mApi, &GraftWalletAPIv2::saleDetailsReceived, this, &GraftWalletHandlerV2::receiveSaleDetails); connect(mApi, &GraftWalletAPIv2::rejectPayReceived, - this, &GraftWalletHandlerV2::rejectPayReceived); + this, &GraftWalletHandlerV2::receiveRejectPay); connect(mApi, &GraftWalletAPIv2::payReceived, this, &GraftWalletHandlerV2::payReceived); connect(mApi, &GraftWalletAPIv2::payStatusReceived, this, &GraftWalletHandlerV2::receivePayStatus); @@ -228,6 +228,11 @@ void GraftWalletHandlerV2::sendPay(bool result) } +void GraftWalletHandlerV2::receiveRejectPay(int result) +{ + emit rejectPayReceived(result == 0); +} + void GraftWalletHandlerV2::receivePayStatus(int status) { switch (status) { @@ -261,5 +266,5 @@ void GraftWalletHandlerV2::processPayResult(bool result) mLastPID.clear(); mBlockNumber = 0; } - emit payStatusReceived(0, result); + emit payStatusReceived(result); } diff --git a/GraftMobileClient/core/api/v2/graftwallethandlerv2.h b/GraftMobileClient/core/api/v2/graftwallethandlerv2.h index 91388cd3..ef31531e 100644 --- a/GraftMobileClient/core/api/v2/graftwallethandlerv2.h +++ b/GraftMobileClient/core/api/v2/graftwallethandlerv2.h @@ -43,6 +43,7 @@ private slots: void receiveSaleDetails(const QVector> &authSample, const QString &saleDetails); void sendPay(bool result); + void receiveRejectPay(int result); void receivePayStatus(int status); void processPayResult(bool result); diff --git a/GraftMobileClient/core/graftwalletclient.cpp b/GraftMobileClient/core/graftwalletclient.cpp index 8eaed0d9..870e98b8 100644 --- a/GraftMobileClient/core/graftwalletclient.cpp +++ b/GraftMobileClient/core/graftwalletclient.cpp @@ -84,11 +84,6 @@ void GraftWalletClient::receiveSaleDetails(int result, const QString &payDetails emit saleDetailsReceived(isStatusOk); } -void GraftWalletClient::receiveRejectPay(int result) -{ - emit rejectPayReceived(result == 0); -} - void GraftWalletClient::receivePay(int result) { const bool isStatusOk = (result == 0); @@ -99,32 +94,6 @@ void GraftWalletClient::receivePay(int result) } } -void GraftWalletClient::receivePayStatus(int result, int status) -{ - if (result == 0) - { - switch (status) { - case GraftWalletAPIv1::StatusProcessing: - payStatus(); - break; - case GraftWalletAPIv1::StatusApproved: - emit payStatusReceived(true); - break; - case GraftWalletAPIv1::StatusNone: - case GraftWalletAPIv1::StatusFailed: - case GraftWalletAPIv1::StatusPOSRejected: - case GraftWalletAPIv1::StatusWalletRejected: - default: - emit payStatusReceived(false); - break; - } - } - else - { - emit payStatusReceived(false); - } -} - void GraftWalletClient::changeGraftHandler() { if (mClientHandler) @@ -150,7 +119,7 @@ void GraftWalletClient::changeGraftHandler() connect(mClientHandler, &GraftWalletHandler::saleDetailsReceived, this, &GraftWalletClient::receiveSaleDetails); connect(mClientHandler, &GraftWalletHandler::rejectPayReceived, - this, &GraftWalletClient::receiveRejectPay); + this, &GraftWalletClient::rejectPayReceived); connect(mClientHandler, &GraftWalletHandler::payStatusReceived, this, &GraftWalletClient::payStatusReceived); connect(mClientHandler, &GraftWalletHandler::errorReceived, diff --git a/GraftMobileClient/core/graftwalletclient.h b/GraftMobileClient/core/graftwalletclient.h index 11f4f79a..6e5291d4 100644 --- a/GraftMobileClient/core/graftwalletclient.h +++ b/GraftMobileClient/core/graftwalletclient.h @@ -29,9 +29,7 @@ public slots: private slots: void receiveSaleDetails(int result, const QString &payDetails); - void receiveRejectPay(int result); void receivePay(int result); - void receivePayStatus(int result, int status); private: void changeGraftHandler() override;