checkoutCompleteWithTokenizedPaymentV3 method

Future<String?> checkoutCompleteWithTokenizedPaymentV3(
  1. String checkoutId, {
  2. required Checkout checkout,
  3. required String token,
  4. required PaymentTokenType paymentTokenType,
  5. required String idempotencyKey,
  6. required String amount,
  7. required String currencyCode,
  8. bool deleteThisPartOfCache = false,
})

Implementation

Future<String?> checkoutCompleteWithTokenizedPaymentV3(String checkoutId,
    {required Checkout checkout,
    required String token,
    required PaymentTokenType paymentTokenType,
    required String idempotencyKey,
    required String amount,
    required String currencyCode,
    bool deleteThisPartOfCache = false}) async {
  final MutationOptions _options =
      MutationOptions(document: gql(completeCheckoutWithTokenV3), variables: {
    'checkoutId': checkoutId,
    'payment': {
      'paymentAmount': {'amount': amount, 'currencyCode': currencyCode},
      'idempotencyKey': idempotencyKey,
      'billingAddress': const {},
      'paymentData': token,
      'type': paymentTokenType.toString()
    }
  });
  final QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'checkoutCompleteWithTokenizedPaymentV3',
    errorKey: 'checkoutUserErrors',
  );

  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }

  return result.data?['checkoutCompleteWithTokenizedPaymentV3']['payment']
      ['id'];
}