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.

4

1 回答 1

1

OP的同事,回答这个问题以防其他人有这个问题。

这似乎是线程安全的问题。尽管文档另有说明,PayflowNETAPI.SubmitTransaction但似乎不是线程安全的。通过为每笔交易使用新的 PayflowNETAPI 实例解决了这个问题。

于 2013-12-18T17:35:13.980 回答