From 1df179de3c600730bb733484cedafd56cf0050fd Mon Sep 17 00:00:00 2001 From: Marco Tormento Date: Mon, 25 Nov 2024 22:46:57 +0100 Subject: [PATCH] Added missing references to MA payment and to external payment --- README.md | 2 ++ examples/create_payment.rs | 2 ++ src/apis/merchant_accounts/api.rs | 10 ++++++---- src/apis/merchant_accounts/model.rs | 4 ++-- src/apis/payments/api.rs | 8 ++++++-- src/apis/payments/model.rs | 9 +++++++++ src/lib.rs | 2 ++ tests/integration_tests/helpers.rs | 2 ++ tests/integration_tests/payments.rs | 4 ++++ 9 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 41e73c2..ddb58fc 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ let res = tl beneficiary: Beneficiary::MerchantAccount { merchant_account_id: "some-merchant-account-id".to_string(), account_holder_name: None, + reference: None, + statement_reference: None, }, }, user: User { diff --git a/examples/create_payment.rs b/examples/create_payment.rs index 9080467..6cf94c3 100644 --- a/examples/create_payment.rs +++ b/examples/create_payment.rs @@ -76,6 +76,8 @@ async fn run() -> anyhow::Result<()> { beneficiary: Beneficiary::MerchantAccount { merchant_account_id: merchant_account.id, account_holder_name: None, + reference: None, + statement_reference: None, }, }, user: CreatePaymentUserRequest::NewUser { diff --git a/src/apis/merchant_accounts/api.rs b/src/apis/merchant_accounts/api.rs index 7913868..3a913f6 100644 --- a/src/apis/merchant_accounts/api.rs +++ b/src/apis/merchant_accounts/api.rs @@ -263,7 +263,7 @@ mod tests { SweepingFrequency, TransactionPayinStatus, TransactionPayoutContextCode, TransactionPayoutStatus, TransactionType, }, - payments::{AccountIdentifier, Currency, Remitter}, + payments::{AccountIdentifier, Currency, ExternalPaymentRemitter}, payouts::PayoutBeneficiary, }, authenticator::Authenticator, @@ -745,7 +745,8 @@ mod tests { "sort_code": "sort-code", "account_number": "account-number" }, - "account_holder_name": "Mr. Holder" + "account_holder_name": "Mr. Holder", + "reference": "ext-payment-ref" } }, { @@ -832,12 +833,13 @@ mod tests { r#type: TransactionType::ExternalPayment { status: TransactionPayinStatus::Settled, settled_at: now, - remitter: Remitter { + remitter: ExternalPaymentRemitter { account_holder_name: Some("Mr. Holder".into()), account_identifier: Some(AccountIdentifier::SortCodeAccountNumber { sort_code: "sort-code".to_string(), account_number: "account-number".to_string() - }) + }), + reference: Some("ext-payment-ref".to_string()) } } }, diff --git a/src/apis/merchant_accounts/model.rs b/src/apis/merchant_accounts/model.rs index b9f1107..10585f3 100644 --- a/src/apis/merchant_accounts/model.rs +++ b/src/apis/merchant_accounts/model.rs @@ -1,5 +1,5 @@ use crate::apis::{ - payments::{AccountIdentifier, Currency, PaymentSource, Remitter}, + payments::{AccountIdentifier, Currency, ExternalPaymentRemitter, PaymentSource}, payouts::PayoutBeneficiary, }; use chrono::{DateTime, SecondsFormat, Utc}; @@ -80,7 +80,7 @@ pub enum TransactionType { ExternalPayment { status: TransactionPayinStatus, settled_at: DateTime, - remitter: Remitter, + remitter: ExternalPaymentRemitter, }, Payout { #[serde(flatten)] diff --git a/src/apis/payments/api.rs b/src/apis/payments/api.rs index 3bac2d7..684d323 100644 --- a/src/apis/payments/api.rs +++ b/src/apis/payments/api.rs @@ -476,7 +476,7 @@ mod tests { }, "beneficiary": { "type": "merchant_account", - "merchant_account_id": "merchant-account-id" + "merchant_account_id": "merchant-account-id", }, }, "user": { @@ -509,6 +509,8 @@ mod tests { beneficiary: Beneficiary::MerchantAccount { merchant_account_id: "merchant-account-id".to_string(), account_holder_name: None, + reference: None, + statement_reference: None, }, }, user: CreatePaymentUserRequest::ExistingUser { @@ -897,7 +899,9 @@ mod tests { }, beneficiary: Beneficiary::MerchantAccount { merchant_account_id: "merchant-account-id".to_string(), - account_holder_name: None + account_holder_name: None, + reference: None, + statement_reference: None } } ); diff --git a/src/apis/payments/model.rs b/src/apis/payments/model.rs index 82d3b15..b379a10 100644 --- a/src/apis/payments/model.rs +++ b/src/apis/payments/model.rs @@ -251,6 +251,8 @@ pub enum Beneficiary { MerchantAccount { merchant_account_id: String, account_holder_name: Option, + reference: Option, + statement_reference: Option, }, ExternalAccount { account_holder_name: String, @@ -311,6 +313,13 @@ pub struct Remitter { pub account_identifier: Option, } +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] +pub struct ExternalPaymentRemitter { + pub account_holder_name: Option, + pub account_identifier: Option, + pub reference: Option, +} + #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] pub struct ProviderFilter { pub countries: Option>, diff --git a/src/lib.rs b/src/lib.rs index 11543a7..2e77043 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,6 +64,8 @@ //! beneficiary: Beneficiary::MerchantAccount { //! merchant_account_id: "some-merchant-account-id".to_string(), //! account_holder_name: None, +//! reference: None, +//! statement_reference: None, //! }, //! }, //! user: CreatePaymentUserRequest::NewUser { diff --git a/tests/integration_tests/helpers.rs b/tests/integration_tests/helpers.rs index 050b843..524fd58 100644 --- a/tests/integration_tests/helpers.rs +++ b/tests/integration_tests/helpers.rs @@ -34,6 +34,8 @@ pub async fn create_closed_loop_payment( beneficiary: Beneficiary::MerchantAccount { merchant_account_id: ctx.merchant_account_gbp_id.clone(), account_holder_name: None, + reference: None, + statement_reference: None, }, }, user: CreatePaymentUserRequest::NewUser { diff --git a/tests/integration_tests/payments.rs b/tests/integration_tests/payments.rs index 9d366ff..6846fda 100644 --- a/tests/integration_tests/payments.rs +++ b/tests/integration_tests/payments.rs @@ -61,6 +61,8 @@ async fn hpp_link_returns_200() { beneficiary: Beneficiary::MerchantAccount { merchant_account_id: ctx.merchant_account_gbp_id.clone(), account_holder_name: None, + reference: None, + statement_reference: None, }, }, user: CreatePaymentUserRequest::NewUser { @@ -193,6 +195,8 @@ impl CreatePaymentScenario { ScenarioBeneficiary::ClosedLoop => Beneficiary::MerchantAccount { merchant_account_id: ctx.merchant_account_gbp_id.clone(), account_holder_name: None, + reference: Some("Reference".to_string()), + statement_reference: Some("StReference".to_string()), }, ScenarioBeneficiary::OpenLoop { ref account_identifier,