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

# getMissingVerificationForCoinbaseOnrampOrder

# getMissingVerificationForCoinbaseOnrampOrder

Checks what user verification is missing before creating a Coinbase onramp order. Coinbase requires verified email and phone number for Apple Pay purchases, and phone verification must be within the last 60 days.

Call this function before [createCoinbaseOnrampOrder](/javascript/reference/client/create-coinbase-onramp-order) to ensure the user has completed all required verification steps.

## Usage

```javascript theme={"system"}
import { getMissingVerificationForCoinbaseOnrampOrder } from "@dynamic-labs-sdk/client";

const missingFields = getMissingVerificationForCoinbaseOnrampOrder({
  paymentMethod: "GUEST_CHECKOUT_APPLE_PAY",
});

if (missingFields.length > 0) {
  console.log("User needs to verify:", missingFields);
} else {
  console.log("User is ready to create an order");
}
```

## Parameters

| Parameter       | Type                         | Description                                                              |
| --------------- | ---------------------------- | ------------------------------------------------------------------------ |
| `paymentMethod` | `"GUEST_CHECKOUT_APPLE_PAY"` | The payment method for the order. Currently only Apple Pay is supported. |
| `client`        | `DynamicClient` (optional)   | The Dynamic client instance. Only required when using multiple clients.  |

## Returns

`FieldMissingVerificationForCoinbaseOnramp[]` - An array of fields that need attention. Empty array means the user is ready.

### Return type

```typescript theme={"system"}
type FieldMissingVerificationForCoinbaseOnramp =
  | {
      field: "email" | "phoneNumber";
      errorCode: "MISSING_INFORMATION";
    }
  | {
      field: "email" | "phoneNumber";
      errorCode: "MISSING_VERIFICATION" | "VERIFICATION_EXPIRED";
      data: string; // The unverified email or phone number
    };
```

### Error Codes

| Code                   | Description                                       | Action Required                                                                                                                                                 |
| ---------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MISSING_INFORMATION`  | User hasn't provided email or phone number.       | Collect the information using [updateUser](/javascript/user-session-management).                                                                                |
| `MISSING_VERIFICATION` | User provided but hasn't verified email or phone. | Send OTP and verify using [email OTP verification](/javascript/authentication-methods/email) or [SMS OTP verification](/javascript/authentication-methods/sms). |
| `VERIFICATION_EXPIRED` | Phone verification is older than 60 days.         | Re-verify the phone number.                                                                                                                                     |

## Complete Example

```javascript theme={"system"}
import {
  getMissingVerificationForCoinbaseOnrampOrder,
  createCoinbaseOnrampOrder,
  updateUser,
  sendEmailOTP,
  sendSmsOTP,
  verifyOTP,
} from "@dynamic-labs-sdk/client";

const prepareCoinbaseOrder = async (orderParams) => {
  const missing = getMissingVerificationForCoinbaseOnrampOrder({
    paymentMethod: "GUEST_CHECKOUT_APPLE_PAY",
  });

  // Handle each missing verification
  for (const field of missing) {
    if (field.field === "email") {
      if (field.errorCode === "MISSING_INFORMATION") {
        // Need to collect email from user
        const email = await promptUserForEmail();
        const result = await updateUser({ userFields: { email } });

        if (result?.verificationUUID) {
          // Email update requires verification
          const code = await promptUserForOTP("Check your email for a code");
          await verifyOTP({ otp: code, verificationUUID: result.verificationUUID });
        }
      } else if (field.errorCode === "MISSING_VERIFICATION") {
        // Email exists but not verified
        const result = await sendEmailOTP({ email: field.data });
        const code = await promptUserForOTP("Check your email for a code");
        await verifyOTP({ otp: code, verificationUUID: result.verificationUUID });
      }
    }

    if (field.field === "phoneNumber") {
      if (field.errorCode === "MISSING_INFORMATION") {
        // Need to collect phone number from user
        const phone = await promptUserForPhoneNumber();
        const result = await updateUser({ userFields: { phoneNumber: phone } });

        if (result?.verificationUUID) {
          const code = await promptUserForOTP("Check your phone for a code");
          await verifyOTP({ otp: code, verificationUUID: result.verificationUUID });
        }
      } else if (
        field.errorCode === "MISSING_VERIFICATION" ||
        field.errorCode === "VERIFICATION_EXPIRED"
      ) {
        // Phone exists but needs (re-)verification
        const result = await sendSmsOTP({ phoneNumber: field.data });
        const code = await promptUserForOTP("Check your phone for a code");
        await verifyOTP({ otp: code, verificationUUID: result.verificationUUID });
      }
    }
  }

  // Now the user is verified, create the order
  return createCoinbaseOnrampOrder(orderParams);
};
```

## UI Component Example

```javascript theme={"system"}
import { getMissingVerificationForCoinbaseOnrampOrder } from "@dynamic-labs-sdk/client";

const VerificationStatus = () => {
  const missing = getMissingVerificationForCoinbaseOnrampOrder({
    paymentMethod: "GUEST_CHECKOUT_APPLE_PAY",
  });

  if (missing.length === 0) {
    return <p>Ready to purchase with Coinbase!</p>;
  }

  return (
    <div>
      <p>Please complete the following before purchasing:</p>
      <ul>
        {missing.map((item) => (
          <li key={item.field}>
            {item.field === "email" ? "Email" : "Phone number"}:{" "}
            {item.errorCode === "MISSING_INFORMATION"
              ? "Not provided"
              : item.errorCode === "MISSING_VERIFICATION"
                ? "Not verified"
                : "Verification expired (please re-verify)"}
          </li>
        ))}
      </ul>
    </div>
  );
};
```

## Related functions

* [createCoinbaseOnrampOrder](/javascript/reference/client/create-coinbase-onramp-order) - Create an onramp order (requires verification)
* [updateUser](/javascript/user-session-management) - Update user email or phone number
* [sendEmailOTP](/javascript/authentication-methods/email) - Send email verification code
* [sendSmsOTP](/javascript/authentication-methods/sms) - Send SMS verification code
