Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more Expand and change Outcome to be auto expanded #1139

Merged
merged 1 commit into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public void shipping_has_the_right_tracking_number()
fixture.Charge.Shipping.TrackingNumber.Should().Be(Cache.GetStripeChargeCreateOptions().Shipping.TrackingNumber);
}

[Fact]
public void charge_has_outcome_filled()
{
fixture.Charge.Outcome.NetworkStatus.Should().NotBeNull();
fixture.Charge.Outcome.RiskLevel.Should().NotBeNull();
}

[Fact]
public void updated_has_the_right_description()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Stripe.Tests.XUnit/skus/when_listing_skus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void list_has_the_expected_sku()
{
fixture.SkuList.Data.Count.Should().Be(1);
fixture.SkuList.Data.First().Id.Should().Be(fixture.SkuTwo.Id);
fixture.SkuList.Data.First().Product.Should().Be(fixture.Product.Id);
fixture.SkuList.Data.First().ProductId.Should().Be(fixture.Product.Id);
}
}
}
15 changes: 14 additions & 1 deletion src/Stripe.net/Entities/StripeAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ public class StripeAccount : StripeEntityWithId, ISupportMetadata
[JsonProperty("object")]
public string Object { get; set; }

[JsonProperty("business_logo")]
#region Expandable BusinessLogo
public string BusinessLogoFileId { get; set; }

[JsonIgnore]
public StripeFileUpload BusinessLogo { get; set; }

[JsonProperty("business_logo")]
internal object InternalBusinessLogo
{
set
{
StringOrObject<StripeFileUpload>.Map(value, s => BusinessLogoFileId = s, o => BusinessLogo = o);
}
}
#endregion

[JsonProperty("business_name")]
public string BusinessName { get; set; }

Expand Down
30 changes: 28 additions & 2 deletions src/Stripe.net/Entities/StripeApplicationFeeRefund.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ public class StripeApplicationFeeRefund : StripeEntityWithId, ISupportMetadata
[JsonProperty("amount")]
public int Amount { get; set; }

#region Expandable Balance Transaction
public string BalanceTransactionId { get; set; }

[JsonIgnore]
public StripeBalanceTransaction BalanceTransaction { get; set; }

[JsonProperty("balance_transaction")]
public string BalanceTransaction { get; set; }
internal object InternalBalanceTransaction
{
set
{
StringOrObject<StripeBalanceTransaction>.Map(value, s => BalanceTransactionId = s, o => BalanceTransaction = o);
}
}
#endregion

[JsonProperty("created")]
[JsonConverter(typeof(StripeDateTimeConverter))]
Expand All @@ -23,8 +36,21 @@ public class StripeApplicationFeeRefund : StripeEntityWithId, ISupportMetadata
[JsonProperty("currency")]
public string Currency { get; set; }

#region Expandable Fee
public string FeeId { get; set; }

[JsonIgnore]
public StripeApplicationFee Fee { get; set; }

[JsonProperty("fee")]
public string Fee { get; set; }
internal object InternalFee
{
set
{
StringOrObject<StripeApplicationFee>.Map(value, s => FeeId = s, o => Fee = o);
}
}
#endregion

[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }
Expand Down
25 changes: 15 additions & 10 deletions src/Stripe.net/Entities/StripeCharge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,26 +218,31 @@ internal object InternalOnBehalfOf
}
#endregion

// order - requires orders to be expandable
[JsonProperty("order")]
public string Order { get; set; }

#region Expandable Outcome
public string OutcomeId { get; set; }
#region Expandable Order
/// <summary>
/// ID of the order this charge is for if one exists.
/// </summary>
public string OrderId { get; set; }

[JsonIgnore]
public StripeOutcome Outcome { get; set; }
public StripeOrder Order { get; set; }

[JsonProperty("outcome")]
internal object InternalOutcome
[JsonProperty("order")]
internal object InternalOrder
{
set
{
StringOrObject<StripeOutcome>.Map(value, s => OutcomeId = s, o => Outcome = o);
StringOrObject<StripeOrder>.Map(value, s => OrderId = s, o => Order = o);
}
}
#endregion

/// <summary>
/// Details about whether the payment was accepted, and why.
/// </summary>
[JsonProperty("outcome")]
public StripeOutcome Outcome { get; set; }

/// <summary>
/// true if the charge succeeded, or was successfully authorized for later capture.
/// </summary>
Expand Down
15 changes: 14 additions & 1 deletion src/Stripe.net/Entities/StripeInvoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,22 @@ internal object InternalCustomer
[JsonProperty("statement_descriptor")]
public string StatementDescriptor { get; set; }

[JsonProperty("subscription")]
#region Expandable Subscription
public string SubscriptionId { get; set; }

[JsonIgnore]
public StripeSubscription Subscription { get; set; }

[JsonProperty("subscription")]
internal object InternalSubscription
{
set
{
StringOrObject<StripeSubscription>.Map(value, s => SubscriptionId = s, o => Subscription = o);
}
}
#endregion

[JsonProperty("subscription_proration_date")]
[JsonConverter(typeof(StripeDateTimeConverter))]
public DateTime SubscriptionProrationDate { get; set; }
Expand Down
15 changes: 14 additions & 1 deletion src/Stripe.net/Entities/StripeInvoiceLineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,22 @@ internal object InternalInvoice
[JsonProperty("quantity")]
public int? Quantity { get; set; }

[JsonProperty("subscription")]
#region Expandable Subscription
public string SubscriptionId { get; set; }

[JsonIgnore]
public StripeSubscription Subscription { get; set; }

[JsonProperty("subscription")]
internal object InternalSubscription
{
set
{
StringOrObject<StripeSubscription>.Map(value, s => SubscriptionId = s, o => Subscription = o);
}
}
#endregion

[JsonProperty("subscription_item")]
public string SubscriptionItem { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions src/Stripe.net/Entities/StripeOutcome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class StripeOutcome : StripeEntityWithId
public string RiskLevel { get; set; }

/// <summary>
/// An enumerated value indicating a more detailed explanation of the outcome’s type. See understanding declines for details.
/// The ID of the Radar rule that matched the payment, if applicable.
/// </summary>
[JsonProperty("rule")]
public string Rule { get; set; }
public string RuleId { get; set; }

/// <summary>
/// A human-readable description of the outcome type and reason, designed for you (the recipient of the payment), not your customer.
Expand Down
15 changes: 14 additions & 1 deletion src/Stripe.net/Entities/StripeSku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,24 @@ public class StripeSku : StripeEntityWithId, ISupportMetadata
[JsonProperty("price")]
public int Price { get; set; }

#region Expandable Product
/// <summary>
/// The ID of the product this SKU is associated with. The product must be currently active.
/// </summary>
public string ProductId { get; set; }

[JsonIgnore]
public StripeProduct Product { get; set; }

[JsonProperty("product")]
public string Product { get; set; }
internal object InternalProduct
{
set
{
StringOrObject<StripeProduct>.Map(value, s => ProductId = s, o => Product = o);
}
}
#endregion

[JsonProperty("updated")]
[JsonConverter(typeof(StripeDateTimeConverter))]
Expand Down
45 changes: 42 additions & 3 deletions src/Stripe.net/Entities/StripeTransfer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,37 @@ internal object InternalBalanceTransaction
[JsonProperty("currency")]
public string Currency { get; set; }

#region Expandable Destination
public string DestinationId { get; set; }

[JsonIgnore]
public StripeAccount Destination { get; set; }

[JsonProperty("destination")]
public string Destination { get; set; }
internal object InternalDestination
{
set
{
StringOrObject<StripeAccount>.Map(value, s => DestinationId = s, o => Destination = o);
}
}
#endregion

#region Expandable Destination Payment
public string DestinationPaymentId { get; set; }

[JsonIgnore]
public StripeCharge DestinationPayment { get; set; }

[JsonProperty("destination_payment")]
public string DestinationPayment { get; set; }
internal object InternalDestinationPayment
{
set
{
StringOrObject<StripeCharge>.Map(value, s => DestinationPaymentId = s, o => DestinationPayment = o);
}
}
#endregion

[JsonProperty("livemode")]
public bool LiveMode { get; set; }
Expand All @@ -57,9 +83,22 @@ internal object InternalBalanceTransaction
[JsonProperty("reversed")]
public bool Reversed { get; set; }

[JsonProperty("source_transaction")]
#region Expandable Source Transaction
public string SourceTransactionId { get; set; }

[JsonIgnore]
public StripeCharge SourceTransaction { get; set; }

[JsonProperty("source_transaction")]
internal object InternalSourceTransaction
{
set
{
StringOrObject<StripeCharge>.Map(value, s => SourceTransactionId = s, o => SourceTransaction = o);
}
}
#endregion

[JsonProperty("source_type")]
public string SourceType { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions src/Stripe.net/Services/Account/StripeAccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class StripeAccountService : StripeService
public StripeAccountService() : base(null) { }
public StripeAccountService(string apiKey) : base(apiKey) { }

public bool ExpandBusinessLogo { get; set; }



//Sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class StripeApplicationFeeRefundService : StripeBasicService<StripeApplic
public StripeApplicationFeeRefundService() : base(null) { }
public StripeApplicationFeeRefundService(string apiKey) : base(apiKey) { }

public bool ExpandBalanceTransaction { get; set; }
public bool ExpandFee { get; set; }



// Sync
public virtual StripeApplicationFeeRefund Create(string applicationFeeId, StripeApplicationFeeRefundCreateOptions createOptions = null, StripeRequestOptions requestOptions = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public StripeApplicationFeeService(string apiKey) : base(apiKey) { }
public bool ExpandApplication { get; set; }
public bool ExpandBalanceTransaction { get; set; }
public bool ExpandCharge { get; set; }
public bool ExpandOriginatingTransaction { get; set; }



Expand Down
8 changes: 4 additions & 4 deletions src/Stripe.net/Services/Charges/StripeChargeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public StripeChargeService(string apiKey) : base(apiKey) { }
public bool ExpandBalanceTransaction { get; set; }
public bool ExpandCustomer { get; set; }
public bool ExpandDestination { get; set; }
public bool ExpandDispute { get; set; }
public bool ExpandInvoice { get; set; }
public bool ExpandReview { get; set; }
public bool ExpandTransfer { get; set; }
public bool ExpandOnBehalfOf { get; set; }
public bool ExpandOrder { get; set; }
public bool ExpandReview { get; set; }
public bool ExpandSourceTransfer { get; set; }
public bool ExpandDispute { get; set; }
public bool ExpandOutcome { get; set; }
public bool ExpandTransfer { get; set; }



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public StripeInvoiceItemService(string apiKey) : base(apiKey) { }

public bool ExpandCustomer { get; set; }
public bool ExpandInvoice { get; set; }
public bool ExpandSubscription { get; set; }



Expand Down
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Invoices/StripeInvoiceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public StripeInvoiceService(string apiKey) : base(apiKey) { }

public bool ExpandCharge { get; set; }
public bool ExpandCustomer { get; set; }
public bool ExpandSubscription { get; set; }



Expand Down
3 changes: 3 additions & 0 deletions src/Stripe.net/Services/Orders/StripeOrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class StripeOrderService : StripeBasicService<StripeOrder>
public StripeOrderService() : base(null) { }
public StripeOrderService(string apiKey) : base(apiKey) { }

public bool ExpandCharge { get; set; }
public bool ExpandCustomer { get; set; }



// Sync
Expand Down
2 changes: 1 addition & 1 deletion src/Stripe.net/Services/Payouts/StripePayoutService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public StripePayoutService() : base(null) { }
public StripePayoutService(string apiKey) : base(apiKey) { }

public bool ExpandBalanceTransaction { get; set; }
public bool ExpandFailureBalanceTransaction { get; set; }
public bool ExpandDestination { get; set; }
public bool ExpandFailureBalanceTransaction { get; set; }



Expand Down
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Refunds/StripeRefundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public StripeRefundService(string apiKey) : base(apiKey) { }

public bool ExpandBalanceTransaction { get; set; }
public bool ExpandCharge { get; set; }
public bool ExpandFailureBalanceTransaction { get; set; }



Expand Down
2 changes: 2 additions & 0 deletions src/Stripe.net/Services/Skus/StripeSkuService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class StripeSkuService : StripeBasicService<StripeSku>
public StripeSkuService() : base(null) { }
public StripeSkuService(string apiKey) : base(apiKey) { }

public bool ExpandProduct { get; set; }



// Sync
Expand Down
3 changes: 3 additions & 0 deletions src/Stripe.net/Services/Transfers/StripeTransferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public StripeTransferService() : base(null) { }
public StripeTransferService(string apiKey) : base(apiKey) { }

public bool ExpandBalanceTransaction { get; set; }
public bool ExpandDestination { get; set; }
public bool ExpandDestinationPayment { get; set; }
public bool ExpandSourceTransaction { get; set; }



Expand Down