public string Verify(string transactionId) { PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway( CommerceConfig.PayPalStandardUrl, CommerceConfig.PayPalStandardEmailAddress, CommerceConfig.PayPalStandardPDTId); gateway.TransactionId = transactionId; return(gateway.ValidatePDT()); }
public string Verify(string ipnForm) { PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway( CommerceConfig.PayPalStandardUrl, CommerceConfig.PayPalStandardEmailAddress, CommerceConfig.PayPalStandardPDTId); gateway.IPNForm = ipnForm; return(gateway.ValidateIPN()); }
private void HandleRequest() { if (transactionId.Length == 0) { WebUtils.SetupRedirect(this, lastResortRedirectUrl); return; } try { //Log the querystring in case we have to investigate //Logger.Information(Request.QueryString.ToString()); transactionId = HttpUtility.UrlDecode(transactionId); custom = HttpUtility.UrlDecode(custom); string pdtResponse = Verify(transactionId); if (pdtResponse.StartsWith("SUCCESS")) { string redirectUrl = string.Empty; Guid logGuid = Guid.Empty; if (custom.Length == 36) { logGuid = new Guid(custom); } PayPalLog standardCheckoutLog = new PayPalLog(logGuid); if ((standardCheckoutLog != null) && (standardCheckoutLog.PDTProviderName.Length > 0)) { PayPalPDTHandlerProvider provider = PayPalPDTHandlerProviderManager.Providers[standardCheckoutLog.PDTProviderName]; if (provider != null) { redirectUrl = provider.HandleRequestAndReturnUrlForRedirect( pdtResponse, PayPalStandardPaymentGateway.GetPDTValues(pdtResponse), transactionId, standardCheckoutLog); if (redirectUrl.Length > 0) { WebUtils.SetupRedirect(this, redirectUrl); return; } else { // no redeirectUrl returned from provider //TODO: what? log it? WebUtils.SetupRedirect(this, lastResortRedirectUrl); return; } } else { // provider not found //log it PayPalLog unhandledLog = new PayPalLog(); unhandledLog.ProviderName = "unhandled"; unhandledLog.RawResponse = pdtResponse; unhandledLog.Save(); log.Info("invalid ptd request no valid provider found " + Request.Url.ToString()); WebUtils.SetupRedirect(this, lastResortRedirectUrl); return; } } else { // provider not specified on StandardCheckoutLog //TODO: what? log it? PayPalLog unhandledLog = new PayPalLog(); unhandledLog.ProviderName = "unhandled"; unhandledLog.RawResponse = pdtResponse; unhandledLog.Save(); log.Info("invalid ptd request no valid provider found " + Request.Url.ToString()); WebUtils.SetupRedirect(this, lastResortRedirectUrl); return; } } } catch (Exception ex) { log.Error(ex); //TODO: show generic error on the page } }