Struct LatitudePayMoney
Represents a monetary or financial value in the LatitudePay API as a tuple containing a numeric value and a string representing the associated currency.
Implements
Inherited Members
Namespace: Yort.LatitudePay.InStore
Assembly: Yort.LatitudePay.InStore.dll
Syntax
public struct LatitudePayMoney : IEquatable<LatitudePayMoney>
Remarks
This is an immutable value type. To set the value or currency you must use the LatitudePayMoney(Decimal, String) constructor.
Instances created using the default construtor will return a zero value with the Currency property returning the value of NewZealandDollars.
//Assuming you have an variable called payment with a 'value' property containing the decimal amount
//you want to send.
var amount = new LatitudePayMoney(Math.Round(payment.Value, 2));
//This sample uses a literal value for illustration purposes
var amount = new LatitudePayMoney(Math.Round(99.9900, 2));</code></pre>
Constructors
| Improve this Doc View SourceLatitudePayMoney(Decimal)
Constructs a new instance using the specified amount and currency.
Declaration
public LatitudePayMoney(decimal amount)
Parameters
Type | Name | Description |
---|---|---|
Decimal | amount | A decimal value indicating the numeric value of this monetary value. This value should be rounded to the appropriate number of decimal places associated with the currency specified by Currency. |
Remarks
This constructor uses the DefaultCurrency value for the Currency property of this instance. If DefaultCurrency is null or empty string then AustralianDollars will be used.
LatitudePayMoney(Decimal, String)
Constructs a new instance using the specified amount and currency.
Declaration
public LatitudePayMoney(decimal amount, string currency)
Parameters
Type | Name | Description |
---|---|---|
Decimal | amount | A decimal value indicating the numeric value of this monetary value. This value should be rounded to the appropriate number of decimal places associated with the currency specified by Currency. |
String | currency | A three chracter string that identifies the currency this monetary value is in. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if |
Properties
| Improve this Doc View SourceAmount
Returns the numeric amount of this monetary value in the currency specified by Currency.
Declaration
[JsonProperty("amount")]
public decimal Amount { get; }
Property Value
Type | Description |
---|---|
Decimal |
Remarks
This value should be rounded to the appropriate number of decimal places associated with the currency specified by Currency.
See Also
| Improve this Doc View SourceCurrency
Specifies the currency of the Amount/
Declaration
[Required]
[JsonProperty("currency")]
public string Currency { get; }
Property Value
Type | Description |
---|---|
String |
See Also
Methods
| Improve this Doc View SourceEquals(Object)
Compares this instance to an object value and returns true if they are both LatitudePayMoney instances that are considered equal, otherwise false.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The other value to comnpare to. |
Returns
Type | Description |
---|---|
Boolean | True if |
Overrides
Remarks
If obj
is null or not an instance of LatitudePayMoney then false is returned, otherwise the result of Equals(LatitudePayMoney) is returned.
Equals(LatitudePayMoney)
Returns true if this instance is considered equal to other
, otherwise returns false.
Declaration
public bool Equals(LatitudePayMoney other)
Parameters
Type | Name | Description |
---|---|---|
LatitudePayMoney | other | The other instance to compare to. |
Returns
Type | Description |
---|---|
Boolean | True if the two instances are considered equal. |
Remarks
Equality is determined by comparing the Amount properties for an exact match and the Currency properties for an ordinal, case-insensitive match.
GetHashCode()
Returns the hashcode for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A integer that is the hashcode for this instance. |
Overrides
| Improve this Doc View SourceToString()
Returns the Amount property formatted as a currency using the current thread culture (which may or may not match the currency defined by Currency).
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string containing the formatted amount. |
Overrides
Operators
| Improve this Doc View SourceEquality(LatitudePayMoney, LatitudePayMoney)
Performs equality checking on LatitudePayMoney instances.
Declaration
public static bool operator ==(LatitudePayMoney value1, LatitudePayMoney value2)
Parameters
Type | Name | Description |
---|---|---|
LatitudePayMoney | value1 | A LatitudePayMoney instance. |
LatitudePayMoney | value2 | A LatitudePayMoney instance. |
Returns
Type | Description |
---|---|
Boolean | True if the instances are equal, otherwise false. |
Remarks
Equality is determined by comparing the Amount properties for an exact match and the Currency properties for an ordinal, case-insensitive match.
Inequality(LatitudePayMoney, LatitudePayMoney)
Performs inequality checking on LatitudePayMoney instances.
Declaration
public static bool operator !=(LatitudePayMoney value1, LatitudePayMoney value2)
Parameters
Type | Name | Description |
---|---|---|
LatitudePayMoney | value1 | A LatitudePayMoney instance. |
LatitudePayMoney | value2 | A LatitudePayMoney instance. |
Returns
Type | Description |
---|---|
Boolean | True if the instances are not equal, otherwise false. |
Remarks
Inverts the result of an == comparison.