> ## Documentation Index
> Fetch the complete documentation index at: https://docs.iso20022js.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SWIFT Credit

> Create a SWIFT Credit Payment Initiation message

# SWIFTCreditPaymentInitiation

<Info>If want to learn more about SWIFT, please refer to the <a href="https://www.swift.com/standards/iso-20022/iso-20022-payments-financial-institutions">Official SWIFT website</a>.</Info>

The `SWIFTCreditPaymentInitiation` class is used to generate SWIFT Credit Payment v3 Initiation messages (pain.001.001.03). These are primarily used to send cross-border payments.

It can either be created from a base ISO20022 class or created competely independantly via the `SWIFTCreditPaymentInitiationConfig` interface.

## Constructor

```typescript theme={null}
export interface SWIFTCreditPaymentInitiationConfig {
    initiatingParty: Party;
    paymentInstructions: SWIFTCreditPaymentInstruction[];
    messageId?: string;
    creationDate?: Date;
}

// Example Usage
const swiftPayment = new SWIFTCreditPaymentInitiation({
    initiatingParty: {
        name: 'Acme Corporation',
        id: 'ACMECORP',
        account: {
            // Account details
        },
        agent: {
            // Agent details
        }
    },
    paymentInstructions: [
        {
            id: 'PAYMENT001',
            amount: 100000, // Amount in cents
            currency: 'USD',
            creditor: {
                // Creditor details
            },
            // Other payment instruction details
        }
    ],
    messageId: 'MSG001', // Optional
    creationDate: new Date() // Optional
});
```

Initializes a new `SWIFTCreditPaymentInitiation` instance with the provided configuration.

## Methods

### serialize(): string

Serializes the payment initiation to an XML string.

```typescript theme={null}
const xmlString = swiftPayment.serialize();
console.log(xmlString);
```

This method generates the complete XML representation of the SWIFT Credit Payment Initiation message.

### toString(): string

Alias for `serialize()`.

## Validation

The class includes built-in validation to ensure the payment initiation data meets the required standards:

* Validates that the `messageId` does not exceed 35 characters.
* Ensures all creditors have complete addresses (including country).
* Amount values should be specified in cents (e.g., 100000 for \$1000.00).
* Additional validations can be added as needed.
