我无法获得PayPal将通过其PayPal Button Manager API接受的日期格式。 “指定的开始日期无效。”是错误。
尝试1:直接从文档中复制字符串:
"start_date": "2017-12-22T09:13:49Z"
我看到了https://github.com/paypal/PayPal-Ruby-SDK/issues/107这么试过
strftime('%Y-%m-%dT%H:%M:%SZ') and utc.iso8601
start_date = "1980-02-19T00:37:04Z"
start_date = (DateTime.now - 10.years).utc.iso8601
start_date = (DateTime.now - 10.years).utc
@bm_build_button_search = @api.build_bm_button_search({ "start_date" => start_date })
# Make API call & get response
@bm_button_search_response = @api.BMButtonSearch(@bm_build_button_search)
@Errors=[#<PayPal::SDK::ButtonManager::DataTypes::ErrorType:0x007fa58b12e110 @ShortMessage="Invalid Argument", @LongMessage="The start date specified is invalid.", @ErrorCode="11998
(byebug) @bm_build_button_search.start_date.class
PayPal::SDK::Core::API::DataTypes::SimpleTypes::DateTime
So it looks like PayPal is fine with this DateTime format but when I call
@api.BMButtonSearch(@bm_build_button_search)
我收到错误@ LongMessage =“指定的开始日期无效。”
答案 0 :(得分:0)
我刚刚使用 Ruby版本2.3.3 验证了以下脚本,并且工作正常。以下是我在ruby控制台中使用的脚本。
Step1: install Paypal SDK
$ gem install paypal-sdk-buttonmanager
Step2:
require 'paypal-sdk-buttonmanager'
@api = PayPal::SDK::ButtonManager::API.new(
:mode => "sandbox", # Set "live" for production
:app_id => "APP-80W284485P519543T",
:username => "jb-us-seller_api1.paypal.com",
:password => "WX4WTU3S8MY44S7F",
:signature => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-
RWy" )
Step3:
start_date = "1980-02-19T00:37:04Z"
@bm_build_button_search = @api.build_bm_button_search({ "start_date" => start_date })
@bm_button_search_response = @api.BMButtonSearch(@bm_build_button_search)
回复:我,[2017-05-06T05:43:14.803444#6541]信息 - :行动:BMButtonSearch 我,[2017-05-06T05:43:14.803551#6541]信息 - :请求[帖子]:https://api-3t.sandbox.paypal.com/2.0/
I,[2017-05-06T05:43:27.057413#6541]信息 - :回应[200]:好的,持续时间:12.254s
**Please verify using Ruby 2.3.3. Screenshot has been attached. thanks!**