Phonegap filetransfer working in iPhone simulator but not on device - iphone

The following bit of code works fine in my iPhone simulator. I'm tried with IOS 5.1 using Cordova 1.6 and also tried with 1.7. My external hosts entry is configured to 127.0.0.1
This is the code:
function uploadPhoto(imageElement){
var options = new FileUploadOptions();
var options = new FileUploadOptions();
options.fileKey="file";
options.mimeType="image/jpeg";
options.fileName="carimage.jpg";
options.chunkedMode = true;
var params = new Object();
params.value1 = "Car";
params.value2 = "Used";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
console.log("Upload Photo");
ft.upload(
document.getElementById(imageElement).src,
"http://127.0.0.1:8080/claim/image",
win,
fail,
options,
true);
console.log("Done Uploading");
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
The simulator output in Xcode is:
2012-05-09 12:45:09.390 motorazzi[24964:13403] Multi-tasking -> Device: YES, App: YES
2012-05-09 12:48:28.421 motorazzi[24964:13403] [INFO] Upload Photo
2012-05-09 12:48:28.484 motorazzi[24964:13403] [INFO] Done Uploading
2012-05-09 12:48:40.662 motorazzi[24964:13403] [INFO] Code = 200
2012-05-09 12:48:40.662 motorazzi[24964:13403] [INFO] Response =
2012-05-09 12:48:40.663 motorazzi[24964:13403] [INFO] Sent = 1358
Which is fine, but using the device from Xcode, I get:
2012-05-09 12:51:40.537 motorazzi[885:707] Multi-tasking -> Device: YES, App: YES
2012-05-09 12:51:56.554 motorazzi[885:707] [INFO] Upload Photo
2012-05-09 12:51:56.654 motorazzi[885:707] [INFO] Done Uploading
2012-05-09 12:51:56.748 motorazzi[885:707] File Transfer Error: Could not connect to the server.
2012-05-09 12:51:56.798 motorazzi[885:707] [INFO] An error has occurred: Code = 3
2012-05-09 12:51:56.803 motorazzi[885:707] [INFO] upload error source http://127.0.0.1:8080/claim/image
2012-05-09 12:51:56.813 motorazzi[885:707] [INFO] upload error target file:///var/mobile/Applications/699481A7-C598-43BA-BDCA-962DEF925EE5/tmp/photo_020.jpg
On my server log I can see that the device is not connecting at all. Is there anything that I may be doing wrong, or should be checking?

When you are running on the device the IP address 127.0.0.1 or "localhost" is the device itself. That is why you are not hitting your server. You will have to put in the host name or IP address of the server that is hosting your upload script.
Also, make sure you whitelist the server in your plist or it will get rejected.

Related

unable to upload folder with files using protractor for web application testing

Iam using protractor for testing my web application that has a button to popup window to open file explorer where I need to select a folder that contains 5 files that needs to be uploaded.
I have the code as
''''
var fileUpload = '/home/indu/jpg';
require("./logger");
console.file("./test.log");
var absolutePath = path.resolve(__dirname, fileUpload);
fs.readdir(absolutePath, (err, files) => {
for (i = 0; i < files.length; i++) {
filelst.push(fileUpload +"/"+files[i]);
}
console.log("fuull is ",filelst);
});
var remote = require('/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/remote');
browser.setFileDetector(new remote.FileDetector());
var absolutePath = path.resolve(__dirname, fileUpload);
console.log("value of absolutePath",absolutePath);
var fileElem = element(by.css('input[type="file"]'));
// Unhide file input
browser.executeScript("arguments[0].style.visibility = 'visible'; arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; arguments[0].style.opacity = 1", fileElem.getWebElement());
fileElem.sendKeys(absolutePath);
when I execute I get below error
Failed: unexpected alert open: {Alert text : Error during upload, redirecting to login page .... }
(Session info: chrome=96.0.4664.110): Error during upload, redirecting to login page ....
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'indu-Latitude-E6420', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-91-generic', java.version: '1.8.0_312'
Driver info: driver.version: unknown
I have tried on windows10 as well as ubuntu 18.04.05 and on both I get chrome driver info version unknown error. I have searched for this error and tried suggested solution in
Unable to start e2e tesing in angular project
but that didnt work too.
Pls suggest
I resolved the problem by a
browser.wait(ExpectedConditions.elementToBeClickable(buttonelementlocator),
100, 'Element is not clickable.').then( () => {
uploadfiles();
});
function uploadfiles(){
var shell = require('shelljs');
var exec = require('child_process').execFile;
// uploadfile.bat contains the autoit exe to upload the files and handle
chromebrowser alert
var task = shell.exec('uploadfile.bat');
if (task.code !== 0) {
console.log("execute AutoIt script fail: " + task.stdout);
shell.exit(1);
}
}

Selenium WebDriver, when loading an HTTPS website, closes and reopens browser and does not even attempt to interact with the DOM

Selenium WebDriver (run from Eclipse Oxygen.3a Release (4.7.3a)) seems to be unable to handle any HTTPS website.
By that I mean this: upon loading the page (regardless of whether it redirects or not, tried with gitlab and AWS logon sites)
Logon page loads properly (no SSL certificate issues, any redirect happens just fine), yet Selenium doesn't do anything (debug mode shows it's not even trying to execute the logon code)
It times out (browserWaitTimeout=15) and closes/reopens the logon page
This happens until the 4th time, upon which Selenium finally reaches my logon code (a breakpoint I set there is finally hit), but this happens between browser page closing and reopening, thus it never detects the DOM and fails.
And the most frustrating thing is, console shows NO ERRORS.
Here: Chrome:
Jul 03, 2019 8:40:44 AM com.fincad.vcr.qa.support.WebDriverFactory createWebDriver
INFO: Web driver is created successfully
Jul 03, 2019 8:40:55 AM com.fincad.vcr.qa.support.WebDriverFactory quitWebDriver
INFO: Web driver quits successfully
That's it, as in literally it (notice the 15 second gap? That's browserWaitTimeout).
a) I tried FF, where I saw errors from Marionette:
1562172157538 Marionette INFO Listening on port 56792
1562172157572 addons.xpi-utils DEBUG Successfully read XPI database
1562172157603 addons.manager DEBUG Registering upgrade listener for
formautofill#mozilla.org
Jul 03, 2019 9:42:37 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Jul 03, 2019 9:42:38 AM com.fincad.vcr.qa.support.WebDriverFactory createWebDriver
INFO: Web driver is created successfully
1562172170219 Marionette INFO Stopped listening on port 56792
1562172170243 addons.xpi DEBUG Calling bootstrap method shutdown on webcompat#mozilla.org version 4.0.0
1562172170249 addons.xpi DEBUG Calling bootstrap method shutdown on screenshots#mozilla.org version 37.1.0
1562172170253 addons.xpi DEBUG Calling bootstrap method shutdown on fxmonitor#mozilla.org version 3.0
1562172170254 addons.xpi DEBUG Calling bootstrap method shutdown on formautofill#mozilla.org version 1.0
[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 21788, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 21788, Chrome_Chi[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 6644, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 6644, Chrome_ChildThread] WAR[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 17844, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 17844, Chrome_ChildThread] WARNING: pipe er[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1560988628/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Chi###!!! [Parent][MessageChannel] Error: (msgtype=0x1F0099,name=PBrowser::Msg_UpdateNativeWindowHandle) Closed channel: cannot send/recv
I googled and people mentioned it's due to outdated FF driver, so I upgraded, but it didn't do any good (same errors appear). And in IE it's like Chrome: no error or warning msg at all.
My drivers are these:
Selenium WebDriver: 3.14.0 (32-bit)
geckodriver 0.24.0 (32-bit)
chromedriver 74.0.3729.6 (32-bit)
IEDriverServer 3.8.0 (32-bit)
And my browsers:
Chrome browser: 75.0.3770.100
FF browser: 67.0.4
IE browser: 11.557.17763
This is how I create my drivers:
private static void createFirefoxDriver() {
setCapability("firefox");
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
GeckoDriverService service = builder.build();
FirefoxOptions options = new FirefoxOptions(capabilities);
// Read the default firefox profile
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myProfile = profile.getProfile("default");
// Disable the web page from asking if really want to leave
myProfile.setPreference("dom.disable_beforeunload", true);
options.setProfile(myProfile);
driver = new FirefoxDriver(service, options);
}
private static void createChromeDriver() {
setCapability("chrome");
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
ChromeDriverService service = builder.build();
ChromeOptions options = new ChromeOptions();
options.merge(capabilities);
driver = new ChromeDriver(service, options);
}
This is how I load the URL (local webdriver):
private static void createLocalWebDriver() {
String browser = ConfigParser.getBrowser();
LOGGER.info("Target Browser: " + browser);
switch (browser) {
case "firefox":
System.setProperty("webdriver.gecko.driver", ConfigParser.getGeckoDriver());
System.out.println("GeckoDriver on: " + ConfigParser.getGeckoDriver());
createFirefoxDriver();
break;
case "chrome":
System.setProperty("webdriver.chrome.driver", ConfigParser.getChromeDriver());
System.out.println("ChromeDriver on: " + ConfigParser.getChromeDriver());
createChromeDriver();
break;
case "ie":
System.setProperty("webdriver.ie.driver", ConfigParser.getIEDriverServer());
System.out.println("IEDriver on: " + ConfigParser.getIEDriverServer());
createIEDriver();
break;
default:
LOGGER.warning("Unsupported Browser: " + browser);
break;
}
}
private static void createFirefoxDriver() {`enter code here`
setCapability("firefox");
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
GeckoDriverService service = builder.build();
FirefoxOptions options = new FirefoxOptions(capabilities);
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myProfile = profile.getProfile("default");
myProfile.setPreference("dom.disable_beforeunload", true);
options.setProfile(myProfile);
driver = new FirefoxDriver(service, options);
}
private static void createChromeDriver() {
setCapability("chrome");
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
ChromeDriverService service = builder.build();
ChromeOptions options = new ChromeOptions();
options.merge(capabilities);
driver = new ChromeDriver(service, options);
}
private static void createIEDriver() {
setCapability("ie");
InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder();
InternetExplorerDriverService service = builder.build();
InternetExplorerOptions options = new InternetExplorerOptions(capabilities);
driver = new InternetExplorerDriver(service, options);
CommonJS.executeScript(driver, "window.localStorage.clear();");
CommonJS.executeScript(driver, "window.sessionStorage.clear();");
}
private static void setCapability(String browser) {
capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, true);
if (browser.equalsIgnoreCase("ie")) {
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
capabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, ConfigParser.getAppUrl());
} else if (browser.equalsIgnoreCase("chrome")) {
ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
}
}
Sorry for all the code, but I'm sure I'll be asked about those details, hence my putting there.
Long story short:
This only happens with HTTPS URL's
Non HTTPS URL's work just fine
It's not an SSL certificate issue otherwise I would have seen it on the screen "This connection is untrusted".
It was a problem at page load code. Found a section that was explicitly expecting HTTP only, thus refusing to load any HTTPS URL.

Message 'No configuration setting found for key' Akka-Http

In my project, I can compile and run without problems, my project is a project in akka-http and I provide services of type json, but when calling the service this error appears:
> run
[info] Running net.claritysales.api.Main
[DEBUG] [11/02/2017 11:08:32.360] [run-main-0] [EventStream(akka://default)] logger log1-Logging$DefaultLogger started
[DEBUG] [11/02/2017 11:08:32.361] [run-main-0] [EventStream(akka://default)] Default Loggers started
[DEBUG] [11/02/2017 11:08:33.253] [run-main-0] [AkkaSSLConfig(akka://default)] Initializing AkkaSSLConfig extension...
[DEBUG] [11/02/2017 11:08:33.258] [run-main-0] [AkkaSSLConfig(akka://default)] buildHostnameVerifier: created hostname verifier: com.typesafe.sslconfig.ssl.DefaultHostnameVerifier#5160a3bd
[DEBUG] [11/02/2017 11:08:34.687] [default-akka.actor.default-dispatcher-5] [akka://default/system/IO-TCP/selectors/$a/0] Successfully bound to /127.0.0.1:9000
[DEBUG] [11/02/2017 11:08:40.607] [default-akka.actor.default-dispatcher-5] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted
[ERROR] [11/02/2017 11:08:41.795] [default-akka.actor.default-dispatcher-5] [akka.actor.ActorSystemImpl(default)] Error during processing of request: 'No configuration setting found for key 'c
ors''. Completing with 500 Internal Server Error response.
[ERROR] [11/02/2017 11:08:43.467] [default-akka.actor.default-dispatcher-5] [akka.actor.ActorSystemImpl(default)] Error during processing of request: 'No configuration setting found for key 'c
ors''. Completing with 500 Internal Server Error response.
[DEBUG] [11/02/2017 11:09:49.232] [default-akka.actor.default-dispatcher-5] [akka://default/user/StreamSupervisor-0/flow-1-0-unknown-operation] Aborting tcp connection to /127.0.0.1:64741 beca
use of upstream failure: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
since insomnia this appears:
My application.conf is:
akka {
loglevel = DEBUG
}
http {
interface = "localhost"
interface = ${?HTTP_INTERFACE}
port = 9000
port = ${?HTTP_PORT}
}
database = {
cs {
profile = "slick.jdbc.PostgresProfile$"
db {
url = "jdbc:postgresql://localhost:5432/cs2_company"
url = ${?PSQL_URL}
user = "postgres"
user = ${?PSQL_USER}
password = "qwerty"
password = ${?PSQL_PASSWORD}
}
}
}
I read my configuration from a trait called Config, it has:
package net.cs.api.utils
import com.typesafe.config.ConfigFactory
trait Config {
private val config = ConfigFactory.load()
private val httpConfig = config.getConfig("http")
private val databaseConfig = config.getConfig("database.cs")
val httpHost = httpConfig.getString("interface")
val httpPort = httpConfig.getInt("port")
val jdbcUrl = databaseConfig.getString("db.url")
val dbUser = databaseConfig.getString("db.user")
val dbPassword = databaseConfig.getString("db.password")
}
additionally I have another application.conf file in the test resources, because I want to perform the tests with H2 and execute the application with Postgres
My application.conf for the test is:
akka {
loglevel = WARNING
}
database = {
cs {
profile = "slick.jdbc.H2Profile$"
db {
driver = "org.h2.Driver"
url = "jdbc:h2:mem:cs2_company;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE;DATABASE_TO_UPPER=false"
url = ${?PSQL_TEST_URL}
user = "sales"
user = ${?PSQL_TEST_USER}
password = "sales"
password = ${?PSQL_TEST_PASSWORD}
}
}
}
What is the error? any help I would appreciate it. Thanks!
it seems that something was looking for a key called cors in the configuration and can not find it, in my configuration I added:
cors.allowed-origin = "*"
everything works!

Protractor/Typescript : uncaught InvalidElementStateError

I am writing my first protractor test in Typescript..Here is PageObjectModel class
HomePagePOM.ts
export module HomePage{
export class HomePagePom {
helloTextInput = element(by.model("yourName"));
helloTextDisplay = element(by.css("ng-binding"));
launchPage(url: string): void {
browser.get(url);
console.log("success");
browser.waitForAngular();
}
typeHello(text: string): void {
this.helloTextInput.getWebElement().click();
this.helloTextInput.getWebElement().sendKeys(text);
}
getHelloText() : string {
return this.helloTextDisplay.getWebElement().valueOf();
}
}
}
and my spec class HomePageSpec.ts
import id = require("chai");
import hpp = require("./HomePagePOM");
import HomePage = hpp.HomePage;
var expect = id.expect;
var assert = id.assert;
var should = id.should;
describe("Launch the home page", () => {
var homePagePom = new HomePage.HomePagePom();
it("Launch should be successful", () => {
homePagePom.launchPage("https://www.angularjs.org");
assert.equal("test", "test", "test is success");
});
it("Type Hello Text successfully", () => {
homePagePom.typeHello("Arun");
//assert.equal("test", "test", "test is success");
});
it("Type Hello Text successfully", () => {
assert.equal(homePagePom.getHelloText(), "Hello Arun!", " Hello text typed and retrieved successfully");
});
});
when I run the test, I get this error as below
C:\VisualStudio2013\SampleAutomationPOC\SampleAutomationPOC>protractor conf.js
[23:02:59] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[23:02:59] I/launcher - Running 1 instances of WebDriver
[mochawesome] Generating report files...
Launch the home page
success
1) Launch should be successful
2) Type Hello Text successfully
3) Type Hello Text successfully
0 passing (4s)
3 failing
1) Launch the home page Launch should be successful:
Uncaught InvalidElementStateError: invalid element state: Failed to execute 'replace' on 'Location': '' is not a valid URL.
(Session info: chrome=51.0.2704.103)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any
stacktrace information)
Command duration or timeout: 6 milliseconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ION3076W7LT-3', ip: '10.210.94.178', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1
cdabed0983e7c4), userDataDir=C:\Users\ion3076\AppData\Local\Temp\scoped_dir10008_16863}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasT
ouchScreen=false, version=51.0.2704.103, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webSt
orageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 70409fcf7ae2dfd5a1058292d0c30684
I have 2 problem
1. obviously the error
2. when the script executes the angularjs.org website doesn't load all the components completely. Meaning some of the components are blank and the loading looks completed. (the object i am interacting is not shown on the page). So while the script is running i tried to hit the refresh button quickly twice and then the page loaded completely. Manually launching everything looks fine.. Not sure what is causing the issue.
The object I am interacting is unique as far as i know..
Any clues to help me out? enter code here
thanks in advance.
Never mind ..I figured out the answer. For prep reasons i thought of launching the blank browser, I added a line of code browser.get('') in the conf.js under onPrepare() function section. That is causing the issue as ' ' invalid url. I removed it and now it goes through smooth.. long day...and missed to catch the obvious.
Thanks.

Stream was not Readable for PayPalRest API

This occurs in the Sandbox or production. In the sandbox if I enter in a Visa of 4111111111111111 with a code, and exp date... When I hit the payment.Creat(token) line, an exception is thrown, "Stream was not readable". If I put in some other CC number like 4234567890123456 the payment works fine. In production, if I use that 4234... I get the stream was not readable error. I understand test cards do not always work, but I expect back a Credit Card invalid response. The problem I have is that some of my customers are getting the stream error.... If I put in a real CC in production, it works fine.. but if i change 1 number I get the invalid card error.... So sometimes it sends it back correctly, other times it is the Stream error... I recently update the package to latest and greatest API using Nuget, but does anyone else have any suggestions?
Here is my relevant code
try
{
var token = GetAPIToken();
var creditCard = new CreditCard();
creditCard.number = req.CardNumber;
creditCard.expire_month = req.ExpMonth;
creditCard.expire_year = req.ExpYear;
creditCard.first_name = req.FirstName;
creditCard.last_name = req.LastName;
creditCard.type = req.CardType;
creditCard.payer_id = req.UserId.ToString();
creditCard.cvv2 = req.SecurityCode;
creditCard.billing_address = new Address()
{
line1 = req.Address1,
city = req.City,
state = req.State,
postal_code = req.ZipCode,
country_code = "US"
};
var payment = new Payment();
payment.intent = "sale";
payment.payer = new Payer();
payment.transactions = new List<Transaction>();
var t = new Transaction()
{
description = req.Description,
amount = new Amount()
{
total = req.TotalPayment.ToString("N2"),
currency = "USD",
},
};
t.item_list = new ItemList();
t.item_list.items = new List<Item>();
t.item_list.items.Add(new Item()
{
name = req.Description,
quantity = "1",
price = req.TotalPayment.ToString("N2"),
currency = "USD",
});
payment.transactions.Add(t);
payment.payer.funding_instruments = new List<FundingInstrument>();
payment.payer.payment_method = "credit_card";
var fundingInstrument = new FundingInstrument();
fundingInstrument.credit_card = creditCard;
payment.payer.funding_instruments.Add(fundingInstrument);
var pay = payment.Create(token);
if (req.PaymentOption != PayOption.UsePayPal && pay.state == PayPalStateApproved
&& pay.transactions.Any() && pay.transactions[0].related_resources.Any()
&& pay.transactions[0].related_resources[0].sale != null
&& !String.IsNullOrEmpty(pay.transactions[0].related_resources[0].sale.id))
{
resp.TransactionID = pay.transactions[0].related_resources[0].sale.id;
}
else
{
resp.Status = Status.Error;
resp.Messages.Add(new Message { Code = "paypal", Text = pay.state });
}
}
catch (Exception ex)
{
var err = CheckPayPalError(ex);
resp.Messages.Add(new Message { Code = "paypal", Text = String.IsNullOrEmpty(err) ? ex.Message : err });
resp.Status = Status.Error;
}
return resp;
Here are the log entries, the first is if Retry is set to > 0, the second is with no retry
2013-08-29 09:41:45,852 [33] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK/rest-sdk-dotnet 0.7.3 ;lang=DOTNET;v=4.0.30319.18052;bit=64;os=Windows 7 6.1.7601.65536;
2013-08-29 09:41:45,852 [33] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:a781e6bb-c0b0-4f06-abf8-1202dbc17a59
2013-08-29 09:41:45,920 [33] DEBUG PayPal.Manager.ConnectionManager [(null)] {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4234567890123456","type":"visa","expire_month":5,"expire_year":2015,"cvv2":"123","first_name":"MIckey","last_name":"Keenan","billing_address":{"line1":"123 Main St","city":"Denver","country_code":"US","postal_code":"80210","state":"CO"},"payer_id":"205"}}]},"transactions":[{"amount":{"currency":"USD","total":"4.75"},"description":"WFS Lunch Order","item_list":{"items":[{"quantity":"1","name":"WFS Lunch Order","price":"4.75","currency":"USD"}]}}]}
2013-08-29 09:41:49,505 [33] ERROR PayPal.Manager.ConnectionManager [(null)] Error Response: {"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"2520071cde1ca"}
2013-08-29 09:41:49,506 [33] INFO PayPal.Manager.ConnectionManager [(null)] Got InternalServerError status code from server
2013-08-29 09:41:49,507 [33] ERROR PayPal.Exception.PayPalException [(null)] Exception in HttpConnection Execute: Stream was not readable.
PayPal.Exception.PayPalException: Exception in HttpConnection Execute: Stream was not readable. ---> System.ArgumentException: Stream was not readable.
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
at System.IO.StreamReader..ctor(Stream stream)
at PayPal.HttpConnection.Execute(String payLoad, HttpWebRequest httpRequest)
--- End of inner exception stack trace ---
Here is the second
2013-08-29 09:44:27,685 [16] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK/rest-sdk-dotnet 0.7.3 ;lang=DOTNET;v=4.0.30319.18052;bit=64;os=Windows 7 6.1.7601.65536;
2013-08-29 09:44:27,686 [16] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:1d5c68e5-4b4b-4876-8bf4-3b9f64d0afb6
2013-08-29 09:44:27,753 [16] DEBUG PayPal.Manager.ConnectionManager [(null)] {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4234567890123456","type":"visa","expire_month":5,"expire_year":2015,"cvv2":"123","first_name":"MIckey","last_name":"Keenan","billing_address":{"line1":"123 Main St","city":"Denver","country_code":"US","postal_code":"80210","state":"CO"},"payer_id":"205"}}]},"transactions":[{"amount":{"currency":"USD","total":"4.75"},"description":"WFS Lunch Order","item_list":{"items":[{"quantity":"1","name":"WFS Lunch Order","price":"4.75","currency":"USD"}]}}]}
2013-08-29 09:44:28,847 [16] ERROR PayPal.Manager.ConnectionManager [(null)] Error Response: {"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"465701e606a56"}
2013-08-29 09:44:28,848 [16] INFO PayPal.Manager.ConnectionManager [(null)] Got InternalServerError status code from server
2013-08-29 09:44:28,850 [16] ERROR PayPal.Exception.PayPalException [(null)] Exception in HttpConnection Execute
PayPal.Exception.PayPalException: Exception in HttpConnection Execute
We sometimes see issue with the Test Card 4111xxx in sandbox and are investigating the fix for the same. Hence use the other Test card in sandbox for your testing.
Reg the stream read error, will test the provided code and update back.
Issue has been fixed in core SDK. Fix is available in branch https://github.com/paypal/sdk-core-dotnet/tree/fix-log4net-stream. Please see https://github.com/paypal/rest-api-sdk-dotnet/issues/10 for more details.
After talking with PayPal support about this same issue: apparently even in the Sandbox, if a credit card is used too many times it will be blocked. They suggested trying other fake card numbers, and referred me to this site for generating them:
http://www.fakenamegenerator.com/
Using cards generated there has been working for me.