Paypal の Payflow ホスト ページで問題が発生しています。トークンが見つからないというエラー メッセージが表示されます。私の問題は安全なトークン ID だと思います。コードでセキュア トークン ID を作成しましたが、PayPal への要求でこれを渡す方法がわかりません。0 の応答とトークンが返されますが、失敗した場合はホストされたページにリダイレクトされます。私は広範囲に検索しましたが、私の問題に対する答えが見つからないようです。私はhttps://developer.paypal.com/docs/classic/payflow/gs_ppa_hosted_pa ges/ のペイパル ガイドを使用して、 これを処理しています。どんな助けでも大歓迎です。以下は私のコードです
//Controller that gets some data from a database table and passes it to the paypal utility class
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult RedirectInstruct(PayPalModel Submit)
{
bool recordRetrieved = false;
bool secureTokenRetrieved = false;
string orderId = "A3420-789632-15115151935";
string secureToken = "";
string secureTokenId = "";
string[,] InvoiceArray = new string[9, 2];
dbConnect = new SQLDatabaseUtility(orderId);
//Here I get some data from a database table that is used as the information passed to the inventor object
recordRetrieved = dbConnect.QryCustOrderDetails();
if (recordRetrieved)
{
InvoiceArray = dbConnect.RetrieveCustOrder();
paymentProcessing = new PaymentProcessingUtility(InvoiceArray);
//Here I call the method in the paypal utility class to get the secure token
paymentProcessing.GetSecureToken();
secureToken = paymentProcessing.PassSecureToken();
secureTokenId = paymentProcessing.PassSecureTokenId();
if (secureTokenRetrieved)
{
//Here I insert the token information into the url string and then redirect user to paypal website
string url = "https://payflowlink.paypal.com?MODE=TEST&SECURETOKENID=" + secureTokenId + "&SECURETOKEN=" + secureToken;
Response.Redirect(url);
}
else
{
//secure token retrieval failed
}
}
//Method in the paypal utility class that creates the securitytokenid and gets the security token from paypal
public void GetSecureToken()
{
decimal total = 0;
string licenseNo = "";
string orderID = "";
string requestType = "";
//set the values
orderID = InvoiceArray[0, 1];
total = Convert.ToDecimal(InvoiceArray[8, 1]);
requestType = InvoiceArray[2, 1];
//Here I create the securitytokenid
Guid id = Guid.NewGuid();
SECURETOKENID = Convert.ToString(id).Replace("-", "");
// create the user object
UserInfo User = new UserInfo("myuserid", "vender",
"partner", "password");
// Create the Payflow Connection data object with the required connection details.
PayflowConnectionData Connection = new PayflowConnectionData();
// Create a new Invoice data object with the Amount, Billing Address etc. details.
Invoice Inv = new Invoice();
//Here I place some transaction details into the inventory object
Currency Amt = new Currency(total, "USD");
Inv.Amt = Amt;
Inv.InvoiceDate = DateTime.Now.ToShortDateString();
Inv.Comment1 = licenseNo;
Inv.CustRef = orderID;
Inv.OrderDesc = requestType;
//create a new express checkout request
ECSetRequest setRequest = new ECSetRequest(ConfigurationManager.AppSettings["ReturnURL"], ConfigurationManager.AppSettings["CancelURL"]);
PayPalTender Tender = new PayPalTender(setRequest);
// Create a new Auth Transaction.
SaleTransaction Trans = new SaleTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId);
// Submit the Transaction
Response Resp = Trans.SubmitTransaction();
// Display the transaction response parameters.
if (Resp != null)
{
// Get the Transaction Response parameters.
TransactionResponse TrxnResponse = Resp.TransactionResponse;
ExpressCheckoutResponse eResponse = Resp.ExpressCheckoutSetResponse;
if ((TrxnResponse != null) && (eResponse != null))
{
//get the token
SECURETOKEN = eResponse.Token;
//Below I have tested to see if the requestid or correlationid is the securetokenid I need...
//SECURETOKENID = Trans.Response.RequestId;
//SECURETOKENID = Trans.Response.TransactionResponse.CorrelationId;
}
}
}
//Here I am passing the values back to the calling class
public string PassSecureToken()
{
return SECURETOKEN;
}
public string PassSecureTokenId()
{
return SECURETOKENID;
}