private AcumaticaPayment RetrievePaymentWithMissingId(ShopifyTransaction transactionRecord) { var acumaticaPayment = transactionRecord.AcumaticaPayment; if (acumaticaPayment.AcumaticaRefNbr == AcumaticaSyncConstants.UnknownRefNbr) { var paymentRef = transactionRecord.ShopifyTransactionId.ToString(); var payments = _paymentClient.RetrievePaymentByPaymentRef(paymentRef); if (payments.Count == 0) { _syncOrderRepository.DeleteErroneousPaymentRecord(transactionRecord.MonsterId); throw new Exception($"Shopify Transaction {transactionRecord.MonsterId} sync to Acumatica Payment false record detected"); } if (payments.Count > 1) { throw new Exception($"Multiple Acumatica Payment records with Payment Ref {paymentRef}"); } var correctedPaymentNbr = payments.First().ReferenceNbr.value; _syncOrderRepository.UpdatePaymentRecordRefNbr(transactionRecord.MonsterId, correctedPaymentNbr); acumaticaPayment.AcumaticaRefNbr = correctedPaymentNbr; } return(acumaticaPayment); }