-
Notifications
You must be signed in to change notification settings - Fork 573
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 passing level III data when creating a charge #1216
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- v47.4.0
- v47.4.0-beta.1
- v47.3.0
- v47.3.0-beta.3
- v47.3.0-beta.2
- v47.3.0-beta.1
- v47.2.0
- v47.2.0-beta.3
- v47.2.0-beta.2
- v47.2.0-beta.1
- v47.1.0
- v47.1.0-beta.3
- v47.1.0-beta.2
- v47.1.0-beta.1
- v47.0.0
- v46.3.0-beta.1
- v46.2.2
- v46.2.1
- v46.2.0
- v46.2.0-beta.3
- v46.2.0-beta.2
- v46.2.0-beta.1
- v46.1.0
- v46.0.0
- v45.15.0
- v45.15.0-beta.1
- v45.14.0
- v45.13.0
- v45.13.0-beta.1
- v45.12.0
- v45.12.0-beta.1
- v45.11.0
- v45.10.0
- v45.10.0-beta.1
- v45.9.0
- v45.9.0-beta.2
- v45.9.0-beta.1
- v45.8.0
- v45.8.0-beta.1
- v45.7.0
- v45.7.0-beta.1
- v45.6.0
- v45.6.0-beta.1
- v45.5.0
- v45.4.0
- v45.3.0
- v45.3.0-beta.1
- v45.2.0
- v45.2.0-beta.1
- v45.1.0
- v45.0.0
- v44.13.0
- v44.13.0-beta.1
- v44.12.0
- v44.12.0-beta.1
- v44.11.0
- v44.11.0-beta.1
- v44.10.0
- v44.10.0-beta.1
- v44.9.0
- v44.9.0-beta.1
- v44.8.0
- v44.7.0
- v44.7.0-beta.1
- v44.6.0
- v44.6.0-beta.1
- v44.5.0
- v44.5.0-beta.1
- v44.4.0
- v44.4.0-beta.1
- v44.3.0
- v44.2.0
- v44.2.0-beta.1
- v44.1.0
- v44.0.0
- v43.23.0
- v43.23.0-beta.1
- v43.22.0
- v43.22.0-beta.1
- v43.21.0
- v43.21.0-beta.1
- v43.20.0
- v43.20.0-beta.1
- v43.19.0
- v43.19.0-beta.1
- v43.18.0
- v43.18.0-beta.1
- v43.17.0
- v43.17.0-beta.1
- v43.16.0
- v43.16.0-beta.1
- v43.15.0
- v43.15.0-beta.1
- v43.14.0
- v43.14.0-beta.1
- v43.13.0
- v43.13.0-beta.1
- v43.12.0
- v43.12.0-beta.1
- v43.11.0
- v43.11.0-beta.1
- v43.10.0
- v43.10.0-beta.1
- v43.9.0
- v43.9.0-beta.1
- v43.8.0
- v43.8.0-beta.1
- v43.7.0
- v43.7.0-beta.1
- v43.6.0
- v43.6.0-beta.1
- v43.5.0
- v43.5.0-beta.1
- v43.4.0
- v43.4.0-beta.1
- v43.3.0
- v43.3.0-beta.1
- v43.2.0
- v43.2.0-beta.1
- v43.1.0
- v43.1.0-beta.2
- v43.1.0-beta.1
- v43.0.0
- v42.11.0-beta.1
- v42.10.0
- v42.10.0-beta.1
- v42.9.0
- v42.9.0-beta.1
- v42.8.0
- v42.8.0-beta.1
- v42.7.0
- v42.7.0-beta.1
- v42.6.0
- v42.6.0-beta.1
- v42.5.0
- v42.5.0-beta.1
- v42.4.0
- v42.4.0-beta.1
- v42.3.0
- v42.2.0
- v42.1.0
- v42.0.0
- v42.0.0-beta.1
- v41.29.0-beta.1
- v41.28.0
- v41.28.0-beta.1
- v41.27.0
- v41.27.0-beta.1
- v41.26.0
- v41.25.0
- v41.25.0-beta.1
- v41.24.0
- v41.23.0
- v41.23.0-beta.1
- v41.22.0
- v41.22.0-beta.1
- v41.21.0
- v41.21.0-beta.2
- v41.21.0-beta.1
- v41.20.0
- v41.20.0-beta.1
- v41.19.0
- v41.19.0-beta.1
- v41.18.0
- v41.18.0-beta.1
- v41.17.0
- v41.17.0-beta.1
- v41.16.0
- v41.16.0-beta.1
- v41.15.0
- v41.15.0-beta.1
- v41.14.0
- v41.14.0-beta.3
- v41.14.0-beta.2
- v41.14.0-beta.1
- v41.13.0
- v41.13.0-beta.1
- v41.12.0
- v41.12.0-beta.1
- v41.11.0
- v41.11.0-beta.1
- v41.10.0
- v41.10.0-beta.1
- v41.9.0
- v41.9.0-beta.1
- v41.8.0
- v41.8.0-beta.2
- v41.8.0-beta.1
- v41.7.0
- v41.7.0-beta.1
- v41.6.0
- v41.6.0-beta.2
- v41.6.0-beta.1
- v41.5.0
- v41.5.0-beta.2
- v41.5.0-beta.1
- v41.4.0
- v41.4.0-beta.1
- v41.3.0
- v41.3.0-beta.2
- v41.3.0-beta.1
- v41.2.0
- v41.1.0
- v41.0.0
- v40.17.0-beta.1
- v40.16.0
- v40.15.0
- v40.15.0-beta.2
- v40.15.0-beta.1
- v40.14.0
- v40.14.0-beta.1
- v40.13.0
- v40.13.0-beta.1
- v40.12.0
- v40.12.0-beta.2
- v40.12.0-beta.1
- v40.11.0
- v40.11.0-beta.1
- v40.10.0
- v40.9.0
- v40.8.0
- v40.7.0
- v40.6.0
- v40.5.0
- v40.5.0-beta.1
- v40.4.0
- v40.4.0-beta.1
- v40.3.0
- v40.3.0-beta.1
- v40.2.0
- v40.1.0
- v40.1.0-beta.1
- v40.0.0
- v39.126.0
- v39.125.0
- v39.125.0-beta.1
- v39.124.0
- v39.123.0
- v39.123.0-beta.1
- v39.122.0
- v39.121.0
- v39.120.0
- v39.119.0
- v39.119.0-beta.1
- v39.118.0
- v39.117.0
- v39.116.0
- v39.115.0
- v39.114.0
- v39.113.0
- v39.112.0
- v39.111.0
- v39.110.0
- v39.109.0
- v39.108.0
- v39.107.0
- v39.106.0
- v39.105.0
- v39.104.0
- v39.103.0
- v39.102.0
- v39.101.0
- v39.100.0
- v39.99.0
- v39.98.0
- v39.97.0
- v39.96.0
- v39.95.0
- v39.94.0
- v39.93.0
- v39.92.0
- v39.91.0
- v39.90.0
- v39.89.0
- v39.88.0
- v39.87.0
- v39.86.0
- v39.85.0
- v39.84.0
- v39.83.0
- v39.82.0
- v39.81.0
- v39.80.0
- v39.79.0
- v39.78.1
- v39.78.0
- v39.77.0
- v39.76.0
- v39.75.1
- v39.75.0
- v39.74.0
- v39.73.0
- v39.72.0
- v39.71.0
- v39.70.0
- v39.69.0
- v39.68.0
- v39.67.0
- v39.66.0
- v39.65.0
- v39.64.0
- v39.63.0
- v39.62.0
- v39.61.0
- v39.60.0
- v39.59.0
- v39.58.0
- v39.57.0
- v39.56.1
- v39.56.0
- v39.55.0
- v39.54.0
- v39.53.0
- v39.52.0
- v39.51.0
- v39.50.0
- v39.49.0
- v39.48.0
- v39.47.0
- v39.46.0
- v39.45.0
- v39.44.0
- v39.43.0
- v39.42.0
- v39.41.0
- v39.40.0
- v39.39.0
- v39.38.0
- v39.37.0
- v39.36.0
- v39.35.0
- v39.34.0
- v39.33.0
- v39.32.0
- v39.31.0
- v39.30.0
- v39.29.0
- v39.28.0
- v39.27.0
- v39.26.0
- v39.25.0
- v39.24.0
- v39.23.0
- v39.22.0
- v39.21.0
- v39.20.0
- v39.19.0
- v39.18.0
- v39.17.0
- v39.16.0
- v39.15.0
- v39.14.0
- v39.13.0
- v39.12.0
- v39.11.0
- v39.10.0
- v39.9.0
- v39.8.0
- v39.7.0
- v39.6.0
- v39.5.0
- v39.4.0
- v39.3.0
- v39.2.0
- v39.1.2
- v39.1.1
- v39.1.0
- v39.0.0
- v38.0.0
- v37.35.0
- v37.34.0
- v37.33.0
- v37.32.0
- v37.31.0
- v37.30.0
- v37.29.0
- v37.28.0
- v37.27.0
- v37.26.0
- v37.25.0
- v37.24.0
- v37.23.0
- v37.22.0
- v37.21.0
- v37.20.0
- v37.19.0
- v37.18.0
- v37.17.0
- v37.16.0
- v37.15.1
- v37.15.0
- v37.14.0
- v37.13.0
- v37.12.0
- v37.11.0
- v37.10.0
- v37.9.0
- v37.8.0
- v37.7.0
- v37.6.0
- v37.5.0
- v37.4.0
- v37.3.0
- v37.2.0
- v37.1.0
- v37.0.0
- v36.12.2
- v36.12.1
- v36.12.0
- v36.11.0
- v36.10.0
- v36.9.0
- v36.8.1
- v36.8.0
- v36.7.0
- v36.6.0
- v36.5.0
- v36.4.0
- v36.3.0
- v36.2.0
- v36.1.0
- v36.0.0
- v35.17.0
- v35.16.0
- v35.15.0
- v35.14.0
- v35.13.0
- v35.12.1
- v35.12.0
- v35.11.1
- v35.11.0
- v35.10.0
- v35.9.0
- v35.8.0
- v35.7.1
- v35.7.0
- v35.6.0
- v35.5.0
- v35.4.0
- v35.3.0
- v35.2.0
- v35.1.0
- v35.0.0
- v34.26.0
- v34.25.0
- v34.24.0
- v34.23.0
- v34.22.0
- v34.21.0
- v34.20.1
- v34.20.0
- v34.19.0
- v34.18.0
- v34.17.0
- v34.16.1
- v34.16.0
- v34.15.0
- v34.14.0
- v34.13.0
- v34.12.0
- v34.11.0
- v34.10.1
- v34.10.0
- v34.9.0
- v34.8.0
- v34.7.0
- v34.6.0
- v34.5.0
- v34.4.0
- v34.3.0
- v34.2.0
- v34.1.0
- v34.0.0
- v33.9.0
- v33.8.0
- v33.7.0
- v33.6.0
- v33.5.0
- v33.4.0
- v33.3.0
- v33.2.0
- v33.1.0
- v33.0.0
- v32.2.0
- v32.1.3
- v32.1.2
- v32.1.1
- v32.1.0
- v32.0.0
- v31.2.0
- v31.1.0
- v31.0.0
- v30.1.0
- v30.0.1
- v30.0.0
- v29.6.0
- v29.5.0
- v29.4.0
- v29.3.0
- v29.2.1
- v29.2.0
- v29.1.0
- v29.0.1
- v29.0.0
- v28.11.0
- v28.10.0
- v28.9.0
- v28.8.0
- v28.7.0
- v28.6.0
- v28.5.0
- v28.4.0
- v28.3.0
- v28.2.0
- v28.1.0
- v28.0.0
- v27.25.1
- v27.25.0
- v27.24.0
- v27.23.0
- v27.22.0
- v27.21.0
- v27.20.0
- v27.19.0
- v27.18.0
- v27.17.0
- v27.16.1
- v27.16.0
- v27.15.0
- v27.14.1
- v27.14.0
- v27.13.0
- v27.12.0
- v27.11.0
- v27.10.0
- v27.9.1
- v27.9.0
- v27.8.1
- v27.8.0
- v27.7.0
- v27.6.0
- v27.5.0
- v27.4.0
- v27.3.2
- v27.3.1
- v27.3.0
- v27.2.0
- v27.1.3
- v27.1.2
- v27.1.1
- v27.1.0
- v27.0.0
- v26.1.0
- v26.0.0
- v25.20.0
- v25.19.1
- v25.19.0
- v25.18.0
- v25.17.0
- v25.16.1
- v25.16.0
- v25.15.0
- v25.14.0
- v25.13.0
- v25.12.0
- v25.11.0
- v25.10.0
- v25.9.0
- v25.8.0
- v25.7.1
- v25.7.0
- v25.6.0
- v25.5.0
- v25.4.0
- v25.3.0
- v25.2.0
- v25.1.0
- v25.0.0
- v24.7.0
- v24.6.0
- v24.5.0
- v24.4.1
- v24.4.0
- v24.3.0
- v24.2.0
- v24.1.0
- v24.0.2
- v24.0.1
- v24.0.0
- v23.2.0
- v23.1.0
- v23.0.0
- v22.9.0
- v22.8.1
- v22.8.0
- v22.7.0
- v22.6.0
- v22.5.0
- v22.4.0
- v22.3.0
- v22.2.0
- v22.1.0
- v22.0.0
- v21.9.0
- v21.8.1
- v21.8.0
- v21.7.1
- v21.7.0
- v21.6.0
- v21.5.0
- v21.4.1
- v21.4.0
- v21.3.0
- v21.2.0
- v21.1.0
- v21.0.0
- v20.4.1
- v20.4.0
- v20.3.0
- v20.2.0
- v20.1.0
- v20.0.0
- v19.10.0
- v19.9.2
- v19.9.1
- v19.9.0
- v19.8.0
- v19.7.0
- v19.6.0
- v19.5.0
- v19.4.0
- v19.3.0
- v19.2.0
- v19.1.0
- v19.0.1
- v19.0.0
- v18.0.0
- v17.11.0
- v17.10.0
- v17.9.0
- v17.8.0
- v17.7.0
- v17.6.0
- v17.5.0
- v17.4.0
- v17.3.1
- v17.3.0
- v17.2.0
- v17.1.0
- v17.0.0
- v16.16.1
- v16.16.0
- v16.15.0
- v16.14.0
- v7.63.0
- list
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
|
||
namespace Stripe | ||
{ | ||
public class StripeChargeLevel3 : StripeEntity | ||
{ | ||
[JsonProperty("line_items")] | ||
public List<StripeChargeLevel3LineItem> LineItems { get; set; } | ||
|
||
[JsonProperty("merchant_reference")] | ||
public string MerchantReference { get; set; } | ||
|
||
[JsonProperty("shipping_address_zip")] | ||
public string ShippingAddressZip { get; set; } | ||
|
||
[JsonProperty("shipping_amount")] | ||
public int ShippingAmount { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Stripe | ||
{ | ||
public class StripeChargeLevel3LineItem : StripeEntity | ||
{ | ||
[JsonProperty("discount_amount")] | ||
public int? DiscountAmount { get; set; } | ||
|
||
[JsonProperty("product_code")] | ||
public string ProductCode { get; set; } | ||
|
||
[JsonProperty("product_description")] | ||
public string ProductDescription { get; set; } | ||
|
||
[JsonProperty("quantity")] | ||
public int? Quantity { get; set; } | ||
|
||
[JsonProperty("tax_amount")] | ||
public int? TaxAmount { get; set; } | ||
|
||
[JsonProperty("unit_cost")] | ||
public int? UnitCost { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Newtonsoft.Json; | ||
|
||
namespace Stripe.Infrastructure.Middleware | ||
{ | ||
internal class ChargeLevel3Plugin : IParserPlugin | ||
{ | ||
public bool Parse(ref string requestString, JsonPropertyAttribute attribute, PropertyInfo property, object propertyValue, object propertyParent) | ||
{ | ||
if (attribute.PropertyName != "charge_level3_line_items_array") return false; | ||
|
||
var items = ((List<StripeChargeLevel3LineItemOptions>) property.GetValue(propertyParent, null)); | ||
|
||
var itemIndex = 0; | ||
foreach (var item in items) | ||
{ | ||
var properties = item.GetType().GetRuntimeProperties(); | ||
|
||
foreach (var prop in properties) | ||
{ | ||
var value = prop.GetValue(item, null); | ||
if (value == null) continue; | ||
|
||
// it must have a json attribute matching stripe's key, and only one | ||
var attr = prop.GetCustomAttributes<JsonPropertyAttribute>().SingleOrDefault(); | ||
if (attr == null) continue; | ||
|
||
RequestStringBuilder.ApplyParameterToRequestString(ref requestString, | ||
$"level3[line_items][{itemIndex}][{attr.PropertyName}]", value.ToString()); | ||
} | ||
|
||
itemIndex++; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Stripe | ||
{ | ||
public class StripeChargeLevel3LineItemOptions : INestedOptions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand when something should be called Options versus Option. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should always be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that would work. I thought that we started using |
||
{ | ||
[JsonProperty("discount_amount")] | ||
public int? DiscountAmount { get; set; } | ||
|
||
[JsonProperty("product_code")] | ||
public string ProductCode { get; set; } | ||
|
||
[JsonProperty("product_description")] | ||
public string ProductDescription { get; set; } | ||
|
||
[JsonProperty("quantity")] | ||
public int? Quantity { get; set; } | ||
|
||
[JsonProperty("tax_amount")] | ||
public int? TaxAmount { get; set; } | ||
|
||
[JsonProperty("unit_cost")] | ||
public int? UnitCost { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
|
||
namespace Stripe | ||
{ | ||
public class StripeChargeLevel3Options : INestedOptions | ||
{ | ||
// this will actually send `line_items`. this is to flag it for the middleware | ||
// to process it as a plugin | ||
[JsonProperty("charge_level3_line_items_array")] | ||
public List<StripeChargeLevel3LineItemOptions> LineItems { get; set; } | ||
|
||
[JsonProperty("level3[merchant_reference]")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works but since the parent has |
||
public string MerchantReference { get; set; } | ||
|
||
[JsonProperty("level3[shipping_address_zip]")] | ||
public string ShippingAddressZip { get; set; } | ||
|
||
[JsonProperty("level3[shipping_amount]")] | ||
public int ShippingAmount { get; set; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really should revisit how plugins work. It's all copy/pasta for the sake of adding one list of items. There has to be a better way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I took a stab at this in #1218.