Hi smith,
It is similar to express checkout functionality just to need to enable the in-context checkout. For this you need to added the following script link and script code in your checkout page:
<script src="//www.paypalobjects.com/api/checkout.js" async></script>
<script type="text/javascript">
window.paypalCheckoutReady =function () {
paypal.checkout.setup("@MvcApplication1.Models.PayPalSettings.MerchantAccountID", {
environment:'@MvcApplication1.Models.PayPalSettings.Environment',
click:function (event) {
event.preventDefault();
paypal.checkout.initXO();
$.support.cors =true;
$.ajax({
url:'@Html.Raw(Url.Action("PayPaltoken", "Cart"))',
type:"GET",
async:true,
crossDomain:true,
//Load the minibrowser with the redirection url in the success handler
success:function (token) {
var url = paypal.checkout.urlPrefix + token;
//Loading Mini browser with redirect url, true for async AJAX calls
paypal.checkout.startFlow(url);
},
error:function (responseData, textStatus, errorThrown) {
alert("Something going wrong ");
//Gracefully Close the minibrowser in case of AJAX errors
paypal.checkout.closeFlow();
}
});
},
button: ['btPaypal']
});
}
</script>
You can follow the detail step by step integration in blog:
https://www.niceonecode.com/Blog/DotNet/MVC/-PayPal-Gateway-Integration-(in-context-checkout)-in-ASP_NET-mvc/5
you can also refer to link
https://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/checkout-and-payment-with-paypal