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 source_mandate_notification in the library #1097

Merged
merged 1 commit into from
Feb 13, 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
1 change: 1 addition & 0 deletions src/Stripe.Tests.XUnit/Stripe.Tests.XUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<EmbeddedResource Include="events\event.json" />
<EmbeddedResource Include="source_mandate_notifications\source_mandate_notification.json" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions src/Stripe.Tests.XUnit/source_mandate_notifications/_fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.IO;
using System.Reflection;
using System.Text;

namespace Stripe.Tests.Xunit
{
public class source_mandate_notifications_fixture
{
internal string StripeJson { get; set; }

public source_mandate_notifications_fixture()
{
StripeJson = new StreamReader(
typeof(when_constructing_a_source_mandate_notification).GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit.source_mandate_notifications.source_mandate_notification.json"),
Encoding.UTF8
).ReadToEnd();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"id": "srcmn_1234",
"object": "source_mandate_notification",
"amount": 1000,
"created": 1516981090,
"livemode": false,
"reason": "debit_initiated",
"source": {
"id": "src_123",
"object": "source",
"amount": null,
"client_secret": "src_client_secret_123",
"created": 1516981089,
"currency": "eur",
"customer": "cus_123",
"flow": "none",
"livemode": false,
"mandate": {
"acceptance": {
"date": null,
"ip": null,
"status": "pending",
"user_agent": null
},
"notification_method": "manual",
"reference": "OAAAAAAAAAAAAAAO",
"url": "https://hooks.stripe.com/adapter/sepa_debit/file/src_123/src_client_secret_123"
},
"metadata": {
},
"owner": {
"address": {
"city": "City",
"country": "DE",
"line1": "line1",
"line2": null,
"postal_code": "11111",
"state": null
},
"email": null,
"name": "Jenny Rosen",
"phone": null,
"verified_address": null,
"verified_email": null,
"verified_name": null,
"verified_phone": null
},
"statement_descriptor": null,
"status": "chargeable",
"type": "sepa_debit",
"usage": "reusable",
"sepa_debit": {
"bank_code": "11111111",
"country": "DE",
"fingerprint": "123",
"last4": "3000",
"mandate_reference": "OAAAAAAAAAAAAAAO",
"mandate_url": "https://hooks.stripe.com/adapter/sepa_debit/file/src_123/src_client_secret_123",
"branch_code": null
}
},
"status": "pending",
"type": "sepa_debit",
"sepa_debit": {
"creditor_identifier": "TEST111111111111111",
"last4": "3000",
"mandate_reference": "OAAAAAAAAAAAAAAO"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using FluentAssertions;
using Xunit;

namespace Stripe.Tests.Xunit
{
public class when_constructing_a_source_mandate_notification : IClassFixture<source_mandate_notifications_fixture>
{
private readonly source_mandate_notifications_fixture fixture;
public StripeSourceMandateNotification Notification { get; set; }

public when_constructing_a_source_mandate_notification(source_mandate_notifications_fixture fixture)
{
this.fixture = fixture;
}

[Fact]
public void it_should_load_the_right_data()
{
Notification = Mapper<StripeSourceMandateNotification>.MapFromJson(fixture.StripeJson);

Notification.Should().NotBeNull();
Notification.Id.Should().Be("srcmn_1234");
Notification.Object.Should().Be("source_mandate_notification");
Notification.Amount.Should().Be(1000);
Notification.LiveMode.Should().Be(false);
Notification.Reason.Should().Be("debit_initiated");
Notification.Status.Should().Be("pending");
Notification.Type.Should().Be("sepa_debit");
Notification.Source.Id.Should().Be("src_123");
Notification.Source.Type.Should().Be("sepa_debit");
Notification.SepaDebit.CreditorIdentifier.Should().Be("TEST111111111111111");
Notification.SepaDebit.MandateReference.Should().Be("OAAAAAAAAAAAAAAO");
Notification.SepaDebit.Last4.Should().Be("3000");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

namespace Stripe
{
public class StripeSourceMandateNotification : StripeEntityWithId
{
[JsonProperty("object")]
public string Object => "source_mandate_notification";

[JsonProperty("amount")]
public int? Amount { get; set; }

[JsonProperty("created")]
[JsonConverter(typeof(StripeDateTimeConverter))]
public DateTime Created { get; set; }

[JsonProperty("livemode")]
public bool LiveMode { get; set; }

[JsonProperty("reason")]
public string Reason { get; set; }

[JsonProperty("source")]
public StripeSource Source { get; set; }

[JsonProperty("status")]
public string Status { get; set; }

[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("sepa_debit")]
public StripeSourceMandateNotificationSepaDebit SepaDebit { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace Stripe
{
public class StripeSourceMandateNotificationSepaDebit : StripeEntity
{
[JsonProperty("creditor_identifier")]
public string CreditorIdentifier { get; set; }

[JsonProperty("last4")]
public string Last4 { get; set; }

[JsonProperty("mandate_reference")]
public string MandateReference { get; set; }
}
}