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

Documentando split #20

Merged
merged 1 commit into from
Dec 28, 2024
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
33 changes: 33 additions & 0 deletions docs/payment_split.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Criar cobrança com split
```java
SplitSetting split1 = new SplitSetting()
.setWalletId("635b5330-3931-4ab2-b78c-3c59f136c535")
.setFixedValue(Money.create(10));

Payment payment = Payment.creator()
.setCustomer("cus_000050606806")
.setBillingType(BillingType.PIX)
.setDueDate(new Date())
.setValue(Money.create(new BigDecimal(10.01)))
.setDescription("Teste")
.addSplit(split1)
.create();
```

É possível adicionar mais splits para carteiras diferentes:
```java
.addSplit(split1)
.addSplit(split1);
```

## Listar splits pagos
```java
PaymentSplitPaidReader reader = Split.paidReader()
reader.read();
```

## Listar splits recebidos
```java
PaymentSplitReceivedReader reader = Split.receivedReader()
reader.read();
```
5 changes: 5 additions & 0 deletions src/main/java/io/github/jpdev/asaassdk/utils/Money.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ public static BigDecimal create(double value) {
BigDecimal parsed = new BigDecimal(value);
return create(parsed);
}

public static BigDecimal create(int value) {
BigDecimal parsed = new BigDecimal(value);
return create(parsed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void setup() {
@DisplayName("Integração | Criação de transação Pix com chave")
@Order(1)
void testCreatePixKey() {
BigDecimal value = Money.create(new Random(100).nextDouble());
BigDecimal value = buildValue();

Transfer transfer = Transfer.pixAddressKeyCreator()
.setPixAddressKey("+5547999999999")
Expand Down Expand Up @@ -76,4 +76,9 @@ void testReadById() {
assertNotNull(transfer.getValue(), "Valor da transferência não encontrado.");
assertNotNull(transfer.getDateCreated());
}

private BigDecimal buildValue() {
int value = new Random().nextInt(100) + 1;
return Money.create(value);
}
}