completeCheckoutWithTokenizedPaymentV2 method

Future<String?> completeCheckoutWithTokenizedPaymentV2({
  1. required String checkoutId,
  2. required PriceV2 price,
  3. required Address billingAddress,
  4. required String impotencyKey,
  5. required String tokenizedPayment,
  6. required String type,
  7. bool test = false,
})

Updates the shipping address on given checkoutId

Implementation

Future<String?> completeCheckoutWithTokenizedPaymentV2({
  required String checkoutId,
  required PriceV2 price,
  required Address billingAddress,
  required String impotencyKey,
  required String tokenizedPayment,
  required String type,
  bool test = false,
}) async {
  final MutationOptions _options = MutationOptions(
    document: gql(compCheckoutWithTokenizedPaymentV2),
    variables: {
      'checkoutId': checkoutId,
      "payment": {
        "paymentAmount": {
          "amount": price.amount,
          "currencyCode": price.currencyCode
        },
        "idempotencyKey": impotencyKey,
        "billingAddress": {
          "firstName": billingAddress.firstName,
          "lastName": billingAddress.lastName,
          "address1": billingAddress.address1,
          "province": billingAddress.province,
          "country": billingAddress.country,
          "city": billingAddress.city,
          "zip": billingAddress.zip
        },
        "paymentData": tokenizedPayment,
        "type": type
      }
    },
  );
  final QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'checkoutCompleteWithTokenizedPaymentV2',
    errorKey: 'checkoutUserErrors',
  );
  return (result.data!['checkoutCompleteWithTokenizedPaymentV2'] ??
      const {})['payment']['id'];
}