Skip to content

Commit

Permalink
1. Pass lang to more_info_url
Browse files Browse the repository at this point in the history
2. Added REFUNDED status to WithdrawTransactionResponse and DepositTransactionResponse.
  • Loading branch information
lijamie98 committed Jun 6, 2022
1 parent 737d88d commit 3f202b3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id("org.jetbrains.kotlin.jvm") version "1.6.10"
}

version = "1.0.8"
version = "1.0.11"

dependencies {
compileOnly(libs.servlet.api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static DepositTransactionResponse of(
JwtService jwtService,
Sep24Config sep24Config,
Sep24Transaction txn,
String lang,
boolean allowMoreInfoUrl)
throws MalformedURLException, URISyntaxException {
String strJson = gson.toJson(txn);
Expand All @@ -45,7 +46,7 @@ public static DepositTransactionResponse of(
txnR.depositMemoType = txn.getMemoType();

if (allowMoreInfoUrl && needsMoreInfoUrlDeposit.contains(txn.getStatus())) {
txnR.moreInfoUrl = constructMoreInfoUrl(jwtService, sep24Config, txn);
txnR.moreInfoUrl = constructMoreInfoUrl(jwtService, sep24Config, txn, lang);
} else {
txnR.moreInfoUrl = null;
}
Expand All @@ -58,6 +59,7 @@ public static DepositTransactionResponse of(
PENDING_USR_TRANSFER_START.toString(),
PENDING_USR_TRANSFER_COMPLETE.toString(),
COMPLETED.toString(),
REFUNDED.toString(),
PENDING_EXTERNAL.toString(),
PENDING_ANCHOR.toString(),
PENDING_USER.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class TransactionResponse {
static final Gson gson = new Gson();

static String constructMoreInfoUrl(
JwtService jwtService, Sep24Config sep24Config, Sep24Transaction txn)
JwtService jwtService, Sep24Config sep24Config, Sep24Transaction txn, String lang)
throws URISyntaxException, MalformedURLException {

JwtToken token =
Expand All @@ -97,6 +97,10 @@ static String constructMoreInfoUrl(
.addParameter("transaction_id", txn.getTransactionId())
.addParameter("token", jwtService.encode(token));

if (lang != null) {
builder.addParameter("lang", lang);
}

return builder.build().toURL().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static WithdrawTransactionResponse of(
JwtService jwtService,
Sep24Config sep24Config,
Sep24Transaction txn,
String lang,
boolean allowMoreInfoUrl)
throws MalformedURLException, URISyntaxException {
String strJson = gson.toJson(txn);
Expand All @@ -48,7 +49,7 @@ public static WithdrawTransactionResponse of(
txnR.withdrawAnchorAccount = txn.getReceivingAnchorAccount();

if (allowMoreInfoUrl && needsMoreInfoUrlWithdraw.contains(txn.getStatus())) {
txnR.moreInfoUrl = constructMoreInfoUrl(jwtService, sep24Config, txn);
txnR.moreInfoUrl = constructMoreInfoUrl(jwtService, sep24Config, txn, lang);
} else {
txnR.moreInfoUrl = null;
}
Expand All @@ -61,6 +62,7 @@ public static WithdrawTransactionResponse of(
PENDING_USR_TRANSFER_START.toString(),
PENDING_USR_TRANSFER_COMPLETE.toString(),
COMPLETED.toString(),
REFUNDED.toString(),
PENDING_EXTERNAL.toString(),
PENDING_ANCHOR.toString(),
PENDING_USER.toString());
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/stellar/anchor/sep10/Sep10Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public ChallengeResponse createChallenge(ChallengeRequest challengeRequest) thro

boolean omnibusWallet =
sep10Config.getOmnibusAccountList().contains(challengeRequest.getAccount().trim());
if (omnibusWallet) {
if (challengeRequest.getClientDomain() != null) {
throw new SepValidationException(
"client_domain must not be specified if the account is an omni-wallet account");
}
}
if (omnibusWallet) {
if (challengeRequest.getClientDomain() != null) {
throw new SepValidationException(
"client_domain must not be specified if the account is an omni-wallet account");
}
}

if (!omnibusWallet && sep10Config.isClientAttributionRequired()) {
if (challengeRequest.getClientDomain() == null) {
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public GetTransactionsResponse findTransactions(JwtToken token, GetTransactionsR
GetTransactionsResponse result = new GetTransactionsResponse();
List<TransactionResponse> list = new ArrayList<>();
for (Sep24Transaction txn : txns) {
TransactionResponse transactionResponse = fromTxn(txn);
TransactionResponse transactionResponse = fromTxn(txn, txReq.getLang());
list.add(transactionResponse);
}
result.setTransactions(list);
Expand Down Expand Up @@ -324,7 +324,7 @@ public GetTransactionResponse findTransaction(JwtToken token, GetTransactionRequ
throw new SepNotFoundException("transaction is not found");
}

return GetTransactionResponse.of(fromTxn(txn));
return GetTransactionResponse.of(fromTxn(txn, txReq.getLang()));
}

public InfoResponse getInfo() {
Expand All @@ -348,12 +348,12 @@ String convertBase64ToHex(String memo) {
return Hex.encodeHexString(Base64.getDecoder().decode(memo.getBytes()));
}

TransactionResponse fromTxn(Sep24Transaction txn)
TransactionResponse fromTxn(Sep24Transaction txn, String lang)
throws MalformedURLException, URISyntaxException, SepException {
if (txn.getKind().equals(DEPOSIT.toString())) {
return DepositTransactionResponse.of(jwtService, sep24Config, txn, true);
return DepositTransactionResponse.of(jwtService, sep24Config, txn, lang, true);
} else if (txn.getKind().equals(WITHDRAWAL.toString())) {
return WithdrawTransactionResponse.of(jwtService, sep24Config, txn, true);
return WithdrawTransactionResponse.of(jwtService, sep24Config, txn, lang, true);
} else {
throw new SepException(String.format("unsupported txn kind:%s", txn.getKind()));
}
Expand Down

0 comments on commit 3f202b3

Please sign in to comment.