createOrderV2(data: CreateOrderV2Params)

Requires:
@tuya-miniapp/cloud-api≥1.6.1

Description

Create a value-added service order in the specified mall and return the order ID for subsequent payment.

Parameters

ParameterTypeRequiredDescription
YesRequest parameters

Return Value

Type: Promise<CreateOrderV2Result>
Order information, including order ID and amounts

Referenced Types

interfaceCreateOrderV2ResultResult of creating an order
PropertyTypeDescription
orderIdstringOrder number
amountOriginnumberOriginal order amount
amountTradenumberOrder amount after discounts
enumVasPaymentScope
ValueActual ValueDescription
VasPaymentScope.ALL0All
VasPaymentScope.ONLY_IAP1IAP only
VasPaymentScope.ONLY_NON_IAP2Non-IAP only
VasPaymentScope.AUTO_IAP99Auto-select whether to use IAP
enumVasOptionType
ValueActual ValueDescription
VasOptionType.NORMAL0Standard payment
VasOptionType.SUBSCRIPTION2Subscription payment

Valid Values

VasPaymentScope
ValueDescriptionSince
0All-
1IAP only-
2Non-IAP only-
99Auto-select whether to use IAP-
VasOptionType
ValueDescriptionSince
0Standard payment-
2Subscription payment-

Examples

Request example

import { createOrderV2, VasPaymentScope } from '@tuya-miniapp/cloud-api';

createOrderV2({
  mallCode: 'your_mall_code',
  siteCode: 'your_site_code',
  paymentScopeCode: VasPaymentScope.ONLY_NON_IAP,
  orderItemList: [
    {
      skuCode: 'your_sku_code',
      quantity: 1,
      optionType: 0,
      optionNo: 0,
      trial: false,
    },
  ],
  currency: 'CNY',
  groupId: 123456,
})
  .then(order => {
    console.log('Order info:', order);
  })
  .catch(error => {
    console.error('Failed to create order:', error);
  });

Response example

{
  "orderId": "your_order_id",
  "amountOrigin": 99,
  "amountTrade": 99
}