How to launch IAP of Windows Store in Win10?

I created a game with Cocos Creator 3.6.1, and I tried to support IAP of Windows Store. I used the following code to launch IAP, but got error"Could not create a new view because the main window has not yet been created":

Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([=]() {
        create_task(CurrentApp::RequestProductPurchaseAsync(storeID)).then([=] 
        (PurchaseResults^ result)
        {
              this->OnPurchaseOperationDone(result, storeID, orderID);
              return S_OK;
        });
 }));