Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Amazon eGift Card payment method #4788

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions core/src/main/java/bisq/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,24 @@ public static List<TradeCurrency> getAllTransferwiseCurrencies() {
return currencies;
}

public static List<TradeCurrency> getAllAmazonGiftCardCurrencies() {
List<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
new FiatCurrency("AUD"),
new FiatCurrency("CAD"),
new FiatCurrency("EUR"),
new FiatCurrency("GBP"),
new FiatCurrency("INR"),
new FiatCurrency("JPY"),
new FiatCurrency("SAR"),
new FiatCurrency("SEK"),
new FiatCurrency("SGD"),
new FiatCurrency("TRY"),
new FiatCurrency("USD")
));
currencies.sort(Comparator.comparing(TradeCurrency::getCode));
return currencies;
}

// https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange
public static List<TradeCurrency> getAllRevolutCurrencies() {
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
Expand Down
46 changes: 46 additions & 0 deletions core/src/main/java/bisq/core/payment/AmazonGiftCardAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.payment.payload.AmazonGiftCardAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;

public final class AmazonGiftCardAccount extends PaymentAccount {

public AmazonGiftCardAccount() {
super(PaymentMethod.AMAZON_GIFT_CARD);
}

@Override
protected PaymentAccountPayload createPayload() {
return new AmazonGiftCardAccountPayload(paymentMethod.getId(), id);
}

public String getEmailOrMobileNr() {
return getAmazonGiftCardAccountPayload().getEmailOrMobileNr();
}

public void setEmailOrMobileNr(String emailOrMobileNr) {
getAmazonGiftCardAccountPayload().setEmailOrMobileNr(emailOrMobileNr);
}

private AmazonGiftCardAccountPayload getAmazonGiftCardAccountPayload() {
return (AmazonGiftCardAccountPayload) paymentAccountPayload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new AdvancedCashAccount();
case PaymentMethod.TRANSFERWISE_ID:
return new TransferwiseAccount();
case PaymentMethod.AMAZON_GIFT_CARD_ID:
return new AmazonGiftCardAccount();
case PaymentMethod.BLOCK_CHAINS_INSTANT_ID:
return new InstantCryptoCurrencyAccount();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* 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 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 class AmazonGiftCardAccountPayload extends PaymentAccountPayload {
private String emailOrMobileNr;

public AmazonGiftCardAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

private AmazonGiftCardAccountPayload(String paymentMethodName,
String id,
String emailOrMobileNr,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethodName,
id,
maxTradePeriod,
excludeFromJsonDataMap);
this.emailOrMobileNr = emailOrMobileNr;
}

@Override
public Message toProtoMessage() {
protobuf.AmazonGiftCardAccountPayload.Builder builder =
protobuf.AmazonGiftCardAccountPayload.newBuilder()
.setEmailOrMobileNr(emailOrMobileNr);
return getPaymentAccountPayloadBuilder()
.setAmazonGiftCardAccountPayload(builder)
.build();
}

public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.AmazonGiftCardAccountPayload amazonGiftCardAccountPayload = proto.getAmazonGiftCardAccountPayload();
return new AmazonGiftCardAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
amazonGiftCardAccountPayload.getEmailOrMobileNr(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}


///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
}

@Override
public String getPaymentDetailsForTradePopup() {
return Res.getWithCol("payment.email.mobile") + " " + emailOrMobileNr;
}

@Override
public byte[] getAgeWitnessInputData() {
String data = "AmazonGiftCard" + emailOrMobileNr;
return super.getAgeWitnessInputData(data.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static final String PROMPT_PAY_ID = "PROMPT_PAY";
public static final String ADVANCED_CASH_ID = "ADVANCED_CASH";
public static final String TRANSFERWISE_ID = "TRANSFERWISE";
public static final String AMAZON_GIFT_CARD_ID = "AMAZON_GIFT_CARD";
public static final String BLOCK_CHAINS_INSTANT_ID = "BLOCK_CHAINS_INSTANT";

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -132,6 +133,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod PROMPT_PAY;
public static PaymentMethod ADVANCED_CASH;
public static PaymentMethod TRANSFERWISE;
public static PaymentMethod AMAZON_GIFT_CARD;
public static PaymentMethod BLOCK_CHAINS_INSTANT;

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -176,6 +178,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
SPECIFIC_BANKS = new PaymentMethod(SPECIFIC_BANKS_ID, 4 * DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
HAL_CASH = new PaymentMethod(HAL_CASH_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
F2F = new PaymentMethod(F2F_ID, 4 * DAY, DEFAULT_TRADE_LIMIT_LOW_RISK),
AMAZON_GIFT_CARD = new PaymentMethod(AMAZON_GIFT_CARD_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),

// Trans national
UPHOLD = new PaymentMethod(UPHOLD_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/proto/CoreProtoResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import bisq.core.dao.governance.proposal.storage.appendonly.ProposalPayload;
import bisq.core.payment.payload.AdvancedCashAccountPayload;
import bisq.core.payment.payload.AliPayAccountPayload;
import bisq.core.payment.payload.AmazonGiftCardAccountPayload;
import bisq.core.payment.payload.AustraliaPayidPayload;
import bisq.core.payment.payload.CashAppAccountPayload;
import bisq.core.payment.payload.CashDepositAccountPayload;
Expand Down Expand Up @@ -151,6 +152,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return AdvancedCashAccountPayload.fromProto(proto);
case TRANSFERWISE_ACCOUNT_PAYLOAD:
return TransferwiseAccountPayload.fromProto(proto);
case AMAZON_GIFT_CARD_ACCOUNT_PAYLOAD:
return AmazonGiftCardAccountPayload.fromProto(proto);
case INSTANT_CRYPTO_CURRENCY_ACCOUNT_PAYLOAD:
return InstantCryptoCurrencyPayload.fromProto(proto);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ private enum PaymentMethodMapper {
PROMPT_PAY,
ADVANCED_CASH,
BLOCK_CHAINS_INSTANT,
TRANSFERWISE
TRANSFERWISE,
AMAZON_GIFT_CARD
}

@Getter
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ portfolio.pending.step2_buyer.moneyGram.extra=IMPORTANT REQUIREMENT:\nAfter you
portfolio.pending.step2_buyer.westernUnion=Please pay {0} to the BTC seller by using Western Union.\n\n
portfolio.pending.step2_buyer.westernUnion.extra=IMPORTANT REQUIREMENT:\nAfter you have done the payment send the MTCN (tracking number) and a photo of the receipt by email to the BTC seller.\n\
The receipt must clearly show the seller''s full name, city, country and the amount. The seller''s email is: {0}.
# suppress inspection "TrailingSpacesInProperty"
portfolio.pending.step2_buyer.amazonGiftCard=Please purchase an Amazon eGift Card for {0} at your Amazon account and \
use the BTC seller''s email or mobile number as receiver. \
In case the trade amount exceeds the permitted amount send multiple cards.\n\n

# suppress inspection "TrailingSpacesInProperty"
portfolio.pending.step2_buyer.postal=Please send {0} by \"US Postal Money Order\" to the BTC seller.\n\n
Expand Down Expand Up @@ -742,6 +746,9 @@ portfolio.pending.step3_seller.westernUnion=The buyer has to send you the MTCN (
Only confirm receipt after you have successfully picked up the money!
portfolio.pending.step3_seller.halCash=The buyer has to send you the HalCash code as text message. Beside that you will receive a message from HalCash with the required information to withdraw the EUR from a HalCash supporting ATM.\n\n\
After you have picked up the money from the ATM please confirm here the receipt of the payment!
portfolio.pending.step3_seller.amazonGiftCard=The buyer has sent you an Amazon eGift Card by email or by text \
message to your mobile phone. Please redeem now the Amazon eGift Card at your Amazon account and once accepted \
confirm the payment receipt.

portfolio.pending.step3_seller.bankCheck=\n\nPlease also verify that the name of the sender specified on the trade contract matches the name that appears on your bank statement:\nSender''s name, per trade contract: {0}\n\n\
If the names are not exactly the same, {1}
Expand Down Expand Up @@ -3278,6 +3285,11 @@ payment.payid=PayID linked to financial institution. Like email address or mobil
payment.payid.info=A PayID like a phone number, email address or an Australian Business Number (ABN), that you can securely link to your \
bank, credit union or building society account. You need to have already created a PayID with your Australian financial institution. \
Both sending and receiving financial institutions must support PayID. For more information please check [HYPERLINK:https://payid.com.au/faqs/]
payment.amazonGiftCard.info=To pay with Amazon eGift Card you need to purchase an Amazon eGift Card at your Amazon account and \
use the BTC seller''s email or mobile nr. as receiver. Amazon send then an email or text message to the receiver. \
Use the trade ID for the message field.\n\n\
Amazon eGift Cards can only be redeemed by Amazon accounts with the same currency.\n\n\
For more information visit the Amazon eGift Card webpage. [HYPERLINK:https://www.amazon.com/Amazon-1_US_Email-eGift-Card/dp/B004LLIKVU]

# We use constants from the code so we do not use our normal naming convention
# dynamic values are not recognized by IntelliJ
Expand Down Expand Up @@ -3355,6 +3367,8 @@ ADVANCED_CASH=Advanced Cash
# suppress inspection "UnusedProperty"
TRANSFERWISE=TransferWise
# suppress inspection "UnusedProperty"
AMAZON_GIFT_CARD=Amazon eGift Card
# suppress inspection "UnusedProperty"
BLOCK_CHAINS_INSTANT=Altcoins Instant

# Deprecated: Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -3405,6 +3419,8 @@ ADVANCED_CASH_SHORT=Advanced Cash
# suppress inspection "UnusedProperty"
TRANSFERWISE_SHORT=TransferWise
# suppress inspection "UnusedProperty"
AMAZON_GIFT_CARD_SHORT=Amazon eGift Card
# suppress inspection "UnusedProperty"
BLOCK_CHAINS_INSTANT_SHORT=Altcoins Instant

# Deprecated: Cannot be deleted as it would break old trade history entries
Expand Down
Loading