Anchor to section titled 'undefined'

paymentTermsCreate
mutation

Requires write_payment_terms access scope. Also: The user must have access to orders or draft orders.

Create payment terms on an order. To create payment terms on a draft order, use a draft order mutation and include the request with the DraftOrderInput.


The attributes used to create the payment terms.

Anchor to referenceId
referenceId
required

Specifies the reference orderId to add the payment terms for.


Was this section helpful?

The created payment terms.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation PaymentTermsCreate($referenceId: ID!, $paymentTermsAttributes: PaymentTermsCreateInput!) {
  paymentTermsCreate(referenceId: $referenceId, paymentTermsAttributes: $paymentTermsAttributes) {
    paymentTerms {
      id
    }
    userErrors {
      field
      message
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation PaymentTermsCreate($referenceId: ID!, $paymentTermsAttributes: PaymentTermsCreateInput!) { paymentTermsCreate(referenceId: $referenceId, paymentTermsAttributes: $paymentTermsAttributes) { paymentTerms { id } userErrors { field message } } }",
 "variables": {
    "referenceId": "gid://shopify/Order/922426937",
    "paymentTermsAttributes": {
      "paymentTermsTemplateId": "gid://shopify/PaymentTermsTemplate/1"
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation PaymentTermsCreate($referenceId: ID!, $paymentTermsAttributes: PaymentTermsCreateInput!) {
    paymentTermsCreate(referenceId: $referenceId, paymentTermsAttributes: $paymentTermsAttributes) {
      paymentTerms {
        id
      }
      userErrors {
        field
        message
      }
    }
  }`,
  {
    variables: {
      "referenceId": "gid://shopify/Order/922426937",
      "paymentTermsAttributes": {
        "paymentTermsTemplateId": "gid://shopify/PaymentTermsTemplate/1"
      }
    },
  },
);

const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
  shop: "your-development-store.myshopify.com",
  access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
  session: session
)

query = <<~QUERY
  mutation PaymentTermsCreate($referenceId: ID!, $paymentTermsAttributes: PaymentTermsCreateInput!) {
    paymentTermsCreate(referenceId: $referenceId, paymentTermsAttributes: $paymentTermsAttributes) {
      paymentTerms {
        id
      }
      userErrors {
        field
        message
      }
    }
  }
QUERY

variables = {
  "referenceId": "gid://shopify/Order/922426937",
  "paymentTermsAttributes": {
    "paymentTermsTemplateId": "gid://shopify/PaymentTermsTemplate/1"
  }
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation PaymentTermsCreate($referenceId: ID!, $paymentTermsAttributes: PaymentTermsCreateInput!) {
      paymentTermsCreate(referenceId: $referenceId, paymentTermsAttributes: $paymentTermsAttributes) {
        paymentTerms {
          id
        }
        userErrors {
          field
          message
        }
      }
    }`,
    "variables": {
      "referenceId": "gid://shopify/Order/922426937",
      "paymentTermsAttributes": {
        "paymentTermsTemplateId": "gid://shopify/PaymentTermsTemplate/1"
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation PaymentTermsCreate($referenceId: ID!, $paymentTermsAttributes: PaymentTermsCreateInput!) {
    paymentTermsCreate(referenceId: $referenceId, paymentTermsAttributes: $paymentTermsAttributes) {
      paymentTerms {
        id
      }
      userErrors {
        field
        message
      }
    }
  }
QUERY;

$variables = [
  "referenceId" => "gid://shopify/Order/922426937",
  "paymentTermsAttributes" => [
    "paymentTermsTemplateId" => "gid://shopify/PaymentTermsTemplate/1",
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "referenceId": "gid://shopify/Order/922426937",
  "paymentTermsAttributes": {
    "paymentTermsTemplateId": "gid://shopify/PaymentTermsTemplate/1"
  }
}
Hide code
Response
JSON
{
  "paymentTermsCreate": {
    "paymentTerms": {
      "id": "gid://shopify/PaymentTerms/1054663035"
    },
    "userErrors": []
  }
}