Skip to content

Create

experimental.payment_flows.create(PaymentFlowCreateParams**kwargs) -> PaymentFlowCreateResponse
POST/payment-flows

Creates a new payment flow.

ParametersExpand Collapse
external_id: str

User-provided unique external ID.

invoice: Invoice

Invoice to settle.

Accepts one of the following:
class InvoiceID:
id: str

Fragment invoice ID.

class InvoiceExternalID:
external_id: str

Invoice external ID.

type: Literal["single_invoice_settlement"]

Type of payment flow.

ReturnsExpand Collapse
class PaymentFlowCreateResponse:

Payment flow object.

id: str

FRAGMENT generated unique ID.

created: str

Timestamp when the payment flow was created.

external_id: str

User-provided unique external ID.

invoice: Invoice

Invoice being settled.

id: str

Invoice identifier.

external_id: Optional[str]

Invoice external ID.

modified: str

Timestamp when the payment flow was last modified.

payment_plan: PaymentPlan

Payment plan for UI rendering.

batches: List[PaymentPlanBatch]

Payment batches.

batch_id: str

Batch identifier.

depends_on: List[str]

Batches this one depends on.

label: str

Human-readable batch label.

payments: List[PaymentPlanBatchPayment]

Payments in this batch.

amount: str

Amount in smallest currency unit.

currency: str

Currency code.

direction: str

Direction of the payment.

payment_id: str

FRAGMENT generated unique ID.

status: str

Status of the payment.

user: PaymentPlanBatchPaymentUser

User associated with the payment.

id: str

FRAGMENT generated unique ID.

external_id: str

User-provided unique ID.

status: str

Batch status.

generated_at: str

When the plan was generated.

invoice_id: str

Invoice identifier.

version: float

Plan version.

status: str

Status of the payment flow.

type: str

Type of payment flow.

Create

from fragment import Fragment

client = Fragment()
payment_flow = client.experimental.payment_flows.create(
    external_id="pf_123",
    invoice={
        "id": "inv_abc123"
    },
    type="single_invoice_settlement",
)
print(payment_flow.data)
{
  "data": {
    "id": "pf_abc123",
    "created": "2024-01-01T00:00:00.000Z",
    "external_id": "pf_123",
    "invoice": {
      "id": "inv_abc123",
      "external_id": "inv_ext_123"
    },
    "modified": "2024-01-01T00:00:00.000Z",
    "payment_plan": {
      "batches": [
        {
          "batch_id": "payins",
          "depends_on": [
            "string"
          ],
          "label": "Payins",
          "payments": [
            {
              "amount": "10000",
              "currency": "USD",
              "direction": "payin",
              "payment_id": "pmt_abc123",
              "status": "settled",
              "user": {
                "id": "user_abc123",
                "external_id": "user_ext_001"
              }
            }
          ],
          "status": "settled"
        }
      ],
      "generated_at": "2024-01-01T00:00:00.000Z",
      "invoice_id": "inv_abc123",
      "version": 1
    },
    "status": "settled",
    "type": "single_invoice_settlement"
  }
}
Returns Examples
{
  "data": {
    "id": "pf_abc123",
    "created": "2024-01-01T00:00:00.000Z",
    "external_id": "pf_123",
    "invoice": {
      "id": "inv_abc123",
      "external_id": "inv_ext_123"
    },
    "modified": "2024-01-01T00:00:00.000Z",
    "payment_plan": {
      "batches": [
        {
          "batch_id": "payins",
          "depends_on": [
            "string"
          ],
          "label": "Payins",
          "payments": [
            {
              "amount": "10000",
              "currency": "USD",
              "direction": "payin",
              "payment_id": "pmt_abc123",
              "status": "settled",
              "user": {
                "id": "user_abc123",
                "external_id": "user_ext_001"
              }
            }
          ],
          "status": "settled"
        }
      ],
      "generated_at": "2024-01-01T00:00:00.000Z",
      "invoice_id": "inv_abc123",
      "version": 1
    },
    "status": "settled",
    "type": "single_invoice_settlement"
  }
}