예제 #1
0
        /// <summary>
        /// POST /paymentSession API call
        /// </summary>
        /// <param name="paymentSessionRequest"></param>
        /// <returns></returns>
        public PaymentSessionResponse PaymentSession(PaymentSessionRequest paymentSessionRequest)
        {
            var jsonRequest  = Util.JsonOperation.SerializeRequest(paymentSessionRequest);
            var jsonResponse = _paymentSession.Request(jsonRequest);

            return(JsonConvert.DeserializeObject <PaymentSessionResponse>(jsonResponse));
        }
예제 #2
0
        /// <summary>
        /// POST /paymentSession API call async
        /// </summary>
        /// <param name="paymentSessionRequest"></param>
        /// <returns>PaymentSessionResponse</returns>
        public async Task <PaymentSessionResponse> PaymentSessionAsync(PaymentSessionRequest paymentSessionRequest)
        {
            var jsonRequest  = Util.JsonOperation.SerializeRequest(paymentSessionRequest);
            var jsonResponse = await _paymentSession.RequestAsync(jsonRequest);

            return(JsonConvert.DeserializeObject <PaymentSessionResponse>(jsonResponse));
        }
예제 #3
0
        public async Task <string> CreatePaymentSession(PaymentSessionRequest createPaymentSessionRequest)
        {
            try
            {
                _uow.PaymentRepository.Add(new Payment()
                {
                    EntryDate     = DateTime.Now,
                    InvoiceNumber = createPaymentSessionRequest.InvoiceNumber,
                    RequestId     = createPaymentSessionRequest.InvoiceNumber + 800000,
                    Amount        = createPaymentSessionRequest.TotalPrice,
                    PaymentToken  = createPaymentSessionRequest.PaymentToken,
                    Description   = createPaymentSessionRequest.Description,
                    IsActive      = true,
                    BankGatewayId = createPaymentSessionRequest.GatewayId
                });
                await _uow.Save();

                return(createPaymentSessionRequest.PaymentToken);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a payment session. Initializes a hosted form payment session with all the necessary data (order information, customer information, payment method...).  This API route can be used for classic hosted form. In that case, this operation is an alternative to the \&quot;client redirection POST\&quot; method (with HMAC).  It&#39;s also the standard way for initializing a payment session for \&quot;iframe integration\&quot;.            You will get an URL pointing to a paymentform, so that the customer is able to complete the payment form with his card details.  You will also get a PaymentSessionId, useful for calling the GetPaymentResult API when the payment is completed.
        /// </summary>
        /// <exception cref="pachirapay.Connector.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="authToken">Gets or sets the authentication token.</param>
        /// <param name="paymentSessionRequest">The payment session request. (optional)</param>
        /// <returns>Task of ApiResponse (PaymentSessionResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <PaymentSessionResponse> > V1PaymentSessionsPostAsyncWithHttpInfo(string authToken, PaymentSessionRequest paymentSessionRequest = null)
        {
            // verify the required parameter 'authToken' is set
            if (authToken == null)
            {
                throw new ApiException(400, "Missing required parameter 'authToken' when calling PaymentSessionApi->V1PaymentSessionsPost");
            }

            var    localVarPath         = "./v1/payment-sessions";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json-patch+json",
                "application/json",
                "text/json",
                "application/_*+json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (authToken != null)
            {
                localVarHeaderParams.Add("authToken", this.Configuration.ApiClient.ParameterToString(authToken));                    // header parameter
            }
            if (paymentSessionRequest != null && paymentSessionRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(paymentSessionRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = paymentSessionRequest; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("V1PaymentSessionsPost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <PaymentSessionResponse>(localVarStatusCode,
                                                            localVarResponse.Headers.ToDictionary(x => x.Key, x => string.Join(",", x.Value)),
                                                            (PaymentSessionResponse)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(PaymentSessionResponse))));
        }
예제 #5
0
        /// <summary>
        /// Creates a payment session. Initializes a hosted form payment session with all the necessary data (order information, customer information, payment method...).  This API route can be used for classic hosted form. In that case, this operation is an alternative to the \&quot;client redirection POST\&quot; method (with HMAC).  It&#39;s also the standard way for initializing a payment session for \&quot;iframe integration\&quot;.            You will get an URL pointing to a paymentform, so that the customer is able to complete the payment form with his card details.  You will also get a PaymentSessionId, useful for calling the GetPaymentResult API when the payment is completed.
        /// </summary>
        /// <exception cref="pachirapay.Connector.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="authToken">Gets or sets the authentication token.</param>
        /// <param name="paymentSessionRequest">The payment session request. (optional)</param>
        /// <returns>Task of PaymentSessionResponse</returns>
        public async System.Threading.Tasks.Task <PaymentSessionResponse> V1PaymentSessionsPostAsync(string authToken, PaymentSessionRequest paymentSessionRequest = null)
        {
            ApiResponse <PaymentSessionResponse> localVarResponse = await V1PaymentSessionsPostAsyncWithHttpInfo(authToken, paymentSessionRequest);

            return(localVarResponse.Data);
        }
예제 #6
0
        /// <summary>
        /// Creates a payment session. Initializes a hosted form payment session with all the necessary data (order information, customer information, payment method...).  This API route can be used for classic hosted form. In that case, this operation is an alternative to the \&quot;client redirection POST\&quot; method (with HMAC).  It&#39;s also the standard way for initializing a payment session for \&quot;iframe integration\&quot;.            You will get an URL pointing to a paymentform, so that the customer is able to complete the payment form with his card details.  You will also get a PaymentSessionId, useful for calling the GetPaymentResult API when the payment is completed.
        /// </summary>
        /// <exception cref="pachirapay.Connector.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="authToken">Gets or sets the authentication token.</param>
        /// <param name="paymentSessionRequest">The payment session request. (optional)</param>
        /// <returns>PaymentSessionResponse</returns>
        public PaymentSessionResponse V1PaymentSessionsPost(string authToken, PaymentSessionRequest paymentSessionRequest = null)
        {
            ApiResponse <PaymentSessionResponse> localVarResponse = V1PaymentSessionsPostWithHttpInfo(authToken, paymentSessionRequest);

            return(localVarResponse.Data);
        }