0

I'm using a simple Web API controller to accept a request from a client to process a payment. The Payflow payment request is started in a new task, and I immediately return a status to the client while I wait for the transaction to complete in my task.

However, in testing, if I send two requests back-to-back to my API, the second request will receive a null response from the SubmitTransaction method of the Payflownet API. Why is this happening?

Here is my method which is making the call

private NameValueCollection SubmitTransaction(NameValueCollection pfpParams)
{
    string transactionString = GetTransactionString(pfpParams);
    string pfpResponse = _pfNetApi.SubmitTransaction(transactionString, PayflowUtility.RequestId);
    return HttpUtility.ParseQueryString(pfpResponse);
}

And here is the value of transactionString that I'm passing to the SubmitTransaction method in both cases (dummy credit card info):

ACCT=4111111111111111&EXPDATE=0115&COMMENT1=&COMMENT2=&CVV2=123&NAME=Joshua Dixon&STREET=123 x st&TENDER=C&ZIP=12345&AMT=5.00&TRXTYPE=S&USER=test&PWD=xxxx&PARTNER=Verisign&VENDOR=test

Whenever I send a single request with that string, the response is correct and expected. However, whenever I send two asynchronous requests with that string, if the first hasn't completed, the second response is always null.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
Joshua Dixon
  • 205
  • 3
  • 11
  • Show your code, what have you tried so far – 123 456 789 0 Dec 17 '13 at 23:05
  • Okay, I just posted my method which makes the call. I've tested all of the surrounding code to be sure that everything is as expected. The pfpResponse string is always null, even when being sent a request formed in exactly the same way. – Joshua Dixon Dec 18 '13 at 14:46

1 Answers1

1

OP's co-worker, answering this in case anyone else has this problem.

This seems to be an issue with thread-safety. Though the documentation indicates otherwise, PayflowNETAPI.SubmitTransaction does not seem to be thread-safe. The problem was solved by using a new instance of PayflowNETAPI for each transaction.

Dirk Holsopple
  • 8,731
  • 1
  • 24
  • 37