Skip to content
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ mollie payments create ... \
mollie payments create ... --metadata '{"order_id": "42", "source": "cli"}'
```

`--capture-delay` delays the automatic capture of an authorized payment. Only `"... hours"` and `"... days"` are accepted (max 7 days), and it requires `--capture-mode automatic`:

```bash
mollie payments create ... --capture-mode automatic --capture-delay "8 hours"
```

### `refunds` — refunds

```
Expand Down
26 changes: 19 additions & 7 deletions cmd/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ var (
// terminal ID flag
payCreateTerminalID string

// capture delay flag
payCreateCaptureDelay string

// --with-lines flags
payCreateWithLines bool
payCreateWithDiscount bool
Expand Down Expand Up @@ -108,7 +111,11 @@ var paymentsCreateCmd = &cobra.Command{

Add --with-discount to append a ~10% discount line; requires --with-lines.

--with-billing / --with-shipping attach a Dutch test address; override fields with --billing-* / --shipping-*.`,
--with-billing / --with-shipping attach a Dutch test address; override fields with --billing-* / --shipping-*.

--capture-delay delays the automatic capture of an authorized payment by the given
duration, e.g. --capture-delay "8 hours" or --capture-delay "2 days". Only "... hours"
and "... days" are accepted (max 7 days); requires --capture-mode automatic.`,
RunE: runPaymentsCreate,
Annotations: map[string]string{"usesDefaults": "true"},
}
Expand Down Expand Up @@ -154,6 +161,7 @@ func init() {
paymentsCreateCmd.Flags().StringVar(&payCreateCaptureMode, "capture-mode", "", "Capture mode: automatic or manual")
paymentsCreateCmd.Flags().StringVar(&payCreateLocale, "locale", "", "Locale for the payment, e.g. en_US, nl_NL (determines checkout language)")
paymentsCreateCmd.Flags().StringVar(&payCreateTerminalID, "terminal-id", "", "Terminal ID for point-of-sale payments")
paymentsCreateCmd.Flags().StringVar(&payCreateCaptureDelay, "capture-delay", "", "Delay before auto-capturing an authorized payment, e.g. \"8 hours\", \"2 days\" (max 7 days; requires --capture-mode automatic)")

// --with-lines flags
paymentsCreateCmd.Flags().BoolVar(&payCreateWithLines, "with-lines", false, "Auto-generate order lines summing to --amount (always 2 item lines + 1 shipping line)")
Expand Down Expand Up @@ -256,6 +264,9 @@ func runPaymentsCreate(cmd *cobra.Command, _ []string) error {
if v, ok := input.Str(jsonInput, "terminalId"); ok && !cmd.Flags().Changed("terminal-id") {
payCreateTerminalID = v
}
if v, ok := input.Str(jsonInput, "captureDelay"); ok && !cmd.Flags().Changed("capture-delay") {
payCreateCaptureDelay = v
}
if v, ok := input.RawJSON(jsonInput, "metadata"); ok && !cmd.Flags().Changed("metadata") {
payCreateMetadata = v
}
Expand Down Expand Up @@ -323,6 +334,7 @@ func runPaymentsCreate(cmd *cobra.Command, _ []string) error {
req.Locale = nil
req.Metadata = nil
req.TerminalID = nil
req.CaptureDelay = nil

if payCreateWebhookURL != "" {
req.WebhookURL = &payCreateWebhookURL
Expand Down Expand Up @@ -350,6 +362,9 @@ func runPaymentsCreate(cmd *cobra.Command, _ []string) error {
if payCreateTerminalID != "" {
req.TerminalID = &payCreateTerminalID
}
if payCreateCaptureDelay != "" {
req.CaptureDelay = &payCreateCaptureDelay
}
if payCreateMetadata != "" {
meta, err := parseMetadata(payCreateMetadata)
if err != nil {
Expand Down Expand Up @@ -946,9 +961,9 @@ func parseMetadata(raw string) (components.Metadata, error) {
// from being forwarded.
//
// Fields that have a direct CLI flag (amount, currency, description,
// redirectUrl, webhookUrl, method, sequenceType, captureMode, locale,
// metadata, customerId) are applied separately by the caller and are not
// touched here.
// redirectUrl, webhookUrl, method, sequenceType, captureMode, captureDelay,
// locale, metadata, customerId, terminalId) are applied separately by the
// caller and are not touched here.
func seedPassThroughFields(req *components.PaymentRequest, m map[string]json.RawMessage) {
// ── Addresses ────────────────────────────────────────────────────────────
if raw, ok := m["billingAddress"]; ok {
Expand Down Expand Up @@ -993,9 +1008,6 @@ func seedPassThroughFields(req *components.PaymentRequest, m map[string]json.Raw
if raw, ok := m["restrictPaymentMethodsToCountry"]; ok {
strField(raw, &req.RestrictPaymentMethodsToCountry)
}
if raw, ok := m["captureDelay"]; ok {
strField(raw, &req.CaptureDelay)
}
if raw, ok := m["mandateId"]; ok {
strField(raw, &req.MandateID)
}
Expand Down
8 changes: 8 additions & 0 deletions skills/mollie-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ mollie payments create --amount 25.00 --currency EUR \

Optional line tuning flags: `--lines-vat-rate 21.00` (default), `--lines-shipping-amount 4.99` (default)

### Create a payment with delayed capture
```bash
# --capture-delay requires --capture-mode automatic; only "... hours" / "... days" (max 7 days)
mollie payments create --amount 25.00 --currency EUR \
--description "Order" --redirect-url https://example.com/return \
--capture-mode automatic --capture-delay "8 hours"
```

### Refund a payment
```bash
# Full refund (payment-id is a positional argument):
Expand Down
Loading