publicrecordSampleContext(intSegmentationId):PaymentContext;publicclassCheckoutController:Controller{...publicasyncTask<IActionResult>Index(<YOUR_PARAMETERS>){// Simple example here, normally you could be able //to get more information from parameters passed // to the controller methodvarsampleContext=newSampleContext(1);varpaymentOptions=await_paymentOptionService.ListValidPaymentOptionsAsync(sampleContext);if(!paymentOptions.Any()){thrownewInvalidOperationException("No payment options found");}varcheckoutViewModel=newCheckoutViewModel{PaymentOptions=paymentOptions.ToList()};returnView(checkoutViewModel);}}
Notice the SampleContext which you get to define yourself. This contextual object is
important if you require special rules for deciding if a given payment option is
enabled or not.
Next step
With the options presented to the user, the next step is to initiate a payment with
the given payment identifier. You can read more about that here.