Skip to content

Latest commit

 

History

History
366 lines (281 loc) · 34.6 KB

File metadata and controls

366 lines (281 loc) · 34.6 KB

CheckoutSessions

Overview

Available Operations

  • create - Create checkout session
  • update - Update checkout session
  • get - Get checkout session
  • delete - Delete checkout session

create

Create a new checkout session.

Example Usage

import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";

const gr4vy = new Gr4vy({
    id: "example",
    server: "sandbox",
    merchantAccountId: "default",
    bearerAuth: withToken({
      privateKey: fs.readFileSync("private_key.pem", "utf8"),
    }),
});

async function run() {
  const result = await gr4vy.checkoutSessions.create();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { checkoutSessionsCreate } from "@gr4vy/sdk/funcs/checkoutSessionsCreate.js";

// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
  merchantAccountId: "<id>",
  bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});

async function run() {
  const res = await checkoutSessionsCreate(gr4vy);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("checkoutSessionsCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
merchantAccountId string The ID of the merchant account to use for this request.
checkoutSessionCreate components.CheckoutSessionCreate N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CheckoutSession>

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.SDKError 4XX, 5XX */*

update

Update the information stored on a checkout session.

Example Usage

import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";

const gr4vy = new Gr4vy({
    id: "example",
    server: "sandbox",
    merchantAccountId: "default",
    bearerAuth: withToken({
      privateKey: fs.readFileSync("private_key.pem", "utf8"),
    }),
});

async function run() {
  const result = await gr4vy.checkoutSessions.update({}, "4137b1cf-39ac-42a8-bad6-1c680d5dab6b");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { checkoutSessionsUpdate } from "@gr4vy/sdk/funcs/checkoutSessionsUpdate.js";

// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
  merchantAccountId: "<id>",
  bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});

async function run() {
  const res = await checkoutSessionsUpdate(gr4vy, {}, "4137b1cf-39ac-42a8-bad6-1c680d5dab6b");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("checkoutSessionsUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
sessionId string ✔️ The ID of the checkout session. 4137b1cf-39ac-42a8-bad6-1c680d5dab6b
checkoutSessionCreate components.CheckoutSessionCreate ✔️ N/A
merchantAccountId string The ID of the merchant account to use for this request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CheckoutSession>

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.SDKError 4XX, 5XX */*

get

Retrieve the information stored on a checkout session.

Example Usage

import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";

const gr4vy = new Gr4vy({
    id: "example",
    server: "sandbox",
    merchantAccountId: "default",
    bearerAuth: withToken({
      privateKey: fs.readFileSync("private_key.pem", "utf8"),
    }),
});

async function run() {
  const result = await gr4vy.checkoutSessions.get("4137b1cf-39ac-42a8-bad6-1c680d5dab6b");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { checkoutSessionsGet } from "@gr4vy/sdk/funcs/checkoutSessionsGet.js";

// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
  merchantAccountId: "<id>",
  bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});

async function run() {
  const res = await checkoutSessionsGet(gr4vy, "4137b1cf-39ac-42a8-bad6-1c680d5dab6b");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("checkoutSessionsGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
sessionId string ✔️ The ID of the checkout session. 4137b1cf-39ac-42a8-bad6-1c680d5dab6b
merchantAccountId string The ID of the merchant account to use for this request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CheckoutSession>

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.SDKError 4XX, 5XX */*

delete

Delete a checkout session and all of its (PCI) data.

Example Usage

import { Gr4vy, withToken } from "@gr4vy/sdk";
import fs from "fs";

const gr4vy = new Gr4vy({
    id: "example",
    server: "sandbox",
    merchantAccountId: "default",
    bearerAuth: withToken({
      privateKey: fs.readFileSync("private_key.pem", "utf8"),
    }),
});

async function run() {
  await gr4vy.checkoutSessions.delete("4137b1cf-39ac-42a8-bad6-1c680d5dab6b");


}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { checkoutSessionsDelete } from "@gr4vy/sdk/funcs/checkoutSessionsDelete.js";

// Use `Gr4vyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const gr4vy = new Gr4vyCore({
  merchantAccountId: "<id>",
  bearerAuth: process.env["GR4VY_BEARER_AUTH"] ?? "",
});

async function run() {
  const res = await checkoutSessionsDelete(gr4vy, "4137b1cf-39ac-42a8-bad6-1c680d5dab6b");
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("checkoutSessionsDelete failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
sessionId string ✔️ The ID of the checkout session. 4137b1cf-39ac-42a8-bad6-1c680d5dab6b
merchantAccountId string The ID of the merchant account to use for this request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<void>

Errors

Error Type Status Code Content Type
errors.Error400 400 application/json
errors.Error401 401 application/json
errors.Error403 403 application/json
errors.Error404 404 application/json
errors.Error405 405 application/json
errors.Error409 409 application/json
errors.HTTPValidationError 422 application/json
errors.Error425 425 application/json
errors.Error429 429 application/json
errors.Error500 500 application/json
errors.Error502 502 application/json
errors.Error504 504 application/json
errors.SDKError 4XX, 5XX */*