예제 #1
0
        /// <summary>
        /// Register specified Transaction in Przelewy24 for specified mode
        /// Sets transction P24_sign and P24Response
        /// This method uses only parameters from give transaction
        /// </summary>
        /// <param name="transaction">Transaction to register</param>
        /// <param name="sandboxMode">Determine if transaction will be registered for sandbox(true) or production(false)</param>
        /// <returns>P24Response object with data about Token or Errors</returns>
        public static async Task <P24Response> RegisterTransaction(Transaction transaction, Mode mode, string crc)
        {
            transaction.P24_sign = Przelewy24.CalculateRegisterSign
                                   (
                transaction.P24_session_id,
                transaction.P24_merchant_id,
                transaction.P24_amount,
                transaction.P24_currency,
                crc
                                   );
            transaction.SetRegisterSign();
            string responseString = await RegisterTransaction(transaction.GetParameters(), mode);

            P24Response response = new P24Response(responseString);

            transaction.P24Response = response;
            return(response);
        }
예제 #2
0
        /// <summary>
        /// Register specified Transaction in Przelewy24 for mode specified in this Przelewy24 object
        /// This method uses only parameters from give transaction
        /// It does not chec if Merchant ID nad POS ID are the same as in this Przelewy24 object
        /// Allow to save transaction to database specified in TransactionDb property
        /// </summary>
        /// <param name="transaction">Transaction to register</param>
        /// <param name="saveToDatabase">If sets, transaction will be saved in TransactionDb</param>
        /// <param name="saveOnlyCorrecteTransaction">If sets, only Correct transactions will be saved - will ignore transaction with errors</param>
        /// <returns>P24Response object with data about Token or Errors</returns>
        public async Task <P24Response> RegisterTransaction(Transaction transaction, bool saveToDatabase, bool saveOnlyCorrecteTransaction)
        {
            P24Response response = await RegisterTransaction(transaction);

            if (saveToDatabase)
            {
                if (response.OK || !saveOnlyCorrecteTransaction)
                {
                    try
                    {
                        this.TransactionDb.SaveTransaction(transaction);
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
            return(response);
        }