Skip to content

Commit

Permalink
Merge pull request #20 from jpdev01/split
Browse files Browse the repository at this point in the history
Documentando split
  • Loading branch information
jpdev01 authored Dec 28, 2024
2 parents 9f561bd + 3abb655 commit 38e3316
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
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);
}
}

0 comments on commit 38e3316

Please sign in to comment.