Ejemplo n.º 1
0
        /// <summary>
        /// Zruseni opakovani plateb
        /// </summary>
        ///
        /// <param name="paymentSessionId">identifikator platby </param>
        /// <param name="targetGoId">identifikator prijemnce - GoId</param>
        /// <param name="secureKey">kryptovaci klic prideleny GoPay</param>
        public static void VoidRecurrentPayment(
            long paymentSessionId,
            long targetGoId,
            string secureKey
            )
        {
            try
            {
                // Inicializace providera pro WS
                AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws);
                EPaymentResult paymentResult;

                // Sestaveni dotazu na stav platby
                string hash = GopayHelper.Hash(
                    GopayHelper.ConcatPaymentSession(
                        targetGoId,
                        paymentSessionId,
                        secureKey)
                    );

                string sessionEncryptedSignature = GopayHelper.Encrypt(hash, secureKey);

                EPaymentSessionInfo paymentSessionInfo = new EPaymentSessionInfo();
                paymentSessionInfo.targetGoId         = targetGoId;
                paymentSessionInfo.paymentSessionId   = paymentSessionId;
                paymentSessionInfo.encryptedSignature = sessionEncryptedSignature;

                paymentResult = provider.voidRecurrentPayment(paymentSessionInfo);

                string returnHash = GopayHelper.Decrypt(paymentResult.encryptedSignature, secureKey);

                if (hash != returnHash)
                {
                    throw new GopayException("Encrypted signature differ");
                }

                if (paymentResult.result == GopayHelper.CALL_RESULT_FAILED)
                {
                    throw new GopayException("autorization not voided [" + paymentResult.resultDescription + "]");
                }
                else if (paymentResult.result == GopayHelper.CALL_RESULT_ACCEPTED)
                {
                    //zruseni opakovani platby bylo zarazeno ke zpracovani
                    //po urcite dobe je nutne dotazat zruseni se shodnymi parametry zda je j*z $paymentResult->result == GopayHelper::CALL_RESULT_FINISHED
                }
                else if (paymentResult.result == GopayHelper.CALL_RESULT_FINISHED)
                {
                    //opakovani platby bylo zruseno
                    //oznacte platbu
                }
            }
            catch (Exception ex)
            {
                //
                // Chyba pri komunikaci s WS
                //
                throw new GopayException(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Zruseni predautorizovani plateb
        /// </summary>
        ///
        /// <param name="paymentSessionId">identifikator platby </param>
        /// <param name="targetGoId">identifikator prijemnce - GoId</param>
        /// <param name="secureKey">kryptovaci klic prideleny GoPay</param>
        public static void VoidAuthorization(
            long paymentSessionId,
            long targetGoId,
            string secureKey
            )
        {
            try
            {
                // Inicializace providera pro WS
                AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws);
                EPaymentResult paymentResult;

                // 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;

                paymentResult = provider.voidAuthorization(paymentSessionInfo);

                if (paymentResult.result == GopayHelper.CALL_RESULT_FAILED)
                {
                    throw new GopayException("autorization not voided [" + paymentResult.resultDescription + "]");
                }

                //Overeni podpisu
                GopayHelper.CheckPaymentResult(
                    (long)paymentResult.paymentSessionId,
                    paymentResult.encryptedSignature,
                    paymentResult.result,
                    paymentSessionId,
                    secureKey);
            }
            catch (Exception ex)
            {
                //
                // Chyba pri komunikaci s WS
                //
                throw new GopayException(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Zruseni platby
        /// </summary>
        ///
        /// <param name="paymentSessionId">identifikator platby</param>
        /// <param name="targetGoId">identifikator prijemnce - GoId</param>
        /// <param name="secureKey">kryptovaci klic prideleny GoPay</param>
        ///
        /// <returns>result/returns>
        public static string RefundPayment(
            long paymentSessionId,
            long targetGoId,
            string secureKey)
        {
            try
            {
                // Inicializace providera pro WS
                AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws);
                EPaymentResult paymentResult;

                string encryptedSignature = GopayHelper.Encrypt(
                    GopayHelper.Hash(
                        GopayHelper.ConcatPaymentSession(
                            targetGoId,
                            paymentSessionId,
                            secureKey)
                        ), secureKey);

                EPaymentSessionInfo paymentSessionInfo = new EPaymentSessionInfo();
                paymentSessionInfo.targetGoId         = targetGoId;
                paymentSessionInfo.paymentSessionId   = paymentSessionId;
                paymentSessionInfo.encryptedSignature = encryptedSignature;

                paymentResult = provider.refundPayment(paymentSessionInfo);

                if (paymentResult.result == GopayHelper.CALL_RESULT_FAILED)
                {
                    throw new GopayException("payment not refunded [" + paymentResult.resultDescription + "]");
                }

                return(paymentResult.result);
            }
            catch (Exception ex)
            {
                //
                // Chyba pri komunikaci s WS
                //
                throw new GopayException(ex.ToString());
            }
        }
Ejemplo n.º 4
0
        /// <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);
        }