/// <summary> /// Kontrola stavu platby eshopu /// - verifikace parametru z redirectu /// - kontrola stavu platby /// - pokud nesouhlasi udaje vyhazuje GopayException /// - pri chybe komunikace s WS vyhazuje GopayException /// </summary> /// /// <param name="paymentSessionId">identifikator platby </param> /// <param name="targetGoId">identifikator prijemnce - GoId</param> /// <param name="orderNumber">identifikace akt. objednavky</param> /// <param name="totalPriceInCents">celkova cena v halerich</param> /// <param name="currency">mena, ve ktere platba probiha</param> /// <param name="productName">popis objednavky zobrazujici se na platebni brane</param> /// <param name="secureKey">kryptovaci klic pridelene GoPay</param> /// /// <returns>callbackResult</returns> /// callbackResult.sessionState - stav platby /// callbackResult.sessionSubState - detailnejsi popis stavu platby public static CallbackResult IsPaymentDone( long paymentSessionId, long targetGoId, string orderNumber, long totalPriceInCents, string currency, string productName, string secureKey) { // Inicializace providera pro WS AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws); EPaymentStatus status; // Sestaveni dotazu na stav platby string sessionEncryptedSignature = GopayHelper.Encrypt( GopayHelper.Hash( GopayHelper.ConcatPaymentSession( targetGoId, paymentSessionId, secureKey) ), secureKey); EPaymentSessionInfo paymentSessionInfo = new EPaymentSessionInfo(); paymentSessionInfo.targetGoId = targetGoId; paymentSessionInfo.paymentSessionId = paymentSessionId; paymentSessionInfo.encryptedSignature = sessionEncryptedSignature; CallbackResult callbackResult = new CallbackResult(); try { /* * Kontrola stavu platby na strane GoPay prostrednictvim WS */ status = provider.paymentStatus(paymentSessionInfo); callbackResult.sessionState = status.sessionState; callbackResult.sessionSubState = status.sessionSubState; /* * Kontrola zaplacenosti objednavky, verifikace parametru objednavky */ if (status.result != GopayHelper.CALL_COMPLETED) { throw new GopayException("Payment Status Call failed: " + status.resultDescription); } if (callbackResult.sessionState != GopayHelper.SessionState.PAYMENT_METHOD_CHOSEN.ToString() && callbackResult.sessionState != GopayHelper.SessionState.CREATED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.PAID.ToString() && callbackResult.sessionState != GopayHelper.SessionState.AUTHORIZED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.CANCELED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.TIMEOUTED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.REFUNDED.ToString() ) { throw new GopayException("Bad Payment Session State: " + callbackResult.sessionState); } GopayHelper.CheckPaymentStatus( status, callbackResult.sessionState, targetGoId, orderNumber, totalPriceInCents, currency, productName, secureKey); return callbackResult; } catch (Exception ex1) { callbackResult.sessionState = GopayHelper.SessionState.FAILED.ToString(); } finally { provider.Dispose(); } return callbackResult; }
/// <summary> /// Kontrola stavu platby eshopu /// - verifikace parametru z redirectu /// - kontrola stavu platby /// - pokud nesouhlasi udaje vyhazuje GopayException /// - pri chybe komunikace s WS vyhazuje GopayException /// </summary> /// /// <param name="paymentSessionId">identifikator platby </param> /// <param name="targetGoId">identifikator prijemnce - GoId</param> /// <param name="orderNumber">identifikace akt. objednavky</param> /// <param name="totalPriceInCents">celkova cena v halerich</param> /// <param name="currency">mena, ve ktere platba probiha</param> /// <param name="productName">popis objednavky zobrazujici se na platebni brane</param> /// <param name="secureKey">kryptovaci klic pridelene GoPay</param> /// /// <returns>callbackResult</returns> /// callbackResult.sessionState - stav platby /// callbackResult.sessionSubState - detailnejsi popis stavu platby public static CallbackResult IsPaymentDone( long paymentSessionId, long targetGoId, string orderNumber, long totalPriceInCents, string currency, string productName, string secureKey) { // Inicializace providera pro WS AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws); EPaymentStatus status; // Sestaveni dotazu na stav platby string sessionEncryptedSignature = GopayHelper.Encrypt( GopayHelper.Hash( GopayHelper.ConcatPaymentSession( targetGoId, paymentSessionId, secureKey) ), secureKey); EPaymentSessionInfo paymentSessionInfo = new EPaymentSessionInfo(); paymentSessionInfo.targetGoId = targetGoId; paymentSessionInfo.paymentSessionId = paymentSessionId; paymentSessionInfo.encryptedSignature = sessionEncryptedSignature; CallbackResult callbackResult = new CallbackResult(); try { /* * Kontrola stavu platby na strane GoPay prostrednictvim WS */ status = provider.paymentStatus(paymentSessionInfo); callbackResult.sessionState = status.sessionState; callbackResult.sessionSubState = status.sessionSubState; /* * Kontrola zaplacenosti objednavky, verifikace parametru objednavky */ if (status.result != GopayHelper.CALL_COMPLETED) { throw new GopayException("Payment Status Call failed: " + status.resultDescription); } if (callbackResult.sessionState != GopayHelper.SessionState.PAYMENT_METHOD_CHOSEN.ToString() && callbackResult.sessionState != GopayHelper.SessionState.CREATED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.PAID.ToString() && callbackResult.sessionState != GopayHelper.SessionState.AUTHORIZED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.CANCELED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.TIMEOUTED.ToString() && callbackResult.sessionState != GopayHelper.SessionState.REFUNDED.ToString() ) { throw new GopayException("Bad Payment Session State: " + callbackResult.sessionState); } GopayHelper.CheckPaymentStatus( status, callbackResult.sessionState, targetGoId, orderNumber, totalPriceInCents, currency, productName, secureKey); return(callbackResult); } catch (Exception ex1) { callbackResult.sessionState = GopayHelper.SessionState.FAILED.ToString(); } finally { provider.Dispose(); } return(callbackResult); }