public void Setup() { _services = new ServiceCollection() .BuildServiceProvider(); _builder = new DefaultInvoiceBuilder(_services); }
public VehicleReadySignalHandler( IMemory memory, IInvoiceBuilder invoiceBuilder) { _memory = memory; _invoiceBuilder = invoiceBuilder; }
public static IInvoiceBuilder AddMellatCumulativeAccounts(this IInvoiceBuilder builder, IEnumerable <MellatCumulativeDynamicAccount> accounts) { if (accounts == null) { throw new ArgumentNullException(nameof(accounts)); } if (!accounts.Any()) { throw new ArgumentException("Accounts cannot be an empty collection.", nameof(accounts)); } List <MellatCumulativeDynamicAccount> allAccounts = null; builder.ChangeProperties(properties => { if (properties.ContainsKey(MellatHelper.CumulativeAccountsKey)) { allAccounts = (List <MellatCumulativeDynamicAccount>)properties[MellatHelper.CumulativeAccountsKey]; } else { allAccounts = new List <MellatCumulativeDynamicAccount>(); properties.Add(MellatHelper.CumulativeAccountsKey, allAccounts); } allAccounts.AddRange(accounts); }); return(builder); }
public static IInvoiceBuilder AddMellatCumulativeAccount(this IInvoiceBuilder builder, long subServiceId, long amount, long payerId) { return(AddMellatCumulativeAccounts(builder, new List <MellatCumulativeDynamicAccount> { new MellatCumulativeDynamicAccount(subServiceId, amount, payerId) })); }
public static IInvoiceBuilder SetMellatMobileNumber(this IInvoiceBuilder builder, string mobileNumber) { return(SetMellatAdditionalData(builder, new MellatGatewayAdditionalDataRequest { MobileNumber = mobileNumber })); }
/// <summary> /// Adds or updates the given dictionary to the properties of the invoice. /// </summary> /// <param name="builder"></param> /// <param name="properties"></param> public static IInvoiceBuilder AddOrUpdateProperties(this IInvoiceBuilder builder, IDictionary <string, object> properties) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (properties == null) { throw new ArgumentNullException(nameof(properties)); } ChangeProperties(builder, invoiceProperties => { foreach (var data in properties) { if (invoiceProperties.ContainsKey(data.Key)) { invoiceProperties[data.Key] = data.Value; } else { invoiceProperties.Add(data.Key, data.Value); } } }); return(builder); }
/// <summary> /// Adds or updates the given dictionary to the additional data of the invoice. /// </summary> /// <param name="builder"></param> /// <param name="additionalData"></param> public static IInvoiceBuilder AddOrUpdateAdditionalData(this IInvoiceBuilder builder, IDictionary <string, object> additionalData) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (additionalData == null) { throw new ArgumentNullException(nameof(additionalData)); } ChangeAdditionalData(builder, invoiceAdditionalData => { foreach (var data in additionalData) { if (invoiceAdditionalData.ContainsKey(data.Key)) { invoiceAdditionalData[data.Key] = data.Value; } else { invoiceAdditionalData.Add(data.Key, data.Value); } } }); return(builder); }
/// <summary> /// Contains extra functions for Mellat Gateway. /// </summary> /// <param name="builder"></param> /// <param name="configureMellatInvoiceBuilder">Helps to build the extra functions of Mellat Gateway.</param> public static IInvoiceBuilder UseMellat(this IInvoiceBuilder builder, Action <IMellatGatewayInvoiceBuilder> configureMellatInvoiceBuilder) { builder.UseMellat(); configureMellatInvoiceBuilder(new MellatGatewayInvoiceBuilder(builder)); return(builder); }
/// <summary> /// Sets the type of the gateway which the invoice must be paid in. /// </summary> /// <typeparam name="TGateway">Type of the gateway.</typeparam> /// <param name="builder"></param> /// <exception cref="InvalidGatewayTypeException"></exception> public static IInvoiceBuilder SetGatewayType <TGateway>(this IInvoiceBuilder builder) where TGateway : IGateway { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.SetGatewayType(typeof(TGateway))); }
/// <summary> /// The invoice will be sent to Parbad Virtual gateway. /// </summary> /// <param name="builder"></param> public static IInvoiceBuilder UseParbadVirtual(this IInvoiceBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.UseGateway(ParbadVirtualGateway.Name)); }
/// <summary> /// The invoice will be sent to Asan Pardakht gateway. /// </summary> /// <param name="builder"></param> public static IInvoiceBuilder UseAsanPardakht(this IInvoiceBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.SetGateway(AsanPardakhtGateway.Name)); }
/// <summary> /// The invoice will be sent to Pasargad gateway. /// </summary> /// <param name="builder"></param> public static IInvoiceBuilder UsePasargad(this IInvoiceBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.SetGateway(PasargadGateway.Name)); }
/// <summary> /// Sets the tracking number of invoice. /// </summary> /// <param name="builder"></param> /// <param name="trackingNumber"> /// The tracking number of invoice. /// <para>Note: It must be unique for each payment requests.</para> /// </param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception> public static IInvoiceBuilder SetTrackingNumber(this IInvoiceBuilder builder, long trackingNumber) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.SetTrackingNumberProvider(new UserInputTrackingNumberProvider(trackingNumber))); }
/// <summary> /// Sets the gateway name. /// </summary> /// <param name="builder"></param> /// <param name="gatewayName"></param> /// <exception cref="GatewayNotFoundException"></exception> /// <exception cref="ArgumentNullException"></exception> public static IInvoiceBuilder SetGateway(this IInvoiceBuilder builder, string gatewayName) { if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } return(AddFormatter(builder, invoice => invoice.GatewayName = gatewayName)); }
/// <summary> /// Sets the additional data for <see cref="ZibalGateway"/>. /// </summary> /// <exception cref="ArgumentNullException"></exception> public static IInvoiceBuilder SetZibalData(this IInvoiceBuilder builder, ZibalRequestAdditionalData zibalRequest) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.AddOrUpdateProperty(ZibalHelper.ZibalRequestAdditionalKeyName, zibalRequest)); }
/// <summary> /// Changes the properties. /// </summary> /// <param name="builder"></param> /// <param name="onChange">An action to perform on the properties.</param> public static IInvoiceBuilder ChangeProperties(this IInvoiceBuilder builder, Action <IDictionary <string, object> > onChange) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(AddFormatter(builder, invoice => onChange(invoice.Properties))); }
/// <summary> /// Adds the given formatter to the list of formatters. /// </summary> /// <param name="builder"></param> /// <param name="formatInvoice"></param> public static IInvoiceBuilder AddFormatter(this IInvoiceBuilder builder, Func <Invoice, Task> formatInvoice) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.AddFormatter(new DefaultInvoiceFormatter(formatInvoice))); }
/// <summary> /// The invoice will be sent to Saman gateway. /// </summary> /// <param name="builder"></param> public static IInvoiceBuilder UseSaman(this IInvoiceBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.UseGateway(SamanGateway.Name)); }
/// <summary> /// Sets ZarinPal Gateway data. /// </summary> /// <param name="builder"></param> /// <param name="zarinPalInvoice">Describes an invoice for ZarinPal gateway.</param> /// <exception cref="ArgumentNullException"></exception> public static IInvoiceBuilder SetZarinPalData(this IInvoiceBuilder builder, ZarinPalInvoice zarinPalInvoice) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.AddOrUpdateProperty(ZarinPalHelper.ZarinPalRequestAdditionalKeyName, zarinPalInvoice); return(builder); }
/// <summary> /// Enables or disables Saman Mobile gateway. /// </summary> /// <param name="builder"></param> /// <param name="enable">If true, the invoice will be sent to Saman Mobile gateway. Otherwise it will be sent to Saman Web gateway.</param> public static IInvoiceBuilder EnableSamanMobileGateway(this IInvoiceBuilder builder, bool enable = true) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.AddOrUpdateAdditionalData(SamanHelper.MobileGatewayKey, enable); return(builder); }
internal static void SetYekPayRequest(IInvoiceBuilder builder, YekPayRequest yekPayRequest) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (yekPayRequest == null) { throw new ArgumentNullException(nameof(yekPayRequest)); } builder.AddOrUpdateAdditionalData(YekPayRequestKey, yekPayRequest); }
/// <summary> /// Sets additional data to the Invoice for <see cref="PayIrGateway"/>. /// </summary> /// <param name="builder"></param> /// <param name="data"></param> public static IInvoiceBuilder SetPayIrAdditionalData(this IInvoiceBuilder builder, PayIrRequestAdditionalData data) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } return(builder.AddOrUpdateProperty(PayIrHelper.RequestAdditionalDataKey, data)); }
/// <summary> /// Sets a provider which generates unique tracking numbers for each payment requests. /// </summary> /// <param name="builder"></param> /// <param name="factory"></param> /// <exception cref="ArgumentNullException"></exception> public static IInvoiceBuilder SetTrackingNumberProvider(this IInvoiceBuilder builder, Func <IServiceProvider, ITrackingNumberProvider> factory) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (factory == null) { throw new ArgumentNullException(nameof(factory)); } return(builder.SetTrackingNumberProvider(factory(builder.Services))); }
/// <summary> /// Contains extra functions for Mellat Gateway. /// </summary> /// <param name="builder"></param> /// <param name="configureMellatInvoiceBuilder">Helps to build the extra functions of Mellat Gateway.</param> public static IInvoiceBuilder UseMellat(this IInvoiceBuilder builder, Action <IMellatGatewayInvoiceBuilder> configureMellatInvoiceBuilder) { if (configureMellatInvoiceBuilder == null) { throw new ArgumentNullException(nameof(configureMellatInvoiceBuilder)); } UseMellat(builder); configureMellatInvoiceBuilder(new MellatGatewayInvoiceBuilder(builder)); return(builder); }
/// <summary> /// Sets some additional data for Parsian Gateway. /// </summary> /// <param name="builder"></param> /// <param name="additionalData"></param> public static IInvoiceBuilder SetParsianAdditionalData(this IInvoiceBuilder builder, ParsianGatewayAdditionalDataRequest additionalData) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (additionalData == null) { throw new ArgumentNullException(nameof(additionalData)); } builder.AddOrUpdateProperty(AdditionalDataKey, additionalData); return(builder); }
/// <summary> /// Sets additional data for <see cref="MellatGateway"/>. /// </summary> public static IInvoiceBuilder SetMellatAdditionalData(this IInvoiceBuilder builder, MellatGatewayAdditionalDataRequest request) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } builder.AddOrUpdateProperty(MellatHelper.AdditionalDataKey, request); return(builder); }
/// <summary> /// Sets the gateway using the given name. The given name must match the values of /// <see cref="Gateway"/> enum. /// </summary> /// <param name="builder"></param> /// <param name="gatewayName"></param> /// <exception cref="GatewayNotFoundException"></exception> /// <exception cref="ArgumentNullException"></exception> public static IInvoiceBuilder UseGateway(this IInvoiceBuilder builder, string gatewayName) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } var gatewayType = GatewayHelper.FindGatewayTypeByName(gatewayName, throwException: true); return(builder.SetGatewayType(gatewayType)); }
/// <summary> /// The invoice will be sent to YekPay gateway. /// </summary> public static IInvoiceBuilder SetYekPayData(this IInvoiceBuilder builder, YekPayRequest yekPayRequest) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (yekPayRequest == null) { throw new ArgumentNullException(nameof(yekPayRequest)); } SetYekPayRequest(builder, yekPayRequest); return(builder); }
/// <summary> /// Uses the given account to communicate with the gateway. /// </summary> /// <param name="builder"></param> /// <param name="accountName">Name of the account.</param> public static IInvoiceBuilder UseAccount(this IInvoiceBuilder builder, string accountName) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (accountName.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(accountName)); } builder.AddAdditionalData(GatewayAccountKeyName, accountName); return(builder); }
/// <summary> /// Sets the additional data for PayPing Gateway. /// </summary> public static IInvoiceBuilder SetPayPingData(this IInvoiceBuilder builder, PayPingRequest payPingRequest) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (payPingRequest == null) { throw new ArgumentNullException(nameof(payPingRequest)); } builder.AddOrUpdateAdditionalData(PayPingRequestKey, payPingRequest); return(builder); }
public CongestionChargeCalculator(ICongestionRateStore congestionRateStore, IInvoiceBuilder invoiceBuilder) { _congestionRateStore = congestionRateStore; _invoiceBuilder = invoiceBuilder; }