ASP.NET MVC:在发布到 Paypal 支付网关之前触发操作

发布于 2024-08-31 16:23:09 字数 533 浏览 2 评论 0原文

我正在开发一个使用 Paypal 作为支付网关的电子商务网站。我想做的就是在用户前往 Paypal 支付订单之前运行一些代码,但我不知道该怎么做。

用户应单击提交按钮,进行更改(在本例中为订单状态),然后将用户重定向到支付网关。例如:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GoToPaypal(FormCollection collection)
{
    //change order status

    //send user to paypal where they pay for their order
}

所以我的问题是你如何做应用程序的事情,然后重定向到贝宝的支付网关?示例 HTML 和 C# 会很可爱:)

注意:这个人 似乎有同样的问题 - (并且可能解释得更好)。

I'm in the middle of developing an e-commerce site that is using Paypal as it's payment gateway. All I want to do is run some code before the user heads off to Paypal to pay for their order, but I have no idea how to do it.

The user should click a submit button, changes are made (in this case, the status of the order), and then the user is redirected to the payment gateway. Eg:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GoToPaypal(FormCollection collection)
{
    //change order status

    //send user to paypal where they pay for their order
}

So my question is how do you do application stuff and then redirect to paypal's payment gateway? Example HTML and C# would be lovely :)

Note: This guy seems to have the same issue - (and probably explains it better).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怕倦 2024-09-07 16:23:09

您可以从您的操作方法发布到贝宝,但很难向用户显示响应。此外,您希望在不使用 GET 请求的情况下将用户带到 paypal 网站(GET 公开了 url 字符串中的参数,而 Paypal 可能不接受 GET 请求)。


据我了解,您有一个包含一些可发布到 PayPal 的字段的表单。在将表单发布到 Paypal 之前,您需要捕获表单上的字段,对其进行一些处理,然后让它们发布到 Paypal。

一种方法是使用 jQuery。 连接提交事件

http://api.jquery.com/submit/

单击提交时, ,在上面创建的提交的事件处理程序中,使用 MVC 操作所需的表单字段进行 ajax 调用。
http://api.jquery.com/jQuery.post/

进行处理并发送回复。

当页面收到 ajax 响应时,如果需要,更改从 ajax 响应接收到的表单字段。

最后使用jQuery提交表单。

==

You could POST to paypal from your action method but it will be difficult to show the user the response. In addition, you want to take the users to the paypal website without using a GET request (GET exposes the parameters in the url string and Paypal probably does not accept a GET request).


From what I understand, you have a form with some fields that posts to PayPal. Before the form is posted to Paypal, you want to capture the fields on the form, do some processing with it and then let them post to paypal.

One way of doing this is with jQuery. You wireup the submit event

http://api.jquery.com/submit/

When submit is clicked, in the event handler for the submit you created above, make an ajax call with the form fields you need to your MVC action.
http://api.jquery.com/jQuery.post/

Do the processing and send back a response.

When the page receives the ajax response, change form fields if required that are received from the ajax response.

Finally Use jQuery to submit the form.

==

吲‖鸣 2024-09-07 16:23:09

你的意思是在完成你想做的事情后重定向到贝宝?

// run some code
// 
// go to paypal
return RedirectResult("http://paypal.com/blah");

You mean redirect to paypal, after you're done doing what you want to do?

// run some code
// 
// go to paypal
return RedirectResult("http://paypal.com/blah");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文