forked from bisq-network/bisq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new payment method "Faster Payments System (SBP)" for Russian Ruble
This is the standard P2P payment method in Russia to perform funds transfers and payments between Russian bank accounts in Russian Rubles. There is no chargeback risk. Recipient bank account is located using telephone number and bank name, and sender receives recipients first name, middle name, and initial of last name to confirm the phone number entered is correct before sending. Adding this new payment method has been discussed at length on the GitHub 'growth' channel at: bisq-network/growth#288
- Loading branch information
Showing
14 changed files
with
439 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.core.payment; | ||
|
||
import bisq.core.locale.FiatCurrency; | ||
import bisq.core.locale.TradeCurrency; | ||
import bisq.core.payment.payload.SbpAccountPayload; | ||
import bisq.core.payment.payload.PaymentAccountPayload; | ||
import bisq.core.payment.payload.PaymentMethod; | ||
|
||
import java.util.List; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.NonNull; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
public final class SbpAccount extends PaymentAccount { | ||
|
||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("RUB")); | ||
|
||
public SbpAccount() { | ||
super(PaymentMethod.SBP); | ||
setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0)); | ||
} | ||
|
||
@Override | ||
protected PaymentAccountPayload createPayload() { | ||
return new SbpAccountPayload(paymentMethod.getId(), id); | ||
} | ||
|
||
@Override | ||
public @NonNull List<TradeCurrency> getSupportedCurrencies() { | ||
return SUPPORTED_CURRENCIES; | ||
} | ||
|
||
public String getMessageForAccountCreation() { | ||
return "payment.sbp.info.account"; | ||
} | ||
|
||
public void setMobileNumber(String mobileNumber) { | ||
((SbpAccountPayload) paymentAccountPayload).setMobileNumber(mobileNumber); | ||
} | ||
|
||
public String getMobileNumber() { | ||
return ((SbpAccountPayload) paymentAccountPayload).getMobileNumber(); | ||
} | ||
|
||
public void setBankName(String bankName) { | ||
((SbpAccountPayload) paymentAccountPayload).setBankName(bankName); | ||
} | ||
|
||
public String getBankName() { | ||
return ((SbpAccountPayload) paymentAccountPayload).getBankName(); | ||
} | ||
|
||
public void setHolderName(String holderName) { | ||
((SbpAccountPayload) paymentAccountPayload).setHolderName(holderName); | ||
} | ||
|
||
public String getHolderName() { | ||
return ((SbpAccountPayload) paymentAccountPayload).getHolderName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
core/src/main/java/bisq/core/payment/payload/SbpAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.core.payment.payload; | ||
|
||
import bisq.core.locale.Res; | ||
|
||
import com.google.protobuf.Message; | ||
|
||
import org.apache.commons.lang3.ArrayUtils; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@ToString | ||
@Setter | ||
@Getter | ||
@Slf4j | ||
public final class SbpAccountPayload extends PaymentAccountPayload implements PayloadWithHolderName { | ||
private String mobileNumber = ""; | ||
private String holderName = ""; | ||
private String bankName = ""; | ||
|
||
public SbpAccountPayload(String paymentMethod, String id) { | ||
super(paymentMethod, id); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// PROTO BUFFER | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
private SbpAccountPayload(String paymentMethod, | ||
String id, | ||
String mobileNumber, | ||
String holderName, | ||
String bankName, | ||
long maxTradePeriod, | ||
Map<String, String> excludeFromJsonDataMap) { | ||
super(paymentMethod, | ||
id, | ||
maxTradePeriod, | ||
excludeFromJsonDataMap); | ||
|
||
this.mobileNumber = mobileNumber; | ||
this.holderName = holderName; | ||
this.bankName = bankName; | ||
} | ||
|
||
@Override | ||
public Message toProtoMessage() { | ||
return getPaymentAccountPayloadBuilder() | ||
.setSbpAccountPayload(protobuf.SbpAccountPayload.newBuilder() | ||
.setMobileNumber(mobileNumber) | ||
.setHolderName(holderName) | ||
.setBankName(bankName)) | ||
.build(); | ||
} | ||
|
||
public static SbpAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { | ||
return new SbpAccountPayload(proto.getPaymentMethodId(), | ||
proto.getId(), | ||
proto.getSbpAccountPayload().getMobileNumber(), | ||
proto.getSbpAccountPayload().getHolderName(), | ||
proto.getSbpAccountPayload().getBankName(), | ||
proto.getMaxTradePeriod(), | ||
new HashMap<>(proto.getExcludeFromJsonDataMap())); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// API | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
@Override | ||
public String getPaymentDetails() { | ||
return Res.get(paymentMethodId) + " - " + | ||
Res.getWithCol("payment.account.owner.sbp") + " " + holderName + ", " + | ||
Res.getWithCol("payment.mobile") + " " + mobileNumber + ", " + | ||
Res.getWithCol("payment.bank.name") + " " + bankName; | ||
} | ||
|
||
@Override | ||
public String getPaymentDetailsForTradePopup() { | ||
return Res.getWithCol("payment.account.owner.sbp") + " " + holderName + "\n" + | ||
Res.getWithCol("payment.mobile") + " " + mobileNumber + "\n" + | ||
Res.getWithCol("payment.bank.name") + " " + bankName; | ||
} | ||
|
||
@Override | ||
public byte[] getAgeWitnessInputData() { | ||
// We don't add holderName because we don't want to break age validation if the user recreates an account with | ||
// slight changes in holder name (e.g. add or remove middle name) | ||
return super.getAgeWitnessInputData( | ||
ArrayUtils.addAll( | ||
mobileNumber.getBytes(StandardCharsets.UTF_8), | ||
bankName.getBytes(StandardCharsets.UTF_8) | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
public String getOwnerId() { | ||
return holderName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.