Ruby date format for PayPal Button Manager API - date

I can't get a date format that PayPal will accept via its PayPal Button manager API. "The start date specified is invalid." is the error.
Attempt 1: copy the string directly from the documentation:
"start_date": "2017-12-22T09:13:49Z"
I saw this https://github.com/paypal/PayPal-Ruby-SDK/issues/107 so tried
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)
I get the error #LongMessage="The start date specified is invalid."

I just verified following script using Ruby version 2.3.3 and its working fine. Following is the script i used in ruby console.
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)
Response: I, [2017-05-06T05:43:14.803444 #6541] INFO -- : Action: BMButtonSearch
I, [2017-05-06T05:43:14.803551 #6541] INFO -- : Request[post]: https://api-3t.sandbox.paypal.com/2.0/
I, [2017-05-06T05:43:27.057413 #6541] INFO -- : Response[200]: OK, Duration: 12.254s
**Please verify using Ruby 2.3.3. Screenshot has been attached. thanks!**
reference: https://github.com/paypal/buttonmanager-sdk-ruby

Related

Unable to get resonse from import contacts sendgrid API using python

Below is the call I am trying to make -
I used field mapping in below data -
data = {
"file_type": "csv",
"field_mappings": [
"_rf2_T",
"_rf0_T",
"_rf1_T",
"_rf10_T",
"w1_T",
"w45_T",
"w46_T",
"w44_T",
"w2_D",
"w43_T"
]
}
print("--data---",data)
response = sg.client.marketing.contacts.put(
request_body=data
)
#print("--data---",data)
print(response.status_code)
print(response.body)
print(response.headers)
and getting below error
{'errors': [{'field': 'contacts', 'message': 'at least one contact is required'}]}
I am expecting upload url and header from api call

Deployment via Wildfly native management api

I'm trying to deploy a web application on Wilfly 9 using the native management api. How does a correct request look like in that case? When using CLI, the command would be
$JBOSS_CLI --connect --command="deploy /path/to/war"
but it's not meeting the definition of the operation request syntax. I tried to deploy with a request
{
"address" => [("deployment" => "/path/to/war")],
"operation" => "deploy"
}
but get an error response back:
{
"outcome" => "failed",
"failure-description" => "WFLYCTL0216: Management resource '[(\"deployment\" => \"/path/to/war\")]' not found",
"rolled-back" => true
}
Ok, here's what I came up with:
The following cli command achieves the same result as deploy with file path as parameter:
/deployment=my_deployment:add(enabled=true,content[url=file:///path/to/war])
Translated in Java:
String address = ...
int port = ...
String user = ...
String pass = ...
Path file = ...
ModelNode request = new ModelNode();
request.get(ClientConstants.OP).set(ClientConstants.ADD);
request.get(ClientConstants.OP_ADDR).add("deployment", "my_deployment");
request.get("enabled").set(true);
request.get("content").add("url", file.toUri().toString());
try (ModelControllerClient conn = ModelControllerClient.Factory.create(address, port, new PasswordClientCallbackHandler(user, null, pass.toCharArray()))) {
ModelNode response = conn.execute(request);
Logger.getLogger(Test.class.getName()).info(response);
}

Salesforce Paypal Integration(PayFlow)

I am using Rest API to get security token using unique securityID and other parameters.Please suggest. I am using following code :
HttpRequest httpRequest = new HttpRequest();
httpRequest.setEndpoint('https://pilot-payflowpro.paypal.com');
String body = 'PARTNER=Paypal&PWD=pwd&VENDOR=abc&USER=abc&CREATESECURERTOKEN=Y&SECURETOKENID=9a9ea8208de1413abc3d60c86cb1f4ce&TRXTYPE=C&AMT=23.0&MODE=TEST';
httpRequest.setBody(body);
httpRequest.setMethod('GET');
Http htt = new hTTP();
HttpResponse httpRe = htt.send(httpRequest);
system.debug(httpRe.geTbody());
But I am getting following error : RESULT=2&PNREF=A7X06D187FF7&RESPMSG=Invalid tender
You are missing one parameter here while posting data to "https://pilot-payflowpro.paypal.com". You need to include TENDER=C in your request parameters.
Second, you need to replace the TRXTYPE=C to TRXTYPE=S because TRXTYPE=C indicates it'sa refund transaction but you are performing a sale transaction .
It should similar to the below :
NVP Request:
VENDOR=XXXXXXXXX&PARTNER=XXXXXXXXX&USER=XXXXXXXXX&PWD==XXXXXXXXX&AMT=12.72&TRXTYPE=S&TENDER=C&SECURETOKENID=wsw.big7jsa8la531f4x31ec3ssael7esef1.4521352289&CREATESECURETOKEN=Y
NVP Response:
RESULT=0
RESPMSG=Approved
SECURETOKEN=99UhUOS2ZWk6wDJn8kdNNeAZf
SECURETOKENID=wsw.big7jsa8la531f4x31ec3ssael7esef1**
Hope this helps you debug your issue .

google-api-client suddenly comes back with "invalid request"

I've been running Ruby scripts for weeks now using a Service Account, but today I'm getting an "Invalid Request" when I try to build the client using the following function:
def build_client(user_email)
client = Google::APIClient.new
client.authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => 'https://www.googleapis.com/auth/calendar',
:issuer => SERVICE_ACCOUNT_EMAIL,
:signing_key => Google::APIClient::KeyUtils.load_from_pkcs12(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret"),
:person => user_email
)
client.authorization.fetch_access_token!
return client
end
Is there a lifespan on Service Accounts? I tried creating another Service Account and using that but I get the same result:
Authorization failed. Server message: (Signet::AuthorizationError)
{
"error" : "invalid_request"
}
Stumped!
OK. I figured it out. It was all to do with the user_email. I was reading it from a file and forgot to chomp the linefeed off, so it was objecting to a mal-formed email address.

Magento SOAP 2 API Fatal error: Procedure 'login' not present

I am getting: Fatal error: Procedure 'login' not present in /chroot/home/mystore/mystore.com/html/lib/Zend/Soap/Server.php on line 832
This is where the error is coming from
$soap = $this->_getSoap();
ob_start();
if($setRequestException instanceof Exception) {
// Send SOAP fault message if we've catched exception
$soap->fault("Sender", $setRequestException->getMessage());
} else {
try {
$soap->handle($request);
} catch (Exception $e) {
$fault = $this->fault($e);
$soap->fault($fault->faultcode, $fault->faultstring);
Any Ideas on how to fix the error?
I had the same issue, and which I did to fix it was to go to System/Configuration/Magento Core API and set the value WS-I Compliance as 'No'.
I'm working with a WebService which consumes the Magento V2 API, I don't recall if I generate the web reference using this value as 'Yes'; I'm working with a WS C# using VS 2010.
I had similar problem and I did not want to change the API version. Deleting the WSDL cache helped me.
Run this to get the WSDL cache folder:
php -i | grep soap
From the result you can see that the WDSL cache is enabled and stored in /tmp:
soap
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Remove the cache and run it again:
sudo rm -rf /tmp/*
I found the clue in this article - http://artur.ejsmont.org/blog/content/php-soap-error-procedure-xxx-not-present