CreateChargeCompletionMonitor<M>BatchCreateChargepublic abstract class AbstractBatchCreateCharge<M extends Charge,B extends AbstractChargesBuilders.AbstractCreateChargeRequestBuilder<B,?,M>,G extends AbstractChargesBuilders.AbstractGetChargeRequestBuilder<G,?,M>> extends Object implements CreateChargeCompletionMonitor<M>
BatchCreateCharge batch = gopay.batchCreateCharge();
for (Invoice i : targetInvoicesThisMonth) {
batch.add(gopay.createCharge(i.getTransactionToken(), i.getTotalAmount(), "JPY"));
}
CreateChargeResult[] results = batch.execute();
for (CreateChargeResult r : results) {
if (r.createChargeException != null) {
assert r.charge == null;
// the charge creation request failed.
...
} else if (r.statusCheckException != null) {
assert r.charge != null;
// Failed to check the charge status.
...
} else {
assert r.charge != null;
assert r.charge.getStatus() != ChargeStatus.PENDING
// Save charge result.
...
}
}
| Constructor | Description |
|---|---|
AbstractBatchCreateCharge(retrofit2.Retrofit retrofit,
int createMaxRetry,
int statusCheckTimeout) |
| Modifier and Type | Method | Description |
|---|---|---|
AbstractBatchCreateCharge |
add(B builder) |
Add create charge request builder to request queue.
|
io.reactivex.Flowable<CreateChargeResult<M>> |
createFlowable() |
Creates a flowable by dispatching each builder with idempotency.
|
CreateChargeResult[] |
execute() |
Create in parallel all the charges in the builders, polling the status of each charge.
|
void |
execute(BatchChargeCallback<M> callback) |
Create in parallel all the charges in the builders, polling the status of each charge.
|
void |
setStreamOptions(StreamOptions streamOptions) |
createChargeCompletionMonitorpublic AbstractBatchCreateCharge(retrofit2.Retrofit retrofit,
int createMaxRetry,
int statusCheckTimeout)
public void setStreamOptions(StreamOptions streamOptions)
public AbstractBatchCreateCharge add(B builder)
builder - Create charge builderpublic io.reactivex.Flowable<CreateChargeResult<M>> createFlowable()
InterruptedExceptionpublic CreateChargeResult[] execute()
CreateChargeResultpublic void execute(BatchChargeCallback<M> callback)
callback - CreateChargeResultCopyright © 2018 The Apache Software Foundation. All rights reserved.