Paypal交易未显示

时间:2015-09-24 07:09:39

标签: ruby ruby-on-rails-4 paypal transactions paypal-adaptive-payments

我已经集成了Paypal沙盒,实时

交易显示成功,但我无法在开发人员仪表板上看到交易列表。 代码:

@api = PayPal::SDK::AdaptivePayments.new
@pay = @api.build_pay({
   :actionType => "PAY",
   :cancelUrl => "http://localhost:3000/adaptive_payments/pay",
   :currencyCode => "USD",
   :feesPayer => "SENDER",
  :ipnNotificationUrl => "http://localhost:3000/adaptive_payments/ipn_notify",
   :receiverList => {
     :receiver => [{
       :amount => 1.0,
       :email => "xxxxxx@gmail.com" }] },
       :returnUrl => "http://localhost:3000/adaptive_payments/pay"
 })
  @response = @api.pay(@pay)
   key = @response.payKey

响应:

Response.body={
  "responseEnvelope": {
  "timestamp": "2015-09-28T03:48:23.428-07:00",
  "ack": "Success",
  "correlationId": "xxxxx",
  "build": "17820627"
},
"payKey": "xxxx",
"paymentExecStatus": "CREATED"
}

yml文件:

production:
  mode: live
  app_id: xxxxx
  username: xxxxx
  password: xxxxx
  signature: xxxxxxxx
  client_id: xxxxxxxx
  client_secret: xxxxxxxxx

PayKey已生成,但我需要通过API从后端向用户PayPal发送信用,而无需重定向到网页 还有其他方法,即时支付没有网页插件。

1 个答案:

答案 0 :(得分:0)

是的,您无法在任何一个环境中看到transactionID,因为还没有进行任何交易。

通过运行build_pay方法,您只构建了Pay对象并将其重定向到PayPal付款页。

要在客户付款后收到付款交易ID,您需要在将客户端重定向到付款页面之前使用您保存的相关PAY-KEY(AP -...)运行payment_details方法,这里是一个例子:

def self.get_payment_details(key_str)
  api = PayPal::SDK::AdaptivePayments.new
  pp_request = api.build_payment_details
  pp_request.pay_key = key_str
  api.payment_details(pp_request)
end

get_payment_details(PAY_KEY_GOES_HERE)

更新:

paymentExecStatus显示它处于创建状态,这意味着尚未付款。 在构建Pay对象并进行付款后,您是否将用户重定向到PayPal付款页?

如果没有,请将以下redirect_to行添加到您的代码中:

....
@response = @api.pay(@pay)
redirect_to api.payment_url(@response)