Skip to content

Commit 1ff1247

Browse files
committed
Fix README: self-contained bills example, clarify injected clients
The "Pay a bill" snippet referenced a ValidateCustomerAsync result that was never shown. Replaced with the full validate-then-vend flow using the electricity sample that actually needs a ValidationReference. Also note up front that collections/disbursements/bills/etc. in the Usage examples are assumed to be constructor-injected.
1 parent eb40436 commit 1ff1247

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ need.
5252

5353
## Usage
5454

55+
The examples below assume `collections`, `disbursements`, `bills`,
56+
`verification`, and `banks` are constructor-injected via the interfaces
57+
registered above (e.g. a constructor parameter of type
58+
`IMonnifyCollectionsClient collections`).
59+
5560
### Collect a payment
5661

5762
```csharp
@@ -89,19 +94,32 @@ retry pattern (query status first; only retry with a *new* reference).
8994

9095
### Pay a bill
9196

97+
Some products (electricity prepaid plans, for example) require validating the
98+
customer first, which returns a `ValidationReference` to pass into the vend
99+
request — check `VendInstruction.RequireValidationRef` to know if a given
100+
product needs this step:
101+
92102
```csharp
103+
var validation = await bills.ValidateCustomerAsync(new ValidateBillCustomerRequest
104+
{
105+
ProductCode = "product-ikedc-pre",
106+
CustomerId = "55555666666",
107+
});
108+
109+
var requiresValidation = validation.VendInstruction?.RequireValidationRef == true;
110+
93111
var vend = await bills.VendAsync(new VendBillRequest
94112
{
95-
ProductCode = "11", // e.g. an airtime top-up product
96-
CustomerId = "08012345678",
113+
ProductCode = "product-ikedc-pre",
114+
CustomerId = "55555666666",
97115
Amount = 500,
98116
Reference = Guid.NewGuid().ToString("N"),
117+
ValidationReference = requiresValidation ? validation.VendInstruction!.ValidationReference : null,
99118
});
100119
```
101120

102-
Some products require a `ValidationReference` obtained from
103-
`ValidateCustomerAsync` first — check `VendInstruction.RequireValidationRef`
104-
on that result.
121+
Products that don't need validation (airtime top-ups, for example) can skip
122+
straight to `VendAsync` and leave `ValidationReference` unset.
105123

106124
### Verify an account
107125

0 commit comments

Comments
 (0)