-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
payment-circle: polish responses and code (#88)
### What Code polishes and small fixes. Changes details: * Add `CircleWallet.defaultCapabilities()` and `CircleWallet.merchantAccountCapabilities()` to avoid hardcoding the capabilities every time. * Update Account default `balances` and `unsettledBalances` values to null, so the JSON response works better when we don't have the balances. Otherwise, returning an empty list passes the impression the balances are empty when that might not be the case. * Fix paginated responses cursors. * Updated docs on how to get the bank deposit instructions. * Solve warnings * Update `CirclePaymentServiceTest` to reduce code repetition and standardize method names. * Add all Circle asset names to the `CircleAsset` class, so we don't need to hardcode the string names.
- Loading branch information
1 parent
c3fe0c9
commit 5489326
Showing
11 changed files
with
482 additions
and
504 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,7 +157,7 @@ Usage: | |
// CircleWallet->CircleWallet | ||
Account source = new Account(PaymentNetwork.CIRCLE, "1000066041", Account.Capabilities(PaymentNetwork.CIRCLE, PaymentNetwork.STELLAR)); | ||
Account destination = new Account(PaymentNetwork.CIRCLE, "1000067536", Account.Capabilities(PaymentNetwork.CIRCLE, PaymentNetwork.STELLAR)); | ||
String currencyName = "circle:USD"; | ||
String currencyName = CircleAsset.circleUSD(); | ||
Payment payment = service.sendPayment(source, destination, currencyName, BigDecimal.valueOf(0.91)).block(); | ||
System.out.println(payment); | ||
|
||
|
@@ -172,7 +172,7 @@ System.out.println(payment); | |
Account source = new Account(PaymentNetwork.CIRCLE, "1000066041", Account.Capabilities(PaymentNetwork.CIRCLE, PaymentNetwork.STELLAR)); | ||
// The bank wire account should have been created in advance directly in Circle | ||
Account destination = new Account(PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", "[email protected]", Account.Capabilities()); | ||
String currencyName = "iso4217:USD"; | ||
String currencyName = CircleAsset.fiatUSD(); | ||
Payment payment = service.sendPayment(source, destination, currencyName, BigDecimal.valueOf(0.91)).block(); | ||
System.out.println(payment); | ||
``` | ||
|
@@ -186,17 +186,17 @@ Usage: | |
|
||
```java | ||
// Deposit requirements to receive CircleWallet<-CircleWallet payments | ||
DepositRequirements config = DepositRequirements("1000066041", null, PaymentNetwork.CIRCLE, "circle:USD"); | ||
DepositRequirements config = DepositRequirements("1000066041", PaymentNetwork.CIRCLE, CircleAsset.circleUSD()); | ||
DepositInstructions instructions = service.getDepositInstructions(config).block(); | ||
System.out.println(instructions); | ||
|
||
// Deposit requirements to receive CircleWallet<-Stellar payments | ||
DepositRequirements config = DepositRequirements("1000066041", null, PaymentNetwork.STELLAR, "circle:USD"); | ||
DepositRequirements config = DepositRequirements("1000066041", PaymentNetwork.STELLAR, CircleAsset.circleUSD()); | ||
DepositInstructions instructions = service.getDepositInstructions(config).block(); | ||
System.out.println(instructions); | ||
|
||
// Deposit requirements to receive CircleWallet<-BankWire payments | ||
DepositRequirements config = DepositRequirements("1000066041", null, PaymentNetwork.BANK_WIRE, "circle:USD"); | ||
DepositRequirements config = DepositRequirements("1000066041", null, PaymentNetwork.BANK_WIRE, "a4e76642-81c5-47ca-9229-ebd64efd74a7", CircleAsset.circleUSD()); | ||
DepositInstructions instructions = service.getDepositInstructions(config).block(); | ||
System.out.println(instructions); | ||
``` | ||
|
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
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
19 changes: 17 additions & 2 deletions
19
payment-circle/src/main/java/org/stellar/anchor/paymentservice/circle/util/CircleAsset.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 |
---|---|---|
@@ -1,14 +1,29 @@ | ||
package org.stellar.anchor.paymentservice.circle.util; | ||
|
||
import java.util.List; | ||
import org.stellar.sdk.Network; | ||
import reactor.util.annotation.NonNull; | ||
|
||
public class CircleAsset { | ||
@NonNull | ||
public static String stellarUSDC(Network stellarNetwork) { | ||
if (stellarNetwork == org.stellar.sdk.Network.PUBLIC) | ||
return "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"; | ||
return "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"; | ||
|
||
return "USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"; | ||
return "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"; | ||
} | ||
|
||
public static String circleUSD() { | ||
return "circle:USD"; | ||
} | ||
|
||
public static String fiatUSD() { | ||
return "iso4217:USD"; | ||
} | ||
|
||
public static boolean isSupported(String currencyName, Network stellarNetwork) { | ||
return List.of( | ||
CircleAsset.circleUSD(), CircleAsset.fiatUSD(), CircleAsset.stellarUSDC(stellarNetwork)) | ||
.contains(currencyName); | ||
} | ||
} |
Oops, something went wrong.