コード例 #1
0
        public void CancelTransactionResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"": {""event"": ""cancel_response"", ""id"": ""0"", ""datetime"": ""2018-02-06T15:16:44.094"", ""data"": {""pos_ref_id"": ""123456abc"", ""success"": false, ""error_reason"": ""TXN_PAST_POINT_OF_NO_RETURN"", ""error_detail"":""Txn has passed the point of no return"" }}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new CancelTransactionResponse(msg);

            // assert
            Assert.Equal("cancel_response", msg.EventName);
            Assert.False(response.Success);
            Assert.Equal("123456abc", response.PosRefId);
            Assert.Equal("TXN_PAST_POINT_OF_NO_RETURN", response.GetErrorReason());
            Assert.True(response.WasTxnPastPointOfNoReturn());
            Assert.NotNull(response.GetErrorDetail());
            Assert.Equal(response.GetResponseValueWithAttribute("pos_ref_id"), response.PosRefId);

            // act
            response = new CancelTransactionResponse();

            // assert
            Assert.Null(SpiClientTestUtils.GetInstanceField(response.GetType(), response, "_m"));
            Assert.Null(response.PosRefId);
        }
コード例 #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CancelTransactionResponse response = new CancelTransactionResponse();


            return(response);
        }
コード例 #3
0
        public ActionResult CancelOrder()
        {
            var cancelTransactionRequest = new CancelTransactionRequest((string)Session["tid"], _configuration);
            CancelTransactionResponse response = _cieloService.CancelTransaction(cancelTransactionRequest);
            ViewBag.Status = response.Status.ToString();

            return RedirectToAction("CheckStatus");
        }
コード例 #4
0
        /// <summary>
        /// Cancel opened transaction, mandatory fields are order and typ
        /// </summary>
        /// <param name="transaction">
        /// Offer type transaction, from Models namespace.
        /// </param>
        /// <returns></returns>
        public CancelTransactionResponse CancelOffer(Offer transaction)
        {
            if (!IsPrivateAPIPossible())
            {
                throw new ArgumentException("This method need key and secret (key and id)");
            }
            IRestRequest req = new RestRequest();

            req = addMandatoryParameters(req, "transactions", "cancel");
            req.AddParameter("order", transaction.nr);
            req.AddParameter("typ", transaction.offertype);
            string response = client.Execute(req).Content;
            CancelTransactionResponse resp = JsonConvert.DeserializeObject <CancelTransactionResponse>(response);

            return(resp);
        }
コード例 #5
0
        public override async Task <CancelTransactionResponse> CancelTransaction(CancelTransactionRequest request, ServerCallContext context)
        {
            var httpContext = context.GetHttpContext();

            var userId = httpContext.GetUserId();

            var account = await _accountService.FindAccountOrNullAsync(userId);

            if (account == null)
            {
                throw context.NotFoundRpcException("User account not found.");
            }

            var result = await _accountService.MarkAccountTransactionAsCanceledAsync(account !, request.TransactionId.ParseEntityId <TransactionId>());

            if (result.IsValid)
            {
                var response = new CancelTransactionResponse();

                return(context.Ok(response));
            }

            throw context.FailedPreconditionRpcException(result);
        }