133 #include "../core/stdafx.hpp"
138 #include "../cash/Purse.hpp"
140 #include "../core/recurring/OTPaymentPlan.hpp"
141 #include "../core/script/OTSmartContract.hpp"
142 #include "../core/OTCheque.hpp"
143 #include "../core/OTLog.hpp"
145 #include <irrxml/irrXML.hpp>
173 int32_t nType =
static_cast<int32_t
>(theType);
179 #define OT_NUM_ELEM(blah) (sizeof(blah) / sizeof(*(blah)))
182 return static_cast<OTPayment::paymentType>(i);
205 if (
nullptr == pPurse) {
206 otErr <<
"OTPayment::SetTempValues: Error: Failed instantiating "
207 "OTPayment (purported purse) contents:\n\n" <<
m_strPayment
211 std::unique_ptr<Purse> thePurseAngel(pPurse);
218 if (
nullptr == pTrackable) {
219 otErr <<
"OTPayment::SetTempValues: Error: Failed instantiating "
224 std::unique_ptr<OTTrackable> theTrackableAngel(pTrackable);
234 pCheque =
dynamic_cast<OTCheque*
>(pTrackable);
235 if (
nullptr == pCheque)
236 otErr <<
"OTPayment::SetTempValues: Failure: "
237 "dynamic_cast<OTCheque *>(pTrackable). Contents:\n\n"
247 if (
nullptr == pPaymentPlan)
248 otErr <<
"OTPayment::SetTempValues: Failure: "
249 "dynamic_cast<OTPaymentPlan *>(pTrackable). "
250 "Contents:\n\n" << m_strPayment <<
"\n\n";
259 if (
nullptr == pSmartContract)
260 otErr <<
"OTPayment::SetTempValues: Failure: "
261 "dynamic_cast<OTSmartContract *>(pTrackable). "
262 "Contents:\n\n" << m_strPayment <<
"\n\n";
270 otErr <<
"OTPayment::SetTempValues: Failure: Wrong m_Type. "
271 "Contents:\n\n" << m_strPayment <<
"\n\n";
336 otErr <<
"OTPayment::SetTempValuesFromCheque: Error: Wrong type. "
337 "(Returning false.)\n";
382 otErr <<
"OTPayment::SetTempValuesFromPaymentPlan: Error: Wrong type. "
383 "(Returning false.)\n";
422 otErr << __FUNCTION__ <<
": Error: Wrong type. (Returning false.)\n";
462 otErr <<
"OTPayment::SetTempValuesFromPurse: Error: Wrong type. "
463 "(Returning false.)\n";
474 bool bSuccess =
false;
495 otErr <<
"OTPayment::GetMemo: Bad payment type!\n";
508 bool bSuccess =
false;
526 otErr <<
"OTPayment::GetAmount: Bad payment type!\n";
548 if (
nullptr == pTrackable) {
549 otErr << __FUNCTION__
550 <<
": Failed instantiating OTPayment containing:\n"
554 std::unique_ptr<OTTrackable> theTrackableAngel(pTrackable);
562 if (
nullptr != pPlan) {
566 else if (
nullptr != pSmartContract) {
579 bool bSuccess =
false;
598 otErr <<
"OTPayment::" << __FUNCTION__ <<
": Bad payment type!\n";
623 if (
nullptr == pTrackable) {
624 otErr << __FUNCTION__
625 <<
": Failed instantiating OTPayment containing:\n"
629 std::unique_ptr<OTTrackable> theTrackableAngel(pTrackable);
637 if (
nullptr != pPlan) {
641 else if (
nullptr != pSmartContract) {
654 bool bSuccess =
false;
672 otErr <<
"OTPayment::" << __FUNCTION__ <<
": Bad payment type!\n";
692 if (
nullptr == pTrackable) {
693 otErr << __FUNCTION__
694 <<
": Failed instantiating OTPayment containing:\n"
698 std::unique_ptr<OTTrackable> theTrackableAngel(pTrackable);
706 if (
nullptr != pSmartContract) {
708 if (lOutput > 0)
return true;
711 else if (
nullptr != pPlan) {
713 if (lOutput > 0)
return true;
722 bool bSuccess =
false;
737 otErr << __FUNCTION__ <<
": Bad payment type!\n";
757 if (
nullptr == pTrackable) {
758 otErr << __FUNCTION__
759 <<
": Failed instantiating OTPayment containing:\n"
763 std::unique_ptr<OTTrackable> theTrackableAngel(pTrackable);
771 if (
nullptr != pSmartContract) {
773 if (lOutput > 0)
return true;
776 else if (
nullptr != pPlan) {
778 if (lOutput > 0)
return true;
788 bool bSuccess =
false;
825 otErr << __FUNCTION__ <<
": Bad payment type!\n";
838 bool bSuccess =
false;
860 otErr <<
"OTPayment::GetTransactionNum: Bad payment type!\n";
873 bool bSuccess =
false;
887 otErr <<
"OTPayment::GetValidFrom: Bad payment type!\n";
900 bool bSuccess =
false;
914 otErr <<
"OTPayment::GetValidTo: Bad payment type!\n";
969 bool bSuccess =
false;
986 otErr <<
"OTPayment::GetAssetTypeID: Bad payment type!\n";
999 bool bSuccess =
false;
1013 otErr <<
"OTPayment::GetServerID: Bad payment type!\n";
1029 bool bSuccess =
false;
1038 otErr <<
"OTPayment::GetRemitterUserID: Bad payment type! Expected a "
1039 "voucher cheque.\n";
1056 bool bSuccess =
false;
1065 otErr <<
"OTPayment::GetRemitterAcctID: Bad payment type! Expected a "
1066 "voucher cheque.\n";
1093 bool bSuccess =
false;
1110 otErr <<
"OTPayment::GetSenderUserID: Bad payment type!\n";
1123 bool bSuccess =
false;
1140 otErr <<
"OTPayment::GetSenderAcctID: Bad payment type!\n";
1153 bool bSuccess =
false;
1175 otErr <<
"OTPayment::GetRecipientUserID: Bad payment type!\n";
1195 bool bSuccess =
false;
1218 otErr <<
"OTPayment::GetRecipientAcctID: Bad payment type!\n";
1228 , m_bAreTempValuesSet(false)
1229 , m_bHasRecipient(false)
1230 , m_bHasRemitter(false)
1232 , m_lTransactionNum(0)
1242 , m_bAreTempValuesSet(false)
1243 , m_bHasRecipient(false)
1244 , m_bHasRemitter(false)
1246 , m_lTransactionNum(0)
1271 if (
nullptr != pContract) {
1272 pCheque =
dynamic_cast<OTCheque*
>(pContract);
1274 if (
nullptr == pCheque) {
1275 otErr <<
"OTPayment::Instantiate: Tried to instantiate cheque, "
1279 pContract =
nullptr;
1282 pTrackable = pCheque;
1285 otErr <<
"OTPayment::Instantiate: Tried to instantiate cheque, but "
1286 "factory returned nullptr:\n\n" <<
m_strPayment <<
"\n\n";
1290 pContract = ::InstantiateContract(m_strPayment);
1292 if (
nullptr != pContract) {
1295 if (
nullptr == pPaymentPlan) {
1296 otErr <<
"OTPayment::Instantiate: Tried to instantiate payment "
1297 "plan, but factory returned non-payment-plan:\n\n"
1298 << m_strPayment <<
"\n\n";
1300 pContract =
nullptr;
1303 pTrackable = pPaymentPlan;
1306 otErr <<
"OTPayment::Instantiate: Tried to instantiate payment "
1307 "plan, but factory returned nullptr:\n\n" << m_strPayment
1312 pContract = ::InstantiateContract(m_strPayment);
1314 if (
nullptr != pContract) {
1317 if (
nullptr == pSmartContract) {
1318 otErr << __FUNCTION__
1319 <<
": Tried to instantiate smart contract, but factory "
1320 "returned non-smart-contract:\n\n" << m_strPayment
1323 pContract =
nullptr;
1326 pTrackable = pSmartContract;
1329 otErr <<
"OTPayment::Instantiate: Tried to instantiate smart "
1330 "contract, but factory returned nullptr:\n\n"
1331 << m_strPayment <<
"\n\n";
1334 otErr <<
"OTPayment::Instantiate: ERROR: Tried to instantiate purse, "
1335 "but should have called OTPayment::InstantiatePurse.\n";
1338 otErr <<
"OTPayment::Instantiate: ERROR: Tried to instantiate payment "
1339 "object, but had a bad type. Contents:\n\n" << m_strPayment
1365 otErr <<
"OTPayment::InstantiatePurse: Failure: This payment object "
1366 "does NOT contain a purse. "
1406 otErr <<
"OTPayment::InstantiatePurse: WARNING: Failed setting the "
1407 "payment string based on "
1408 "what was passed in:\n\n" << strPayment <<
"\n\n";
1410 otErr <<
"OTPayment::InstantiatePurse: WARNING: No purse was found in "
1412 "payment string:\n\n" << strPayment <<
"\n\n";
1458 if (!strPayment.
Exists())
return false;
1465 otErr << __FUNCTION__ <<
": Input string apparently was encoded and "
1466 "then failed decoding. Contents: \n"
1467 << strPayment <<
"\n";
1475 if (strContract.
Contains(
"-----BEGIN SIGNED CHEQUE-----"))
1477 else if (strContract.
Contains(
"-----BEGIN SIGNED VOUCHER-----"))
1479 else if (strContract.
Contains(
"-----BEGIN SIGNED INVOICE-----"))
1482 else if (strContract.
Contains(
"-----BEGIN SIGNED PAYMENT PLAN-----"))
1484 else if (strContract.
Contains(
"-----BEGIN SIGNED SMARTCONTRACT-----"))
1487 else if (strContract.
Contains(
"-----BEGIN SIGNED PURSE-----"))
1492 otErr << __FUNCTION__
1493 <<
": Failure: Unable to determine payment type, from input:\n\n"
1494 << strContract <<
"\n\n";
1568 " type=\"%s\">\n\n",
1574 if (ascContents.
Exists())
1584 const OTString strNodeName(xml->getNodeName());
1586 if (strNodeName.Compare(
"payment")) {
1589 const OTString strPaymentType = xml->getAttributeValue(
"type");
1591 if (strPaymentType.
Exists())
1597 <<
"\n----------\n";
1601 else if (strNodeName.Compare(
"contents")) {
1606 otErr <<
"OTPayment::ProcessXMLNode: ERROR: \"contents\" field "
1607 "without a value, OR error setting that "
1608 "value onto this object. Raw:\n\n" << strContents
EXPORT bool GetAmount(int64_t &lOutput) const
virtual void GetAllTransactionNumbers(OTNumList &numlistOutput) const
OTLOG_IMPORT OTLogStream otLog4
EXPORT void InitPayment()
EXPORT bool GetClosingNum(int64_t &lOutput, const OTIdentifier &theAcctID) const
EXPORT bool GetServerID(OTIdentifier &theOutput) const
#define OT_NUM_ELEM(blah)
EXPORT bool GetRemitterAcctID(OTIdentifier &theOutput) const
EXPORT bool IsNymIDIncluded() const
EXPORT bool HasTransactionNum(const int64_t &lInput) const
EXPORT bool GetValidFrom(time64_t &tOutput) const
const OTIdentifier & GetSenderUserID() const
EXPORT Purse * InstantiatePurse() const
time64_t GetValidTo() const
OTIdentifier m_RecipientUserID
int64_t GetTransactionNum() const
const int64_t & GetAmount() const
EXPORT bool SetTempValuesFromPaymentPlan(const OTPaymentPlan &theInput)
const OTIdentifier & GetAssetID() const
EXPORT bool GetAllTransactionNumbers(OTNumList &numlistOutput) const
const int64_t & GetInitialPaymentAmount() const
EXPORT bool GetTransactionNum(int64_t &lOutput) const
OTIdentifier m_RecipientAcctID
EXPORT bool SetPayment(const OTString &strPayment)
EXPORT OTTrackable * Instantiate() const
virtual void UpdateContents()
OTIdentifier m_RemitterAcctID
const OTIdentifier & GetAssetID() const
static EXPORT Purse * PurseFactory(OTString strInput)
const OTIdentifier & GetRemitterAcctID() const
EXPORT bool GetAssetTypeID(OTIdentifier &theOutput) const
EXPORT bool VerifyCurrentDate(bool &bVerified)
bool HasRecipient() const
virtual int64_t GetClosingNumber(const OTIdentifier &theAcctID) const
EXPORT void Concatenate(const char *arg,...)
EXPORT bool GetOpeningNum(int64_t &lOutput, const OTIdentifier &theNymID) const
const OTString & GetMemo() const
EXPORT bool DecodeIfArmored(bool escapedIsAllowed=true)
EXPORT bool Exists() const
virtual EXPORT ~OTPayment()
int64_t m_lTransactionNum
static EXPORT const char * _GetTypeString(paymentType theType)
EXPORT bool GetRecipientAcctID(OTIdentifier &theOutput) const
const OTIdentifier & GetServerID() const
time64_t GetValidFrom() const
EXPORT void Release_Payment()
EXPORT bool Compare(const char *compare) const
OTIdentifier m_AssetTypeID
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
time64_t OTTimeGetCurrentTime()
EXPORT bool GetSenderUserID(OTIdentifier &theOutput) const
EXPORT bool GetMemo(OTString &strOutput) const
char const *const __TypeStrings[]
OTIdentifier m_RemitterUserID
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
EXPORT bool GetSenderUserIDForDisplay(OTIdentifier &theOutput) const
int64_t GetTotalValue() const
virtual bool HasTransactionNum(const int64_t &lInput) const
OTIdentifier m_SenderAcctID
OTString m_strContractType
const OTString & GetConsideration() const
const OTIdentifier & GetRemitterUserID() const
EXPORT time64_t GetLatestValidFrom() const
EXPORT bool GetSenderAcctID(OTIdentifier &theOutput) const
OTStringXML m_xmlUnsigned
virtual bool HasTransactionNum(const int64_t &lInput) const
EXPORT bool SetTempValues()
EXPORT const char * GetTypeString() const
EXPORT const char * Get() const
EXPORT bool GetSenderAcctIDForDisplay(OTIdentifier &theOutput) const
OTLOG_IMPORT OTLogStream otErr
virtual EXPORT int64_t GetOpeningNumber(const OTIdentifier &theNymID) const
EXPORT time64_t GetEarliestValidTo() const
EXPORT bool GetValidTo(time64_t &tOutput) const
virtual EXPORT void Release()
EXPORT bool SetTempValuesFromSmartContract(const OTSmartContract &theInput)
virtual EXPORT void Release()
static EXPORT paymentType GetTypeFromString(const OTString &strType)
EXPORT bool IsExpired(bool &bExpired)
virtual int64_t GetOpeningNumber(const OTIdentifier &theNymID) const
const OTIdentifier & GetRecipientUserID() const
const OTIdentifier & GetSenderAcctID() const
EXPORT bool IsVoucher() const
EXPORT bool Contains(const char *compare) const
virtual void GetAllTransactionNumbers(OTNumList &numlistOutput) const
const OTIdentifier & GetRecipientAcctID() const
virtual EXPORT int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
virtual EXPORT void Release()
EXPORT bool GetNymID(OTIdentifier &theOutput) const
EXPORT paymentType GetType() const
const OTIdentifier & GetRecipientUserID() const
virtual EXPORT bool SaveContractWallet(std::ofstream &ofs) const
EXPORT bool GetRecipientUserID(OTIdentifier &theOutput) const
EXPORT bool GetRemitterUserID(OTIdentifier &theOutput) const
virtual EXPORT void Release()
EXPORT bool SetTempValuesFromPurse(const Purse &theInput)
virtual int64_t GetClosingNumber(const OTIdentifier &theAcctID) const
OTIdentifier m_SenderUserID
EXPORT bool SetTempValuesFromCheque(const OTCheque &theInput)
const OTIdentifier & GetServerID() const