【问题标题】:Accessing my paypal transaction list from the paypal Rest API从 paypal Rest API 访问我的 paypal 交易列表
【发布时间】:2015-07-14 14:41:36
【问题描述】:

我正在尝试从 paypal Rest API 访问我的交易列表。一世 想查看我发送和接收的所有付款,例如最近 3 次 周。

认为这可以通过 paypal REST api ("paypal-sdk-rest" gem 在红宝石中)。但是,我找不到确切的命令。我检查了 Paypal Rest API 参考 (https://developer.paypal.com/docs/api/) , 并且有一个“搜索交易”,但这似乎在 “计费协议”的标题。还有一个“搜索 发票”在发票标题下。但这些不是发票项目。我 只想要交易清单。

我是否使用了正确的 SDK?是否有另一个 REST api 可以做到这一点? 具体是什么命令?

【问题讨论】:

    标签: rest paypal


    【解决方案1】:

    Ruby 的官方 REST API SDK 位于:https://github.com/paypal/PayPal-Ruby-SDK

    它附带samples,可以帮助您快速入门。您可以按照有关如何运行示例或安装 sdk 的说明进行操作。

    以下是在 Payments API 中获取所有贝宝交易的示例:https://github.com/paypal/PayPal-Ruby-SDK/blob/master/samples/payment/all.rb

    # #GetPaymentList Sample
    # This sample code demonstrate how you can
    # retrieve a list of all Payment resources
    # you've created using the Payments API.
    # Note various query parameters that you can
    # use to filter, and paginate through the
    # payments list.
    # API used: GET /v1/payments/payments
    require 'paypal-sdk-rest'
    include PayPal::SDK::REST
    include PayPal::SDK::Core::Logging
    
    # ###Retrieve
    # Retrieve the PaymentHistory  by calling the
    # `all` method
    # on the Payment class
    # Refer the API documentation
    # for valid values for keys
    # Supported paramters are :count, :next_id
    @payment_history = Payment.all( :count => 5 )
    
    # List Payments
    logger.info "List Payment:"
    @payment_history.payments.each do |payment|
      logger.info "  -> Payment[#{payment.id}]"
    end
    

    【讨论】:

    • 这不会提取我的任何交易历史记录:<:sdk::rest::datatypes::paymenthistory:0x00000002325058> 我知道api 之所以有效,是因为我可以通过“Capture”类提取任意 transaction_id。这会提取信息,例如: Capture.find("6H858595U07730403")
    猜你喜欢
    • 1970-01-01
    • 2013-06-14
    • 2014-10-05
    • 1970-01-01
    • 2014-11-22
    • 2016-04-17
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多