Skip to content

Commit 01abcfa

Browse files
Add support for Klarna Source and SourceOrders on Sources
1 parent 703be2b commit 01abcfa

12 files changed

+351
-1
lines changed

src/Stripe.net/Constants/SourceType.cs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public static class SourceType
2020

2121
public const string Ideal = "ideal";
2222

23+
public const string Klarna = "klarna";
24+
2325
public const string P24 = "p24";
2426

2527
public const string SepaCreditTransfer = "sepa_credit_transfer";

src/Stripe.net/Entities/Charges/ChargePaymentMethodDetails.cs

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class ChargePaymentMethodDetails : StripeEntity
3838
[JsonProperty("ideal")]
3939
public ChargePaymentMethodDetailsIdeal Ideal { get; set; }
4040

41+
[JsonProperty("klarna")]
42+
public ChargePaymentMethodDetailsKlarna Klarna { get; set; }
43+
4144
[JsonProperty("multibanco")]
4245
public ChargePaymentMethodDetailsMultibanco Multibanco { get; set; }
4346

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
using Stripe.Infrastructure;
5+
6+
public class ChargePaymentMethodDetailsKlarna : StripeEntity
7+
{
8+
}
9+
}

src/Stripe.net/Entities/Sources/Source.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ public class Source : StripeEntity<Source>, IHasId, IHasMetadata, IHasObject, IP
6565
[JsonProperty("metadata")]
6666
public Dictionary<string, string> Metadata { get; set; }
6767

68+
/// <summary>
69+
/// Information about the items and shipping associated with the source.
70+
/// Required for transactional credit (for example Klarna) sources
71+
/// before you can charge it.
72+
/// </summary>
73+
[JsonProperty("source_order")]
74+
public SourceSourceOrder SourceOrder { get; set; }
75+
6876
/// <summary>
6977
/// Information about the owner of the payment instrument that may be used or required by particular source types.
7078
/// </summary>
@@ -96,7 +104,7 @@ public class Source : StripeEntity<Source>, IHasId, IHasMetadata, IHasObject, IP
96104
public string Status { get; set; }
97105

98106
/// <summary>
99-
/// The type of the source. The type is a payment method, one of card, three_d_secure, giropay, sepa_debit, ideal, sofort, or bancontact.
107+
/// The type of the source. The type is a payment method, one of card, three_d_secure, giropay, sepa_debit, ideal, klarna, sofort, or bancontact.
100108
/// </summary>
101109
[JsonProperty("type")]
102110
public string Type { get; set; }
@@ -147,6 +155,9 @@ public class Source : StripeEntity<Source>, IHasId, IHasMetadata, IHasObject, IP
147155
[JsonProperty("ideal")]
148156
public SourceIdeal Ideal { get; set; }
149157

158+
[JsonProperty("klarna")]
159+
public SourceKlarna Klarna { get; set; }
160+
150161
[JsonProperty("multibanco")]
151162
public SourceMultibanco Multibanco { get; set; }
152163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class SourceKlarna : StripeEntity<SourceIdeal>
6+
{
7+
[JsonProperty("background_image_url")]
8+
public string BackgroundImageUrl { get; set; }
9+
10+
[JsonProperty("client_token")]
11+
public string ClientToken { get; set; }
12+
13+
[JsonProperty("first_name")]
14+
public string FirstName { get; set; }
15+
16+
[JsonProperty("last_name")]
17+
public string LastName { get; set; }
18+
19+
[JsonProperty("locale")]
20+
public string Locale { get; set; }
21+
22+
[JsonProperty("logo_url")]
23+
public string LogoUrl { get; set; }
24+
25+
[JsonProperty("page_title")]
26+
public string PageTitle { get; set; }
27+
28+
[JsonProperty("pay_later_asset_urls_descriptive")]
29+
public string PayLaterAssetUrlsDescriptive { get; set; }
30+
31+
[JsonProperty("pay_later_asset_urls_standard")]
32+
public string PayLaterAssetUrlsStandard { get; set; }
33+
34+
[JsonProperty("pay_later_name")]
35+
public string PayLaterName { get; set; }
36+
37+
[JsonProperty("pay_later_redirect_url")]
38+
public string PayLaterRedirectUrl { get; set; }
39+
40+
[JsonProperty("pay_now_asset_urls_descriptive")]
41+
public string PayNowAssetUrlsDescriptive { get; set; }
42+
43+
[JsonProperty("pay_now_asset_urls_standard")]
44+
public string PayNowAssetUrlsStandard { get; set; }
45+
46+
[JsonProperty("pay_now_name")]
47+
public string PayNowName { get; set; }
48+
49+
[JsonProperty("pay_now_redirect_url")]
50+
public string PayNowRedirectUrl { get; set; }
51+
52+
[JsonProperty("pay_over_time_asset_urls_descriptive")]
53+
public string PayOverTimeAssetUrlsDescriptive { get; set; }
54+
55+
[JsonProperty("pay_over_time_asset_urls_standard")]
56+
public string PayOverTimeAssetUrlsStandard { get; set; }
57+
58+
[JsonProperty("pay_over_time_name")]
59+
public string PayOverTimeName { get; set; }
60+
61+
[JsonProperty("pay_over_time_redirect_url")]
62+
public string PayOverTimeRedirectUrl { get; set; }
63+
64+
[JsonProperty("payment_method_categories")]
65+
public string PaymentMethodCategories { get; set; }
66+
67+
[JsonProperty("purchase_country")]
68+
public string PurchaseCountry { get; set; }
69+
70+
[JsonProperty("purchase_type")]
71+
public string PurchaseType { get; set; }
72+
73+
[JsonProperty("redirect_url")]
74+
public string RedirectUrl { get; set; }
75+
76+
[JsonProperty("shipping_first_name")]
77+
public string ShippingFirstName { get; set; }
78+
79+
[JsonProperty("shipping_last_name")]
80+
public string ShippingLastName { get; set; }
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class SourceSourceOrder : StripeEntity<SourceSourceOrder>
9+
{
10+
/// <summary>
11+
/// A positive integer representing the total amount for the order.
12+
/// </summary>
13+
[JsonProperty("amount")]
14+
public long Amount { get; set; }
15+
16+
/// <summary>
17+
/// The currency associated with the order.
18+
/// </summary>
19+
[JsonProperty("currency")]
20+
public string Currency { get; set; }
21+
22+
/// <summary>
23+
/// The email address of the customer placing the order.
24+
/// </summary>
25+
[JsonProperty("email")]
26+
public string Email { get; set; }
27+
28+
/// <summary>
29+
/// List of items constituting the order.
30+
/// </summary>
31+
[JsonProperty("items")]
32+
public List<SourceSourceOrderItem> Items { get; set; }
33+
34+
/// <summary>
35+
/// The shipping address for the order. Present if the order is for goods
36+
/// to be shipped.
37+
/// </summary>
38+
[JsonProperty("shipping")]
39+
public Shipping Shipping { get; set; }
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class SourceSourceOrderItem : StripeEntity<SourceSourceOrderItem>
6+
{
7+
/// <summary>
8+
/// The amount (price) for this order item.
9+
/// </summary>
10+
[JsonProperty("amount")]
11+
public long? Amount { get; set; }
12+
13+
/// <summary>
14+
/// This currency of this order item. Required when <c>amount</c> is
15+
/// present.
16+
/// </summary>
17+
[JsonProperty("currency")]
18+
public string Currency { get; set; }
19+
20+
/// <summary>
21+
/// Human-readable description for this order item.
22+
/// </summary>
23+
[JsonProperty("description")]
24+
public string Description { get; set; }
25+
26+
/// <summary>
27+
/// The quantity of this order item. When type is <c>sku</c>, this is
28+
/// the number of instances of the SKU to be ordered.
29+
/// </summary>
30+
[JsonProperty("quantity")]
31+
public long? Quantity { get; set; }
32+
33+
/// <summary>
34+
/// The type of this order item.
35+
/// </summary>
36+
[JsonProperty("type")]
37+
public string Type { get; set; }
38+
}
39+
}

src/Stripe.net/Services/Sources/SourceCreateOptions.cs

+12
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public class SourceCreateOptions : BaseOptions
7777
[JsonProperty("receiver")]
7878
public SourceReceiverOptions Receiver { get; set; }
7979

80+
/// <summary>
81+
/// Information about the items and shipping associated with the source.
82+
/// </summary>
83+
[JsonProperty("source_order")]
84+
public SourceSourceOrderOptions SourceOrder { get; set; }
85+
86+
/// <summary>
87+
/// An arbitrary string to be displayed on your customer’s statement.
88+
/// </summary>
8089
[JsonProperty("statement_descriptor")]
8190
public string StatementDescriptor { get; set; }
8291

@@ -112,6 +121,9 @@ Below we group all Source type specific paramters
112121
[JsonProperty("ideal")]
113122
public SourceIdealCreateOptions Ideal { get; set; }
114123

124+
[JsonProperty("klarna")]
125+
public SourceKlarnaCreateOptions Klarna { get; set; }
126+
115127
[JsonProperty("sepa_debit")]
116128
public SourceSepaDebitCreateOptions SepaDebit { get; set; }
117129

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
namespace Stripe
2+
{
3+
using Newtonsoft.Json;
4+
5+
public class SourceKlarnaCreateOptions : INestedOptions
6+
{
7+
[JsonProperty("background_image_url")]
8+
public string BackgroundImageUrl { get; set; }
9+
10+
[JsonProperty("client_token")]
11+
public string ClientToken { get; set; }
12+
13+
[JsonProperty("first_name")]
14+
public string FirstName { get; set; }
15+
16+
[JsonProperty("last_name")]
17+
public string LastName { get; set; }
18+
19+
[JsonProperty("locale")]
20+
public string Locale { get; set; }
21+
22+
[JsonProperty("logo_url")]
23+
public string LogoUrl { get; set; }
24+
25+
[JsonProperty("page_title")]
26+
public string PageTitle { get; set; }
27+
28+
[JsonProperty("pay_later_asset_urls_descriptive")]
29+
public string PayLaterAssetUrlsDescriptive { get; set; }
30+
31+
[JsonProperty("pay_later_asset_urls_standard")]
32+
public string PayLaterAssetUrlsStandard { get; set; }
33+
34+
[JsonProperty("pay_later_name")]
35+
public string PayLaterName { get; set; }
36+
37+
[JsonProperty("pay_later_redirect_url")]
38+
public string PayLaterRedirectUrl { get; set; }
39+
40+
[JsonProperty("pay_now_asset_urls_descriptive")]
41+
public string PayNowAssetUrlsDescriptive { get; set; }
42+
43+
[JsonProperty("pay_now_asset_urls_standard")]
44+
public string PayNowAssetUrlsStandard { get; set; }
45+
46+
[JsonProperty("pay_now_name")]
47+
public string PayNowName { get; set; }
48+
49+
[JsonProperty("pay_now_redirect_url")]
50+
public string PayNowRedirectUrl { get; set; }
51+
52+
[JsonProperty("pay_over_time_asset_urls_descriptive")]
53+
public string PayOverTimeAssetUrlsDescriptive { get; set; }
54+
55+
[JsonProperty("pay_over_time_asset_urls_standard")]
56+
public string PayOverTimeAssetUrlsStandard { get; set; }
57+
58+
[JsonProperty("pay_over_time_name")]
59+
public string PayOverTimeName { get; set; }
60+
61+
[JsonProperty("pay_over_time_redirect_url")]
62+
public string PayOverTimeRedirectUrl { get; set; }
63+
64+
[JsonProperty("payment_method_categories")]
65+
public string PaymentMethodCategories { get; set; }
66+
67+
[JsonProperty("purchase_country")]
68+
public string PurchaseCountry { get; set; }
69+
70+
[JsonProperty("purchase_type")]
71+
public string PurchaseType { get; set; }
72+
73+
[JsonProperty("redirect_url")]
74+
public string RedirectUrl { get; set; }
75+
76+
[JsonProperty("shipping_first_name")]
77+
public string ShippingFirstName { get; set; }
78+
79+
[JsonProperty("shipping_last_name")]
80+
public string ShippingLastName { get; set; }
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace Stripe
2+
{
3+
using System.Collections.Generic;
4+
using Newtonsoft.Json;
5+
6+
public class SourceSourceOrderItemOptions : INestedOptions
7+
{
8+
/// <summary>
9+
/// The amount (price) for this order item.
10+
/// </summary>
11+
[JsonProperty("amount")]
12+
public long? Amount { get; set; }
13+
14+
/// <summary>
15+
/// This currency of this order item. Required when amount is present.
16+
/// </summary>
17+
[JsonProperty("currency")]
18+
public string Currency { get; set; }
19+
20+
/// <summary>
21+
/// Human-readable description for this order item.
22+
/// </summary>
23+
[JsonProperty("description")]
24+
public string Description { get; set; }
25+
26+
/// <summary>
27+
/// The quantity of this order item. When type is <c>sku</c>, this is
28+
/// the number of instances of the SKU to be ordered.
29+
/// </summary>
30+
[JsonProperty("quantity")]
31+
public long? Quantity { get; set; }
32+
33+
/// <summary>
34+
/// The type of this order item. Must be <c>sku</c>, <c>tax</c>, or
35+
/// <c>shipping</c>.
36+
/// </summary>
37+
[JsonProperty("type")]
38+
public string Type { get; set; }
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Stripe
2+
{
3+
using System.Collections.Generic;
4+
using Newtonsoft.Json;
5+
6+
public class SourceSourceOrderOptions : INestedOptions
7+
{
8+
/// <summary>
9+
/// List of items constituting the order.
10+
/// </summary>
11+
[JsonProperty("items")]
12+
public List<SourceSourceOrderItemOptions> Items { get; set; }
13+
14+
/// <summary>
15+
/// The shipping address for the order. Present if the order is for
16+
/// goods to be shipped.
17+
/// </summary>
18+
[JsonProperty("shipping")]
19+
public ChargeShippingOptions Shipping { get; set; }
20+
}
21+
}

0 commit comments

Comments
 (0)