当前位置: 首页>>代码示例>>C++>>正文


C++ OT_ME::accept_from_paymentbox方法代码示例

本文整理汇总了C++中OT_ME::accept_from_paymentbox方法的典型用法代码示例。如果您正苦于以下问题:C++ OT_ME::accept_from_paymentbox方法的具体用法?C++ OT_ME::accept_from_paymentbox怎么用?C++ OT_ME::accept_from_paymentbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OT_ME的用法示例。


在下文中一共展示了OT_ME::accept_from_paymentbox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AcceptIncomingInstrument

// ---------------------------------------
// For incoming, pending (not-yet-accepted) instruments.
//
bool MTRecord::AcceptIncomingInstrument(const std::string & str_into_acct)
{
    if (!this->CanAcceptIncoming())
        return false;

    switch (this->GetRecordType())
    {
        // --------------------------------------------
        // Accept from Nym's payments inbox.
        //
        case MTRecord::Instrument:
        {
            if (m_str_server_id.empty() || m_str_nym_id.empty())
            {
                OTLog::vError("%s: Error: missing server id (%s) or nym id (%s)\n",
                              __FUNCTION__, m_str_server_id.c_str(), m_str_nym_id.c_str());
                return false;
            }
            // ------------------------------
            if (0 == m_lTransactionNum)
            {
                OTLog::vError("%s: Error: Transaction number is 0, in payment inbox for server id (%s), nym id (%s)\n",
                              __FUNCTION__, m_str_server_id.c_str(), m_str_nym_id.c_str());
                return false;
            }
            // ------------------------------
            const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id);

            // Open the Nym's payments inbox.
            OTLedger * pInbox = OTAPI_Wrap::OTAPI()->LoadPaymentInbox(theServerID, theNymID);
            OTCleanup<OTLedger> theInboxAngel(pInbox);
            // ------------------------------------------
            if (NULL == pInbox)
            {
                OTLog::vError("%s: Error: Unable to load payment inbox for server id (%s), nym id (%s)\n",
                              __FUNCTION__, m_str_server_id.c_str(), m_str_nym_id.c_str());
                return false;
            }
            // ------------------------------------------
            // Find the payment therein that correlates to this MTRecord.
            //
            int nIndex = pInbox->GetTransactionIndex(m_lTransactionNum);

            if ((-1) == nIndex)
            {
                OTLog::vError("%s: Error: Unable to find transaction %ld in payment inbox for server id (%s), nym id (%s)\n",
                              __FUNCTION__, m_lTransactionNum, m_str_server_id.c_str(), m_str_nym_id.c_str());
                return false;
            }
            // ------------------------------------------
            // Accept it.
            //
            OTString strIndices;
            strIndices.Format("%d", nIndex);
            const std::string str_indices(strIndices.Get());

            OT_ME madeEasy;
            int32_t nReturn = madeEasy.accept_from_paymentbox(str_into_acct, str_indices, "ANY");

            switch (nReturn)
            {
                case 0:
                    OTLog::vOutput(0, "%s: This instrument was expired, so it was moved to the record box.\n", __FUNCTION__);
                    return true;

                case 1: // success
                    break;
                // ----------------------------------
                default:
                    OTLog::vError("%s: Error while trying to accept this instrument.\n", __FUNCTION__);
                    return false;
            } // switch
        } // case: instrument
            break;
        // --------------------------------------------
        default:
            OTLog::vError("%s: Unexpected type: %s\n",
                          __FUNCTION__, this->GetInstrumentType().c_str());
            return false;
    }

    return true;
}
开发者ID:kazcw,项目名称:Moneychanger,代码行数:86,代码来源:MTRecord.cpp


注:本文中的OT_ME::accept_from_paymentbox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。