我有功能,付费用户:
def pay
require 'httpclient'
require 'xmlsimple'
clnt = HTTPClient.new
user = User.find(params[:user_id])
@params_id = params[:user_id]
credentials = {
'USER' => 'payer_1342623102_biz_api1.gmail.com',
'PWD' => '1342623141',
'SIGNATURE' => 'Ay2zwWYEoiRoHTTVv365EK8U1lNzAESedJw09MPnj0SEIENMKd6jvnKL '
}
header = {"X-PAYPAL-SECURITY-USERID" => "payer_1342623102_biz_api1.gmail.com",
"X-PAYPAL-SECURITY-PASSWORD" => "1342623141",
"X-PAYPAL-SECURITY-SIGNATURE" => "Ay2zwWYEoiRoHTTVv365EK8U1lNzAESedJw09MPnj0SEIENMKd6jvnKL ",
"X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT" => "XML",
"X-PAYPAL-APPLICATION-ID" => "APP-80W284485P519543T"
}
//here is data what is posting to PayPal
data = {"actionType" => "PAY",
"receiverList.receiver(0).email"=> user.email,
"receiverList.receiver(0).amount" => "10",
"currencyCode" => "USD",
"cancelUrl" => "http://127.0.0.1:3000/",
"returnUrl" => "http://127.0.0.1:3000/",
"requestEnvelope.errorLanguage" => "en_US"}
uri = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"
res = clnt.post(uri, data, header)
端 来自文档:
Adaptive Payments API operation - use -
ipnNotificationUrl field of the Pay or Preapproval request
所以,我应该添加到数据变量中:
"ipnNotificationUrl" => "myaapp.com"//my site url yes ?
我应该在这个字段中放入我的网站网址?
如何从此通知中获取信息?
如果交易成功,如何发送一些电子邮件并采取一些行动?
我无法在本地测试,是吗?
如何在沙箱中测试?
答案 0 :(得分:1)
是的,如果您想接收与付款相关的通知,则应包括该字段
您需要指定一个可从外部访问的URL(因为这是PayPal将从其服务器发布信息的地方)。
此网址可以是一个PHP页面,在收到IPN并验证后,会发送您提到的电子邮件。
要模拟来自PayPal的IPN,您可以使用沙盒开发者页面中的以下工具:https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
(或者,您可以在沙盒中完成购买,如果您在API调用中指定了ipnNotificationURL,PayPal会在完成付款时向您发送一个)