Skip to content

Commit

Permalink
Create PaymentAddressDetails record and add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Viincenttt committed Jul 9, 2024
1 parent afa543c commit 59e04ea
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 30 deletions.
25 changes: 0 additions & 25 deletions src/Mollie.Api/Models/AddressObject.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
namespace Mollie.Api.Models {
public record AddressObject {
/// <summary>
/// The title of the person, for example Mr. or Mrs..
/// </summary>
public string? Title { get; set; }

/// <summary>
/// The given name (first name) of the person should be at least two characters and cannot contain only numbers.
/// </summary>
public string? GivenName { get; set; }

/// <summary>
/// The given family name (surname) of the person should be at least two characters and cannot contain only numbers.
/// </summary>
public string? FamilyName { get; set; }

/// <summary>
/// The name of the organization, in case the addressee is an organization.
/// </summary>
public string? OrganizationName { get; set; }

/// <summary>
/// The card holder’s street and street number.
/// </summary>
Expand All @@ -35,11 +15,6 @@ public record AddressObject {
/// </summary>
public string? PostalCode { get; set; }

/// <summary>
/// Email address
/// </summary>
public string? Email { get; set; }

/// <summary>
/// The card holder’s city.
/// </summary>
Expand Down
35 changes: 35 additions & 0 deletions src/Mollie.Api/Models/Payment/PaymentAddressDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Mollie.Api.Models.Payment;

public record PaymentAddressDetails : AddressObject {
/// <summary>
/// The person’s organization, if applicable.
/// </summary>
public string? OrganizationName { get; set; }

/// <summary>
/// The title of the person, for example Mr. or Mrs..
/// </summary>
public string? Title { get; set; }

/// <summary>
/// The given name (first name) of the person.
/// </summary>
public string? GivenName { get; set; }

/// <summary>
/// The family name (surname) of the person.
/// </summary>
public string? FamilyName { get; set; }

/// <summary>
/// The email address of the person.
/// </summary>
public string? Email { get; set; }

/// <summary>
/// The phone number of the person. Some payment methods require this information. If you have it, you
/// should pass it so that your customer does not have to enter it again in the checkout. Must be in
/// the E.164 format. For example +31208202070.
/// </summary>
public string? Phone { get; set; }
}
4 changes: 2 additions & 2 deletions src/Mollie.Api/Models/Payment/Request/PaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public record PaymentRequest
/// The customer's billing address details. We advise to provide these details to improve fraud protection and conversion. This is
/// particularly relevant for card payments.
/// </summary>
public AddressObject? BillingAddress { get; set; }
public PaymentAddressDetails? BillingAddress { get; set; }

/// <summary>
/// The customer's shipping address details. We advise to provide these details to improve fraud protection and conversion. This is
/// particularly relevant for card payments.
/// </summary>
public AddressObject? ShippingAddress { get; set; }
public PaymentAddressDetails? ShippingAddress { get; set; }

/// <summary>
/// Allows you to preset the language to be used in the payment screens shown to the consumer. Setting a locale is highly
Expand Down
4 changes: 2 additions & 2 deletions src/Mollie.Api/Models/Payment/Response/PaymentResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ public record PaymentResponse
/// The customer's billing address details. We advise to provide these details to improve fraud protection and conversion. This is
/// particularly relevant for card payments.
/// </summary>
public AddressObject? BillingAddress { get; set; }
public PaymentAddressDetails? BillingAddress { get; set; }

/// <summary>
/// The customer's shipping address details. We advise to provide these details to improve fraud protection and conversion. This is
/// particularly relevant for card payments.
/// </summary>
public AddressObject? ShippingAddress { get; set; }
public PaymentAddressDetails? ShippingAddress { get; set; }

/// <summary>
/// An optional routing configuration that you provided, which enables you to route a successful payment, or part of the payment, to one or more connected accounts.
Expand Down
19 changes: 18 additions & 1 deletion tests/Mollie.Tests.Integration/Api/PaymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ public async Task CanCreatePaymentWithCustomMetaDataClass() {
[DefaultRetryFact]
public async Task CanCreatePaymentWithLines() {
// Arrange
var address = new PaymentAddressDetails {
Title = "Mr",
GivenName = "John",
FamilyName = "Doe",
OrganizationName = "Mollie",
StreetAndNumber = "Keizersgracht 126",
Email = "[email protected]",
City = "Amsterdam",
Country = "NL",
Phone = "+31600000000",
Region = "Zuid-Holland",
PostalCode = "1015CW"
};
PaymentRequest paymentRequest = new PaymentRequest() {
Amount = new Amount(Currency.EUR, 90m),
Description = "Description",
Expand All @@ -382,14 +395,18 @@ public async Task CanCreatePaymentWithLines() {
VatAmount = new Amount(Currency.EUR, 15.62m),
VatRate = "21.00"
}
}
},
ShippingAddress = address,
BillingAddress = address
};

// Act
PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest);

// Assert
result.Lines.Should().BeEquivalentTo(paymentRequest.Lines);
result.BillingAddress.Should().BeEquivalentTo(paymentRequest.BillingAddress);
result.ShippingAddress.Should().BeEquivalentTo(paymentRequest.ShippingAddress);
}

[DefaultRetryFact]
Expand Down

0 comments on commit 59e04ea

Please sign in to comment.