Пример #1
0
 /// <remarks/>
 public System.IAsyncResult BegincreatePayment(EPaymentCommand paymentCommand, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("createPayment", new object[] {
                 paymentCommand}, callback, asyncState);
 }
Пример #2
0
 public EPaymentStatus createPayment(EPaymentCommand paymentCommand) {
     object[] results = this.Invoke("createPayment", new object[] {
                 paymentCommand});
     return ((EPaymentStatus)(results[0]));
 }
Пример #3
0
 /// <remarks/>
 public void createPaymentAsync(EPaymentCommand paymentCommand, object userState) {
     if ((this.createPaymentOperationCompleted == null)) {
         this.createPaymentOperationCompleted = new System.Threading.SendOrPostCallback(this.OncreatePaymentOperationCompleted);
     }
     this.InvokeAsync("createPayment", new object[] {
                 paymentCommand}, this.createPaymentOperationCompleted, userState);
 }
Пример #4
0
 /// <remarks/>
 public void createPaymentAsync(EPaymentCommand paymentCommand) {
     this.createPaymentAsync(paymentCommand, null);
 }
Пример #5
0
        /// <summary>
        /// Vytvoreni platby pomoci WS z eshopu
        /// 
        /// - pri chybe komunikace s WS vyhozeni GopayException
        /// - pokud nesouhlasi udaje pri kontrole platby vyhozeni GopayException
        /// </summary>
        /// 
        /// <param name="targetGoId">identifikator prijemce - GoId</param>
        /// <param name="productName">popis objednavky zobrazujici se na platebni brane</param>
        /// <param name="totalPriceInCents">celkova cena objednavky v halerich</param>
        /// <param name="currency">mena, ve ktere platba probiha</param>
        /// <param name="orderNumber">identifikator objednavky</param>
        /// <param name="successUrl">URL stranky, kam je zakaznik presmerovan po uspesnem zaplaceni</param>
        /// <param name="failedUrl">URL stranky, kam je zakaznik presmerovan po zruseni platby / neuspesnem zaplaceni</param>
        /// <param name="preAuthorization">jedna-li se o predautorizovanou platbu</param>
        /// <param name="recurrentPayment">jedna-li se o opakovanou platbu</param>
        /// <param name="recurrenceDateTo">datum, do nehoz budou provadeny opakovane platby. Jedna se textovy retezec ve formatu yyyy-MM-dd.</param>
        /// <param name="recurrenceCycle">zakladni casovou jednotku opakovani. Nabyva hodnot [DAY, WEEK, MONTH], pro opakování od CS a.s. lze pouzit pouze hodnotu DAY.</param>
        /// <param name="recurrencePeriod">definuje periodu opakovane platby. Napr. při konfiguraci DAY,5 bude platba provadena kazdy 5. den</param>
        /// <param name="paymentChannels">pole platebnich kanalu, ktere se zobrazi na platebni brane</param>
        /// <param name="defaultPaymentChannel">platebni kanal, ktery se zobrazi (predvybere) na platebni brane po presmerovani</param>
        /// <param name="secureKey">kryptovaci klic prideleny prijemci</param>
        /// 
        /// Informace o zakaznikovi
        /// <param name="firstName">Jmeno</param>
        /// <param name="lastName">Prijmeno</param>
        /// 
        /// Adresa
        /// <param name="city">Mesto</param>
        /// <param name="street">Ulice</param>
        /// <param name="postalCode">PSC</param>
        /// <param name="countryCode">stat</param>
        /// <param name="email">Email</param>
        /// <param name="phoneNumber">Tel. cislo</param>
        /// 
        /// <param name="p1 - p4">volitelne parametry (max. 128 znaku).</param>
        /// <param name="lang">jazyk plat. brany</param>
        /// Parametry jsou vraceny v nezmenene podobe jako soucast volani dotazu na stav platby $paymentStatus (viz metoda isPaymentDone)
        /// 
        /// <returns>paymentSessionId</returns>
        public static long CreateBasePayment(
                long targetGoId,
                string productName,
                long totalPriceInCents,
                string currency,
                string orderNumber,
                string successURL,
                string failedURL,
                System.Nullable<bool> preAuthorization,
                System.Nullable<bool> recurrentPayment,
                string recurrenceDateTo,
                string recurrenceCycle,
                System.Nullable<int> recurrencePeriod,
                string[] paymentChannels,
                string defaultPaymentChannel,
                string secureKey,
                string firstName,
                string lastName,
                string city,
                string street,
                string postalCode,
                string countryCode,
                string email,
                string phoneNumber,
                string p1,
                string p2,
                string p3,
                string p4,
                string lang
        )
        {

            String paymentChannelsString = (null == paymentChannels) ? "" : String.Join(",", paymentChannels);

            // Sestaveni pozadavku pro podpis platby
            string encryptedSignature = GopayHelper.Encrypt(
                        GopayHelper.Hash(
                            GopayHelper.ConcatPaymentCommand(
                            targetGoId,
                            productName,
                            totalPriceInCents,
                            currency,
                            orderNumber,
                            failedURL,
                            successURL,
                            preAuthorization,
                            recurrentPayment,
                            recurrenceDateTo,
                            recurrenceCycle,
                            recurrencePeriod,
                            paymentChannelsString,
                            secureKey)
                        ),
                        secureKey);

            // Sestaveni pozadavku pro zalozeni platby

            ECustomerData customerData = new ECustomerData();
            customerData.firstName = firstName;
            customerData.lastName = lastName;
            customerData.city = city;
            customerData.street = street;
            customerData.postalCode = postalCode;
            customerData.countryCode = countryCode;
            customerData.email = email;
            customerData.phoneNumber = phoneNumber;

            if (!validateCustomerData(customerData))
            {
                throw new GopayException(GopayException.Reason.INVALID_COUNTRY_CODE);
            }

            EPaymentCommand customerPaymentCommand = new EPaymentCommand();
            customerPaymentCommand.targetGoId = targetGoId;
            customerPaymentCommand.productName = productName;
            customerPaymentCommand.totalPrice = totalPriceInCents;
            customerPaymentCommand.currency = currency;
            customerPaymentCommand.orderNumber = orderNumber;
            customerPaymentCommand.failedURL = failedURL;
            customerPaymentCommand.successURL = successURL;
            customerPaymentCommand.preAuthorization = preAuthorization;
            customerPaymentCommand.recurrentPayment = recurrentPayment;
            customerPaymentCommand.recurrenceDateTo = recurrenceDateTo;
            customerPaymentCommand.recurrenceCycle = recurrenceCycle;
            customerPaymentCommand.recurrencePeriod = recurrencePeriod;
            customerPaymentCommand.paymentChannels = paymentChannelsString;
            customerPaymentCommand.defaultPaymentChannel = defaultPaymentChannel;
            customerPaymentCommand.encryptedSignature = encryptedSignature;
            customerPaymentCommand.customerData = customerData;
            customerPaymentCommand.p1 = p1;
            customerPaymentCommand.p2 = p2;
            customerPaymentCommand.p3 = p3;
            customerPaymentCommand.p4 = p4;
            customerPaymentCommand.lang = lang;

            EPaymentStatus paymentStatus;

            try
            {
                // Vytvorime providera pro komunikaci s WS
                AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws);

                /*
                * Vytvareni platby na strane GoPay prostrednictvim providera 
                */
                paymentStatus = provider.createPayment(customerPaymentCommand);

                /*
                 * Kontrola stavu platby - musi byt ve stavu CREATED, kontrola parametru platby 
                 */
                if (paymentStatus.result == GopayHelper.CALL_COMPLETED
                    && paymentStatus.sessionState == GopayHelper.SessionState.CREATED.ToString()
                    && paymentStatus.paymentSessionId > 0)
                {

                    return (long)paymentStatus.paymentSessionId;

                }
                else
                {
                    throw new GopayException("Create payment failed: " + paymentStatus.resultDescription);
                }

            }
            catch (Exception ex)
            {
                /*
                 * Chyba pri komunikaci s WS
                 */
                throw new GopayException(ex.ToString());
            }
        }
Пример #6
0
        /// <summary>
        /// Vytvoreni platby pomoci WS z eshopu
        ///
        /// - pri chybe komunikace s WS vyhozeni GopayException
        /// - pokud nesouhlasi udaje pri kontrole platby vyhozeni GopayException
        /// </summary>
        ///
        /// <param name="targetGoId">identifikator prijemce - GoId</param>
        /// <param name="productName">popis objednavky zobrazujici se na platebni brane</param>
        /// <param name="totalPriceInCents">celkova cena objednavky v halerich</param>
        /// <param name="currency">mena, ve ktere platba probiha</param>
        /// <param name="orderNumber">identifikator objednavky</param>
        /// <param name="successUrl">URL stranky, kam je zakaznik presmerovan po uspesnem zaplaceni</param>
        /// <param name="failedUrl">URL stranky, kam je zakaznik presmerovan po zruseni platby / neuspesnem zaplaceni</param>
        /// <param name="preAuthorization">jedna-li se o predautorizovanou platbu</param>
        /// <param name="recurrentPayment">jedna-li se o opakovanou platbu</param>
        /// <param name="recurrenceDateTo">datum, do nehoz budou provadeny opakovane platby. Jedna se textovy retezec ve formatu yyyy-MM-dd.</param>
        /// <param name="recurrenceCycle">zakladni casovou jednotku opakovani. Nabyva hodnot [DAY, WEEK, MONTH], pro opakování od CS a.s. lze pouzit pouze hodnotu DAY.</param>
        /// <param name="recurrencePeriod">definuje periodu opakovane platby. Napr. při konfiguraci DAY,5 bude platba provadena kazdy 5. den</param>
        /// <param name="paymentChannels">pole platebnich kanalu, ktere se zobrazi na platebni brane</param>
        /// <param name="defaultPaymentChannel">platebni kanal, ktery se zobrazi (predvybere) na platebni brane po presmerovani</param>
        /// <param name="secureKey">kryptovaci klic prideleny prijemci</param>
        ///
        /// Informace o zakaznikovi
        /// <param name="firstName">Jmeno</param>
        /// <param name="lastName">Prijmeno</param>
        ///
        /// Adresa
        /// <param name="city">Mesto</param>
        /// <param name="street">Ulice</param>
        /// <param name="postalCode">PSC</param>
        /// <param name="countryCode">stat</param>
        /// <param name="email">Email</param>
        /// <param name="phoneNumber">Tel. cislo</param>
        ///
        /// <param name="p1 - p4">volitelne parametry (max. 128 znaku).</param>
        /// <param name="lang">jazyk plat. brany</param>
        /// Parametry jsou vraceny v nezmenene podobe jako soucast volani dotazu na stav platby $paymentStatus (viz metoda isPaymentDone)
        ///
        /// <returns>paymentSessionId</returns>
        public static long CreateBasePayment(
            long targetGoId,
            string productName,
            long totalPriceInCents,
            string currency,
            string orderNumber,
            string successURL,
            string failedURL,
            System.Nullable <bool> preAuthorization,
            System.Nullable <bool> recurrentPayment,
            string recurrenceDateTo,
            string recurrenceCycle,
            System.Nullable <int> recurrencePeriod,
            string[] paymentChannels,
            string defaultPaymentChannel,
            string secureKey,
            string firstName,
            string lastName,
            string city,
            string street,
            string postalCode,
            string countryCode,
            string email,
            string phoneNumber,
            string p1,
            string p2,
            string p3,
            string p4,
            string lang
            )
        {
            String paymentChannelsString = (null == paymentChannels) ? "" : String.Join(",", paymentChannels);

            // Sestaveni pozadavku pro podpis platby
            string encryptedSignature = GopayHelper.Encrypt(
                GopayHelper.Hash(
                    GopayHelper.ConcatPaymentCommand(
                        targetGoId,
                        productName,
                        totalPriceInCents,
                        currency,
                        orderNumber,
                        failedURL,
                        successURL,
                        preAuthorization,
                        recurrentPayment,
                        recurrenceDateTo,
                        recurrenceCycle,
                        recurrencePeriod,
                        paymentChannelsString,
                        secureKey)
                    ),
                secureKey);

            // Sestaveni pozadavku pro zalozeni platby

            ECustomerData customerData = new ECustomerData();

            customerData.firstName   = firstName;
            customerData.lastName    = lastName;
            customerData.city        = city;
            customerData.street      = street;
            customerData.postalCode  = postalCode;
            customerData.countryCode = countryCode;
            customerData.email       = email;
            customerData.phoneNumber = phoneNumber;

            if (!validateCustomerData(customerData))
            {
                throw new GopayException(GopayException.Reason.INVALID_COUNTRY_CODE);
            }

            EPaymentCommand customerPaymentCommand = new EPaymentCommand();

            customerPaymentCommand.targetGoId            = targetGoId;
            customerPaymentCommand.productName           = productName;
            customerPaymentCommand.totalPrice            = totalPriceInCents;
            customerPaymentCommand.currency              = currency;
            customerPaymentCommand.orderNumber           = orderNumber;
            customerPaymentCommand.failedURL             = failedURL;
            customerPaymentCommand.successURL            = successURL;
            customerPaymentCommand.preAuthorization      = preAuthorization;
            customerPaymentCommand.recurrentPayment      = recurrentPayment;
            customerPaymentCommand.recurrenceDateTo      = recurrenceDateTo;
            customerPaymentCommand.recurrenceCycle       = recurrenceCycle;
            customerPaymentCommand.recurrencePeriod      = recurrencePeriod;
            customerPaymentCommand.paymentChannels       = paymentChannelsString;
            customerPaymentCommand.defaultPaymentChannel = defaultPaymentChannel;
            customerPaymentCommand.encryptedSignature    = encryptedSignature;
            customerPaymentCommand.customerData          = customerData;
            customerPaymentCommand.p1   = p1;
            customerPaymentCommand.p2   = p2;
            customerPaymentCommand.p3   = p3;
            customerPaymentCommand.p4   = p4;
            customerPaymentCommand.lang = lang;

            EPaymentStatus paymentStatus;

            try
            {
                // Vytvorime providera pro komunikaci s WS
                AxisEPaymentProviderV2Service provider = new AxisEPaymentProviderV2Service(GopayConfig.Ws);

                /*
                 * Vytvareni platby na strane GoPay prostrednictvim providera
                 */
                paymentStatus = provider.createPayment(customerPaymentCommand);

                /*
                 * Kontrola stavu platby - musi byt ve stavu CREATED, kontrola parametru platby
                 */
                if (paymentStatus.result == GopayHelper.CALL_COMPLETED &&
                    paymentStatus.sessionState == GopayHelper.SessionState.CREATED.ToString() &&
                    paymentStatus.paymentSessionId > 0)
                {
                    return((long)paymentStatus.paymentSessionId);
                }
                else
                {
                    throw new GopayException("Create payment failed: " + paymentStatus.resultDescription);
                }
            }
            catch (Exception ex)
            {
                /*
                 * Chyba pri komunikaci s WS
                 */
                throw new GopayException(ex.ToString());
            }
        }