Skip to content

Commit

Permalink
Add Faster Payments payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
namloan committed Aug 9, 2023
1 parent 7cafa08 commit d7c7070
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 1 deletion.
3 changes: 3 additions & 0 deletions account/src/main/java/bisq/account/accounts/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ protected bisq.account.protobuf.Account.Builder getAccountBuilder() {
case COUNTRYBASEDACCOUNT: {
return CountryBasedAccount.fromProto(proto);
}
case FASTERPAYMENTSACCOUNT: {
return FasterPaymentsAccount.fromProto(proto);
}
case MESSAGE_NOT_SET: {
throw new UnresolvableProtobufMessageException(proto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public static AccountPayload fromProto(bisq.account.protobuf.AccountPayload prot
case USERDEFINEDFIATACCOUNTPAYLOAD: {
return UserDefinedFiatAccountPayload.fromProto(proto);
}
case FASTERPAYMENTSACCOUNTPAYLOAD: {
return FasterPaymentsAccountPayload.fromProto(proto);
}
case MESSAGE_NOT_SET: {
throw new UnresolvableProtobufMessageException(proto);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package bisq.account.accounts;

import bisq.account.payment_method.FiatPaymentMethod;
import bisq.account.payment_method.FiatPaymentRail;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@Getter
@Slf4j
@ToString
@EqualsAndHashCode(callSuper = true)
public final class FasterPaymentsAccount extends Account<FasterPaymentsAccountPayload, FiatPaymentMethod> {

private static final FiatPaymentMethod PAYMENT_METHOD = FiatPaymentMethod.fromPaymentRail(FiatPaymentRail.FASTER_PAYMENTS);


public FasterPaymentsAccount(long creationDate, String accountName, FasterPaymentsAccountPayload accountPayload) {
super(creationDate, accountName, PAYMENT_METHOD, accountPayload);
}

@Override
public bisq.account.protobuf.Account toProto() {
return getAccountBuilder()
.setFasterPaymentsAccount(bisq.account.protobuf.FasterPaymentsAccount.newBuilder())
.build();
}

public static FasterPaymentsAccount fromProto(bisq.account.protobuf.Account proto) {
return new FasterPaymentsAccount(
proto.getCreationDate(),
proto.getAccountName(),
FasterPaymentsAccountPayload.fromProto(proto.getAccountPayload()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package bisq.account.accounts;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@Getter
@Slf4j
@ToString
@EqualsAndHashCode(callSuper = true)
public final class FasterPaymentsAccountPayload extends AccountPayload {

private final String sortCode;
private final String accountNr;

public FasterPaymentsAccountPayload(String id, String paymentMethodName, String sortCode, String accountNr) {
super(id, paymentMethodName);
this.sortCode = sortCode;
this.accountNr = accountNr;
}

@Override
public bisq.account.protobuf.AccountPayload toProto() {
return getAccountPayloadBuilder()
.setFasterPaymentsAccountPayload(bisq.account.protobuf.FasterPaymentsAccountPayload.newBuilder()
.setSortCode(sortCode)
.setAccountNr(accountNr))
.build();
}

public static FasterPaymentsAccountPayload fromProto(bisq.account.protobuf.AccountPayload account) {
var fasterPaymentsPayload = account.getFasterPaymentsAccountPayload();
return new FasterPaymentsAccountPayload(
account.getId(),
account.getPaymentMethodName(),
fasterPaymentsPayload.getSortCode(),
fasterPaymentsPayload.getAccountNr());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public enum FiatPaymentRail implements PaymentRail {
ACH_TRANSFER(List.of("US"), List.of("USD")),
PIX(List.of("BR"), List.of("BRL")),
FASTER_PAYMENTS(List.of("GB"), List.of("GBP"));

@Getter
@EqualsAndHashCode.Exclude
private final List<Country> countries;
Expand Down Expand Up @@ -124,7 +125,6 @@ public boolean supportsCurrency(String currencyCode) {
WECHAT_PAY=WeChat Pay
SEPA=SEPA
SEPA_INSTANT=SEPA Instant Payments
FASTER_PAYMENTS=Faster Payments
SWISH=Swish
ZELLE=Zelle
CHASE_QUICK_PAY=Chase QuickPay
Expand Down
10 changes: 10 additions & 0 deletions account/src/main/proto/account.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ message AccountPayload {
UserDefinedFiatAccountPayload userDefinedFiatAccountPayload = 20;
RevolutAccountPayload RevolutAccountPayload = 21;
CountryBasedAccountPayload countryBasedAccountPayload = 22;
FasterPaymentsAccountPayload fasterPaymentsAccountPayload = 23;
}
}
message UserDefinedFiatAccountPayload {
Expand Down Expand Up @@ -123,6 +124,11 @@ message PixAccountPayload {
string pix_key = 1;
}

message FasterPaymentsAccountPayload {
string sort_code = 1;
string account_nr = 2;
}

// Account
message Account {
sint64 creationDate = 1;
Expand All @@ -135,6 +141,7 @@ message Account {
UserDefinedFiatAccount userDefinedFiatAccount = 20;
RevolutAccount revolutAccount = 21;
CountryBasedAccount countryBasedAccount = 22;
FasterPaymentsAccount fasterPaymentsAccount = 23;
}
}

Expand Down Expand Up @@ -169,6 +176,9 @@ message AchTransferAccount {
message PixAccount {
}

message FasterPaymentsAccount {
}

message AccountStore {
map<string, Account> accountByName = 1;
optional Account selectedAccount = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package bisq.account.accounts;

import bisq.account.protobuf.Account;
import bisq.account.protobuf.AccountPayload;
import bisq.account.protobuf.FasterPaymentsAccount;
import bisq.account.protobuf.FasterPaymentsAccountPayload;
import bisq.account.protobuf.FiatPaymentMethod;
import bisq.account.protobuf.PaymentMethod;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class FasterPaymentsAccountTest {

private static final bisq.account.protobuf.Account PROTO = Account.newBuilder()
.setAccountName("accountName")
.setCreationDate(123)
.setPaymentMethod(
PaymentMethod.newBuilder()
.setName("FASTER_PAYMENTS")
.setFiatPaymentMethod(
FiatPaymentMethod.newBuilder()))
.setAccountPayload(AccountPayload.newBuilder()
.setId("id")
.setPaymentMethodName("FASTER_PAYMENTS")
.setFasterPaymentsAccountPayload(FasterPaymentsAccountPayload.newBuilder()
.setSortCode("sortCode")
.setAccountNr("accountNr")))
.setFasterPaymentsAccount(FasterPaymentsAccount.newBuilder())
.build();

private static final bisq.account.accounts.FasterPaymentsAccount ACCOUNT = new bisq.account.accounts.FasterPaymentsAccount(
123,
"accountName",
new bisq.account.accounts.FasterPaymentsAccountPayload("id", "FASTER_PAYMENTS", "sortCode", "accountNr")
);

@Test
void toProto() {
var result = ACCOUNT.toProto();
assertThat(result)
.usingRecursiveComparison()
.isEqualTo(PROTO);
}

@Test
void fromProto() {
var result = bisq.account.accounts.FasterPaymentsAccount.fromProto(PROTO);
assertThat(result)
.usingRecursiveComparison()
.isEqualTo(ACCOUNT);
}
}
3 changes: 3 additions & 0 deletions desktop/src/main/resources/css/images.css
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@
-fx-image: url("/images/payment/Pix.png");
}

#FASTER_PAYMENTS {
-fx-image: url("/images/payment/FasterPayments.png");
}

/* Onboarding icons*/
#info-circle-solid {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d7c7070

Please sign in to comment.