Search code examples
c#asp.net-mvciframeopayo

Using Sage Pay iFrame method ,for customer click the url to complete the payment,how can I generate the iFrame URL?


Here is the issue: My website use the Sage Pay iFrame method for customer to finished their payment ,but I don't know how to generate the payment URL, which can be clicked by customer redirect to Sage Pay to finish the payment .

The URL is what I need, or How to generate this URL.


Solution

  • I suggest you take a look at the SagePay API documentation here which will take you through how to create the request to SagePay in order to receive the nextUrl, specifically Appendix A1 and Appendix A2 - as this is your request and response object for the payment registration. Basically the process works like this:

    • You send the request object (in A1 of the appendix) to SagePay's server - you will need to read the relevant sections of the linked PDF for this.

    • They response with the response object (A2), of which one of the properties is NextUrl.

    • You can then either present the url to the user to click on, or a better solution is to return a page to the user, using the NextUrl value as the src of the iframe in the page - something like

    -

    return View("Payment", new SagePayView { nextUrl = sagePayResponse.NextUrl });
    

    And your payment view:

    <h2>Secure Payment by SagePay</h2>
    <iframe src="@Model.nextUrl" width="600", height="600" frameborder="0" border="0" style="margin-left:15px;"></iframe>