@@ -378,27 +378,38 @@ class GameTab
378378
379379 if (ImGui::Button (" Refund last purchase" ))
380380 {
381- Json::CharReaderBuilder builder;
382- const std::unique_ptr<Json::CharReader> reader (builder.newCharReader ());
383- JSONCPP_STRING err;
384- Json::Value rootSession;
385- Json::Value rootPurchaseHistory;
386-
387- std::string storeUrl = LCU::Request (" GET" , " https://127.0.0.1/lol-store/v1/getStoreUrl" );
388- storeUrl = storeUrl.erase (0 , 1 ).erase (storeUrl.size () - 1 );
389- std::string session = LCU::Request (" GET" , " https://127.0.0.1/lol-login/v1/session" );
390- if (reader->parse (session.c_str (), session.c_str () + static_cast <int >(session.length ()), &rootSession, &err))
381+ if (MessageBoxA (0 , " Are you sure?" , " Refunding last purchase" , MB_OKCANCEL) == IDOK)
391382 {
392- std::string accountId = rootSession[" accountId" ].asString ();
393- std::string idToken = rootSession[" idToken" ].asString ();
394- std::string authorizationHeader = " Authorization: Bearer " + idToken + " \r\n " +
395- " Accept: application/json" + " \r\n " +
396- " Content-Type: application/json" + " \r\n " ;
397- std::string purchaseHistory = HTTP::Request (" GET" , storeUrl + " /storefront/v3/history/purchase" , " " , authorizationHeader, " " , " " );
398- if (reader->parse (purchaseHistory.c_str (), purchaseHistory.c_str () + static_cast <int >(purchaseHistory.length ()), &rootPurchaseHistory, &err))
383+ Json::CharReaderBuilder builder;
384+ const std::unique_ptr<Json::CharReader> reader (builder.newCharReader ());
385+ JSONCPP_STRING err;
386+ Json::Value rootSession;
387+ Json::Value rootPurchaseHistory;
388+
389+ std::string storeUrl = LCU::Request (" GET" , " https://127.0.0.1/lol-store/v1/getStoreUrl" );
390+ storeUrl = storeUrl.erase (0 , 1 ).erase (storeUrl.size () - 1 );
391+ std::string session = LCU::Request (" GET" , " https://127.0.0.1/lol-login/v1/session" );
392+ if (reader->parse (session.c_str (), session.c_str () + static_cast <int >(session.length ()), &rootSession, &err))
393+ {
394+ std::string accountId = rootSession[" accountId" ].asString ();
395+ std::string idToken = rootSession[" idToken" ].asString ();
396+ std::string authorizationHeader = " Authorization: Bearer " + idToken + " \r\n " +
397+ " Accept: application/json" + " \r\n " +
398+ " Content-Type: application/json" + " \r\n " ;
399+ std::string purchaseHistory = HTTP::Request (" GET" , storeUrl + " /storefront/v3/history/purchase" , " " , authorizationHeader, " " , " " );
400+ if (reader->parse (purchaseHistory.c_str (), purchaseHistory.c_str () + static_cast <int >(purchaseHistory.length ()), &rootPurchaseHistory, &err))
401+ {
402+ std::string transactionId = rootPurchaseHistory[" transactions" ][0 ][" transactionId" ].asString ();
403+ result = HTTP::Request (" POST" , storeUrl + " /storefront/v3/refund" , " {\" accountId\" :" + accountId + " ,\" transactionId\" :\" " + transactionId + " \" ,\" inventoryType\" :\" CHAMPION\" ,\" language\" :\" EN_US\" }" , authorizationHeader, " " , " " );
404+ }
405+ else
406+ {
407+ result = purchaseHistory;
408+ }
409+ }
410+ else
399411 {
400- std::string transactionId = rootPurchaseHistory[" transactions" ][0 ][" transactionId" ].asString ();
401- result = HTTP::Request (" POST" , storeUrl + " /storefront/v3/refund" , " {\" accountId\" :" + accountId + " ,\" transactionId\" :\" " + transactionId + " \" ,\" inventoryType\" :\" CHAMPION\" ,\" language\" :\" EN_US\" }" , authorizationHeader, " " , " " );
412+ result = session;
402413 }
403414 }
404415 }
0 commit comments