public static string GetEnumDescription(EPaymentStatus value) { var fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) { return(attributes[0].Description); } else { return(value.ToString()); } }
public void ChangeOrderStatus(EPaymentStatus status) { PaymentStatus = status; }
public static string ToString(EPaymentStatus eEnum) { return(Enum.GetName(typeof(EPaymentStatus), eEnum)); }
/// <summary> /// Kontrola stavu platby proti internim udajum objednavky /// /// - verifikace podpisu /// - pokud nesouhlasi udaje, tak se vyvola GopayException /// </summary> /// /// <param name="paymentStatus">vysledek volani paymentStatus</param> /// <param name="sessionState">ocekavany stav paymentSession (WAITING, PAYMENT_DONE)</param> /// <param name="gopayId">identifikator prijemce prideleny GoPay</param> /// <param name="OrderNumber">identifikace akt. objednavky u prijemce</param> /// <param name="totalPriceInCents">cena objednavky v halerich</param> /// <param name="currency">identifikator meny platby</param> /// <param name="productName">nazev objednavky / zbozi</param> /// <param name="secureKey">kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace</param> /// /// <returns>True</returns> public static bool CheckPaymentStatus( EPaymentStatus paymentStatus, String sessionState, long gopayId, string orderNumber, long totalPriceInCents, string currency, string productName, string secureKey) { if (paymentStatus != null) { if (paymentStatus.result != GopayHelper.CALL_COMPLETED) { throw new GopayException(GopayException.Reason.INVALID_CALL_STATE_STATE); } if ( paymentStatus.sessionState != sessionState) { throw new GopayException(GopayException.Reason.INVALID_SESSION_STATE); } if (paymentStatus.orderNumber != orderNumber) { throw new GopayException(GopayException.Reason.INVALID_ON); } if (paymentStatus.productName != productName) { throw new GopayException(GopayException.Reason.INVALID_PN); } if (paymentStatus.targetGoId != gopayId) { throw new GopayException(GopayException.Reason.INVALID_GOID); } if (paymentStatus.totalPrice != totalPriceInCents) { throw new GopayException(GopayException.Reason.INVALID_PRICE); } if (paymentStatus.currency != currency) { throw new GopayException(GopayException.Reason.INVALID_CURRENCY); } } else { throw new GopayException(GopayException.Reason.NO_PAYMENT_STATUS); } /* * Kontrola podpisu objednavky */ string hashedSignature = GopayHelper.Hash( GopayHelper.ConcatPaymentStatus( (long)paymentStatus.targetGoId, paymentStatus.productName, (long)paymentStatus.totalPrice, paymentStatus.currency, paymentStatus.orderNumber, paymentStatus.recurrentPayment, paymentStatus.parentPaymentSessionId, paymentStatus.preAuthorization, paymentStatus.result, paymentStatus.sessionState, paymentStatus.sessionSubState, paymentStatus.paymentChannel, secureKey)); string decryptedHash = GopayHelper.Decrypt(paymentStatus.encryptedSignature, secureKey); if (hashedSignature != decryptedHash) { throw new GopayException(GopayException.Reason.INVALID_STATUS_SIGNATURE); } return true; }
/// <summary> /// Kontrola stavu platby proti internim udajum objednavky /// /// - verifikace podpisu /// - pokud nesouhlasi udaje, tak se vyvola GopayException /// </summary> /// /// <param name="paymentStatus">vysledek volani paymentStatus</param> /// <param name="sessionState">ocekavany stav paymentSession (WAITING, PAYMENT_DONE)</param> /// <param name="gopayId">identifikator prijemce prideleny GoPay</param> /// <param name="OrderNumber">identifikace akt. objednavky u prijemce</param> /// <param name="totalPriceInCents">cena objednavky v halerich</param> /// <param name="currency">identifikator meny platby</param> /// <param name="productName">nazev objednavky / zbozi</param> /// <param name="secureKey">kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace</param> /// /// <returns>True</returns> public static bool CheckPaymentStatus( EPaymentStatus paymentStatus, String sessionState, long gopayId, string orderNumber, long totalPriceInCents, string currency, string productName, string secureKey) { if (paymentStatus != null) { if (paymentStatus.result != GopayHelper.CALL_COMPLETED) { throw new GopayException(GopayException.Reason.INVALID_CALL_STATE_STATE); } if (paymentStatus.sessionState != sessionState) { throw new GopayException(GopayException.Reason.INVALID_SESSION_STATE); } if (paymentStatus.orderNumber != orderNumber) { throw new GopayException(GopayException.Reason.INVALID_ON); } if (paymentStatus.productName != productName) { throw new GopayException(GopayException.Reason.INVALID_PN); } if (paymentStatus.targetGoId != gopayId) { throw new GopayException(GopayException.Reason.INVALID_GOID); } if (paymentStatus.totalPrice != totalPriceInCents) { throw new GopayException(GopayException.Reason.INVALID_PRICE); } if (paymentStatus.currency != currency) { throw new GopayException(GopayException.Reason.INVALID_CURRENCY); } } else { throw new GopayException(GopayException.Reason.NO_PAYMENT_STATUS); } /* * Kontrola podpisu objednavky */ string hashedSignature = GopayHelper.Hash( GopayHelper.ConcatPaymentStatus( (long)paymentStatus.targetGoId, paymentStatus.productName, (long)paymentStatus.totalPrice, paymentStatus.currency, paymentStatus.orderNumber, paymentStatus.recurrentPayment, paymentStatus.parentPaymentSessionId, paymentStatus.preAuthorization, paymentStatus.result, paymentStatus.sessionState, paymentStatus.sessionSubState, paymentStatus.paymentChannel, secureKey)); string decryptedHash = GopayHelper.Decrypt(paymentStatus.encryptedSignature, secureKey); if (hashedSignature != decryptedHash) { throw new GopayException(GopayException.Reason.INVALID_STATUS_SIGNATURE); } return(true); }