Skip to content

Commit

Permalink
Added missing references to MA payment and to external payment
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-marco-tormento committed Nov 25, 2024
1 parent 01cc479 commit 1df179d
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions examples/create_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions src/apis/merchant_accounts/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ mod tests {
SweepingFrequency, TransactionPayinStatus, TransactionPayoutContextCode,
TransactionPayoutStatus, TransactionType,
},
payments::{AccountIdentifier, Currency, Remitter},
payments::{AccountIdentifier, Currency, ExternalPaymentRemitter},
payouts::PayoutBeneficiary,
},
authenticator::Authenticator,
Expand Down Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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())
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/apis/merchant_accounts/model.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::apis::{
payments::{AccountIdentifier, Currency, PaymentSource, Remitter},
payments::{AccountIdentifier, Currency, ExternalPaymentRemitter, PaymentSource},
payouts::PayoutBeneficiary,
};
use chrono::{DateTime, SecondsFormat, Utc};
Expand Down Expand Up @@ -80,7 +80,7 @@ pub enum TransactionType {
ExternalPayment {
status: TransactionPayinStatus,
settled_at: DateTime<Utc>,
remitter: Remitter,
remitter: ExternalPaymentRemitter,
},
Payout {
#[serde(flatten)]
Expand Down
8 changes: 6 additions & 2 deletions src/apis/payments/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ mod tests {
},
"beneficiary": {
"type": "merchant_account",
"merchant_account_id": "merchant-account-id"
"merchant_account_id": "merchant-account-id",
},
},
"user": {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
);
Expand Down
9 changes: 9 additions & 0 deletions src/apis/payments/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ pub enum Beneficiary {
MerchantAccount {
merchant_account_id: String,
account_holder_name: Option<String>,
reference: Option<String>,
statement_reference: Option<String>,
},
ExternalAccount {
account_holder_name: String,
Expand Down Expand Up @@ -311,6 +313,13 @@ pub struct Remitter {
pub account_identifier: Option<AccountIdentifier>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct ExternalPaymentRemitter {
pub account_holder_name: Option<String>,
pub account_identifier: Option<AccountIdentifier>,
pub reference: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct ProviderFilter {
pub countries: Option<Vec<CountryCode>>,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_tests/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1df179d

Please sign in to comment.