public void Should_Cancel() { var postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = CreateToken(null), Interval = IntervalType.Day, IntervalCount = 1 }; var paymentScheduleId = _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, null); Assert.IsTrue(_paymentSchedulesApi.PaymentSchedulesCancel(paymentScheduleId)); try { Assert.IsFalse(_paymentSchedulesApi.PaymentSchedulesCancel(paymentScheduleId)); Assert.Fail(); } catch { } }
public void Should_Create_And_Get_With_Impersonation() { var tokenIdWithImpersonation = CreateToken(TestApiSettings.ImpersonationAccountKey); var postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = tokenIdWithImpersonation, Interval = IntervalType.Day, IntervalCount = 1 }; var paymentScheduleId = _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, TestApiSettings.ImpersonationAccountKey); Assert.IsNotNull(paymentScheduleId); var paymentSchedule = _paymentSchedulesApi.PaymentSchedulesGet(paymentScheduleId, TestApiSettings.ImpersonationAccountKey); Assert.IsNotNull(paymentSchedule); Assert.IsNotNull(paymentSchedule.StartDate); try { // Should not be able to get this payment schedule without the impersonation key. _paymentSchedulesApi.PaymentSchedulesGet(paymentScheduleId, null); Assert.Fail(); } catch (ApiException exception) { Assert.AreEqual(404, exception.ErrorCode); } try { // Should not be able to cancel this payment schedule without the impersonation key. _paymentSchedulesApi.PaymentSchedulesCancel(paymentScheduleId, null); Assert.Fail(); } catch (ApiException exception) { Assert.AreEqual(404, exception.ErrorCode); } Assert.IsTrue(_paymentSchedulesApi.PaymentSchedulesCancel(paymentScheduleId, TestApiSettings.ImpersonationAccountKey)); }
public void Should_Fail_With_Invalid_Token() { var tokenId = CreateToken(null); var tokenIdWithImpersonation = CreateToken(TestApiSettings.ImpersonationAccountKey); var postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = tokenIdWithImpersonation, Interval = IntervalType.Day, IntervalCount = 1 }; try { _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, null); Assert.Fail(); } catch (ApiException exception) { Assert.AreEqual(400, exception.ErrorCode); } postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = tokenId, Interval = IntervalType.Day, IntervalCount = 1 }; try { _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, TestApiSettings.ImpersonationAccountKey); Assert.Fail(); } catch (ApiException exception) { Assert.AreEqual(400, exception.ErrorCode); } }
public void Should_Fail_With_Invalid_Token() { var tokenId = CreateToken(null); var tokenIdWithImpersonation = CreateToken(TestApiSettings.ImpersonationAccountKey); // Software Platform attempting to use client token without impersonation var postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = tokenIdWithImpersonation, Interval = IntervalType.Day, IntervalCount = 1 }; try { _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, null); Assert.Fail(); } catch (ApiException exception) { Assert.AreEqual(400, exception.ErrorCode); } // Software platform to use its own token on behalf of a client. Allowed as of 11/28/2018 postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = tokenId, Interval = IntervalType.Day, IntervalCount = 1 }; var result = _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, TestApiSettings.ImpersonationAccountKey); Assert.IsFalse(string.IsNullOrWhiteSpace(result)); }
public void Should_Create_And_Get() { var postPaymentScheduleRequestModel = new PostPaymentScheduleRequestModel { Payer = "John Smith", EmailAddress = "*****@*****.**", Amount = 100, TokenId = CreateToken(null), Interval = IntervalType.Day, IntervalCount = 1 }; var paymentScheduleId = _paymentSchedulesApi.PaymentSchedulesPost(postPaymentScheduleRequestModel, null); Assert.IsNotNull(paymentScheduleId); var paymentSchedule = _paymentSchedulesApi.PaymentSchedulesGet(paymentScheduleId); Assert.IsNotNull(paymentSchedule); Assert.IsNotNull(paymentSchedule.StartDate); }
/// <summary> /// Creates a payment schedule for a delayed payment or recurring payments. /// </summary> /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="postPaymentScheduleRequestModel">Contains the parameters for the payment schedule.</param> /// <param name="impersonationAccountKey">The key that allows impersonation of another account for which the transaction(s) will be processed. Only specify a value if the account being impersonated is different from the account that is submitting this request. (optional, default to )</param> /// <returns></returns> public string PaymentSchedulesPost(PostPaymentScheduleRequestModel postPaymentScheduleRequestModel, string impersonationAccountKey = null) { if (postPaymentScheduleRequestModel == null) { throw new ApiException(400, "Missing required parameter 'postPaymentScheduleRequestModel' when calling PaymentSchedulesApi->PaymentSchedulesPost"); } var localVarPath = "/api/v1/paymentSchedules"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(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", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json", "text/json", "application/xml", "text/xml" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (impersonationAccountKey != null) { localVarHeaderParams.Add("impersonationAccountKey", Configuration.ApiClient.ParameterToString(impersonationAccountKey)); // header parameter } if (postPaymentScheduleRequestModel.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(postPaymentScheduleRequestModel); // http body (model) parameter } else { localVarPostBody = postPaymentScheduleRequestModel; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (localVarStatusCode == 400) { var errorResponseModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ErrorResponseModel>(localVarResponse.Content); throw new ApiException(localVarStatusCode, errorResponseModel != null ? errorResponseModel.Message : null); } else if (localVarStatusCode >= 400) { var errorResponseModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ErrorResponseModel>(localVarResponse.Content); throw new ApiException(localVarStatusCode, errorResponseModel != null ? errorResponseModel.Message : null); } else if (localVarStatusCode == 0) { throw new ApiException(localVarStatusCode, localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); } return(localVarResponse.Headers.First(x => x.Name == "Location").Value.ToString().Split('/').Last()); }