public async void Ensure_resetting_velocity_control_allows() { // Get client / fixture var client = ClientFactory.GetMarqetaClient(); var fixture = new Fixture(); // // NB: Responses from other test classes have already had assertions run against them // // Get card product var cardProductResponse = await CardProductHelper.CreateCardProduct(); // Create a program funding source var programFundingSourceResponse = await ProgramFundingHelper.CreateProgramFundingSource(); // Create user account var cardHolderResponse = await UserHelper.CreateUser(); // Create / activate card var cardResponse = await CardTests.CreateCard(cardHolderResponse.Token, cardProductResponse.Token); //await CardTests.ActivateCard(cardResponse.Token); // Fund user account const double fundingAmount = 1000; await GpaOrderHelper.FundUserAccount(cardHolderResponse.Token, programFundingSourceResponse.Token, fundingAmount); // Add velocity control const double velocityControlAmount = 10; var velocityControlRequest = new Velocity_control_request { Amount_limit = velocityControlAmount, Velocity_window = Velocity_control_requestVelocity_window.LIFETIME, Currency_code = "USD", Association = new Spend_control_association { User_token = cardHolderResponse.Token }, }; var vcResponse = await client.VelocitycontrolsPostAsync(velocityControlRequest); Assert.NotNull(vcResponse); // Transact 1 - This should succeed var authRequest1 = new Auth_request_model { Amount = velocityControlAmount, Mid = fixture.Create <string>(), Card_token = cardResponse.Token, }; var simulateResponse1 = await client.SimulateAuthorizationAsync(authRequest1); Assert.NotNull(simulateResponse1); Assert.Equal(Transaction_modelState.PENDING, simulateResponse1.Transaction.State); var clearingModel = new ClearingModel { Amount = authRequest1.Amount, Original_transaction_token = simulateResponse1.Transaction.Token }; var simulateClearingResponseModel = await client.SimulateClearingAsync(clearingModel); Assert.NotNull(simulateClearingResponseModel); Assert.Equal(Transaction_modelState.COMPLETION, simulateClearingResponseModel.Transaction.State); var balance2 = await client.BalancesGetAsync(cardHolderResponse.Token); Assert.Equal(fundingAmount - authRequest1.Amount, balance2.Gpa.Available_balance); // Transact 2 - This should be declined var simulateResponse2 = await client.SimulateAuthorizationAsync(authRequest1); Assert.NotNull(simulateResponse2); Assert.Equal(Transaction_modelState.DECLINED, simulateResponse2.Transaction.State); Assert.Equal("1834", simulateResponse2.Transaction.Response.Code); Assert.Equal("Exceeds withdrawal amount limit", simulateResponse2.Transaction.Response.Memo); }
public async void QuickStart() { // Get client / fixture var client = ClientFactory.GetMarqetaClient(); var fixture = new Fixture(); // // Step 2: Create objects // https://www.marqeta.com/api/guides/WIlA2isAAMkAsk6F/quick-start--marqeta-api#step_____create_objects // // Create card product var cardProductRequest = new Card_product_request { Start_date = DateTimeOffset.Now.Date, Name = fixture.Create <string>(), Config = new Card_product_config { Fulfillment = new Card_product_fulfillment { Payment_instrument = Card_product_fulfillmentPayment_instrument.VIRTUAL_PAN }, Poi = new Poi { Ecommerce = true }, Card_life_cycle = new Card_life_cycle { Activate_upon_issue = true }, } }; var cardProductResponse = await client.CardproductsPostAsync(cardProductRequest); Assert.NotNull(cardProductResponse); // Create a program funding sources var programFundingSourceRequest = fixture.Build <Program_funding_source_request>() .Without(pfsr => pfsr.Active) .Without(pfsr => pfsr.Token) .Create(); var programFundingSourceResponse = await client.FundingsourcesProgramPostAsync(programFundingSourceRequest); Assert.NotNull(programFundingSourceResponse); // Create user account var cardHolderModel = new Card_holder_model(); var cardHolderResponse = await client.UsersPostAsync(cardHolderModel); Assert.NotNull(cardHolderResponse); // Create card var cardRequest = new Card_request { User_token = cardHolderResponse.Token, Card_product_token = cardProductResponse.Token, }; var cardResponse = await client.CardsPostAsync(cardRequest); Assert.NotNull(cardResponse); // Activate card var cardTransitionRequest = new Card_transition_request { Card_token = cardResponse.Token, State = Card_transition_requestState.ACTIVE, Channel = Card_transition_requestChannel.API, Reason_code = Card_transition_requestReason_code._00 }; var cardTransitionResponse = await client.CardtransitionsPostAsync(cardTransitionRequest); Assert.NotNull(cardTransitionResponse); // // Step 3: Fund user account // https://www.marqeta.com/api/guides/WIlA2isAAMkAsk6F/quick-start--marqeta-api#step_____fund_user_account_ // // Fund user account var gpaRequest = new Gpa_request { User_token = cardHolderResponse.Token, Amount = 1000, Currency_code = "USD", Funding_source_token = programFundingSourceResponse.Token }; var gpaResponse = await client.GpaordersPostAsync(gpaRequest); Assert.NotNull(gpaResponse); // // Step 4: Transact // https://www.marqeta.com/api/guides/WIlA2isAAMkAsk6F/quick-start--marqeta-api#step_____transact_ // // Transact var authRequest = new Auth_request_model { Amount = 10, Mid = fixture.Create <string>(), Card_token = cardResponse.Token, }; var simulateResponse = await client.SimulateAuthorizationAsync(authRequest); Assert.NotNull(simulateResponse); }