/// <summary> /// Initializes the controller. /// </summary> private void Initialize() { var provider = GatewayContext.Payment.GetProviderByKey(Constants.PayPal.GatewayProviderSettingsKey); if (provider == null) { var nullRef = new NullReferenceException( "PayPalPaymentGatewayProvider is not activated or has not been resolved."); MultiLogHelper.Error <PayPalExpressApiController>( "Failed to find active PayPalPaymentGatewayProvider.", nullRef, GetExtendedLoggerData()); throw nullRef; } _paymentMethod = provider.GetPaymentGatewayMethodByPaymentCode(Constants.PayPal.PaymentCodes.ExpressCheckout) as PayPalExpressCheckoutPaymentGatewayMethod; if (_paymentMethod == null) { var nullRef = new NullReferenceException("PayPalExpressCheckoutPaymentGatewayMethod could not be instantiated"); MultiLogHelper.Error <PayPalExpressApiController>("PayPalExpressCheckoutPaymentGatewayMethod was null", nullRef, GetExtendedLoggerData()); throw nullRef; } }
/// <summary> /// Initializes the controller. /// </summary> private void Initialize() { var provider = GatewayContext.Payment.GetProviderByKey(Constants.PayPal.GatewayProviderSettingsKey) as PayPalPaymentGatewayProvider; if (provider == null) { var nullRef = new NullReferenceException( "PayPalPaymentGatewayProvider is not activated or has not been resolved."); MultiLogHelper.Error <PayPalExpressController>( "Failed to find active PayPalPaymentGatewayProvider.", nullRef, GetExtendedLoggerData()); throw nullRef; } // instantiate the service _paypalApiService = new PayPalApiService(provider.ExtendedData.GetPayPalProviderSettings()); var settings = provider.ExtendedData.GetPayPalProviderSettings(); _successUrl = settings.SuccessUrl; _cancelUrl = settings.CancelUrl; _deleteInvoiceOnCancel = settings.DeleteInvoiceOnCancel; _paymentMethod = provider.GetPaymentGatewayMethodByPaymentCode(Constants.PayPal.PaymentCodes.ExpressCheckout) as PayPalExpressCheckoutPaymentGatewayMethod; if (_paymentMethod == null) { var nullRef = new NullReferenceException("PayPalExpressCheckoutPaymentGatewayMethod could not be instantiated"); MultiLogHelper.Error <PayPalExpressController>("PayPalExpressCheckoutPaymentGatewayMethod was null", nullRef, GetExtendedLoggerData()); throw nullRef; } }