# createComponent()

> The createComponent() method is used to create and display the payment or card vaulting component UI.

  The   `createComponent()`   method is used to create and display the payment or card binding component UI.

 > **[INFO]** **Notes**    : - This method must be called on the main thread.
> - This method is mutually exclusive with `[confirmPayment()](https://docs.antom.com/ac/sdks/ios_confirmPayment.md)`.

## Declaration {#AGz2v}

<!-- TabGroup -->

**Tab: Objective-C**

```objectivec
- (void)createComponent:(NSString *)sessionData;
```

**Tab: Swift**

```swift
public func createComponent(_ sessionData: String)
```

<!-- /TabGroup -->

## Parameters {#CTSts}

 | **Parameters** | **Type** | **Required** | **Description** |
| --- | --- | --- | --- |
| *sessionData* | String | Yes | Payment or vaulting session data. Complete the corresponding configuration according to different scenarios: - [Payment Element](https://docs.antom.com/ac/cashierpay/element.md?platform=ios)      scenario: Pass the complete _paymentSessionData_ obtained from the      [**createPaymentSession (One-time Payments)**](https://docs.antom.com/ac/ams/session_cashier.md)  API response into this parameter. - Vaulting Element scenario: Pass the complete _vaultingSessionData_ obtained from the   [**createVaultingSession**](https://docs.antom.com/ac/ams/vaulting_session.md)   API response into this parameter. |
| *completion* | ([AMSStatusResult](https://docs.antom.com/ac/sdks/ios_AMSStatusResult.md)) -> Void | No | Callback after component creation is complete. |

## Return value {#wbeQG}

 This method does not return any value.

## Error codes {#Jn95K}

 | ***code*** | ***status*** | **Suggested prompt for buyers (**      ***message***      **)** | **Description** | **Recommended action** |
| --- | --- | --- | --- | --- |
| `UNKNOWN_EXCEPTION` | `PROCESSING` | Unknown exception. Please check the payment status and contact the merchant. | Due to unknown reasons, the API call failed. | For detailed reasons, please contact Antom technical support. It is recommended that you try to query the payment result from the server side. If the payment result is not found, you can use the original _paymentSessionData_ to initiate the payment again within the the session validity period. |
| `ORDER_IS_CANCELLED` | `FAIL` | The order status is abnormal. Please check the payment status and contact the merchant. | Order has been cancelled. | The merchant cancelled the order, please investigate on your own. |
| `ORDER_IS_CLOSED` | `FAIL` | The order status is abnormal. Please check the payment status and contact the merchant. | The request you initiated has the same _paymentRequestId_ as a closed transaction. | The order has been closed due to timeout. Please initiate the payment again using a new _paymentRequestId_. |
| `INQUIRY_PAYMENT_SESSION_FAILED` | `FAIL` | The order status is abnormal. Please check the payment status and contact the merchant. | Payment session expired. | The order has been closed due to timeout. Please initiate the payment again using a new _paymentRequestId_. |
| `PARAM_INVALID` | N/A | Request exception, transaction cannot be initiated. | SDK input parameters exception. | Integration code is abnormal, please troubleshoot on your own. If you have any issues, contact Antom technical support. |
| `UI_STATE_ERROR` | N/A | Request exception, transaction cannot be initiated. | The timing of creating SDK instance or calling   `createComponent()`   is abnormal. | Integration code is abnormal, please troubleshoot on your own. If you have any issues, contact Antom technical support. |
| `INITIALIZE_WEB_TIMEOUT` | N/A | Request exception, transaction cannot be initiated. | Checkout static resource loading timeout. | User network exception or Antom service exception, it is recommended to re-call the   `createComponnet()`   method. |
| `PAYMENT_IN_PROCESS` | `PROCESSING` | The payment is being processed, please wait for the payment to complete. | Payment is being processed. | Payment is being processed. It is recommended that you try to query the payment result from the server side. If the payment result is not found, you can use the original _paymentSessionData_ to initiate the payment again within the session validity period. |
| `PAYMENT_RESULT_TIMEOUT` | `PROCESSING` | Request exception, transaction cannot be initiated. | Network exception when obtaining payment result. | Try to query the payment result from the server side. |
| `USER_CANCELED` | `PROCESSING` | N/A | User manually closed the QR code display or the guidance page popup. | Within the session validity period, you may use the original _paymentSessionData_ to initiate the payment again. |
| `INVALID_TRANSACTION` | `FAIL` | If the transaction fails, please do not retry. Contact Antom Technical Support for more information. | Invalid transaction. | The transaction is deemed invalid. Possible reasons: missing/incorrect transaction parameters, risk control rules interception, duplicate transaction submission, or the channel does not support this transaction type. It is recommended to check the completeness of request parameters, guide the users to retry later or change the payment method. |
