Skip to content

Latest commit

 

History

History
382 lines (297 loc) · 35.9 KB

File metadata and controls

382 lines (297 loc) · 35.9 KB

PaymentLinks

Overview

Available Operations

  • create - Add a payment link
  • list - List all payment links
  • expire - Expire a payment link
  • get - Get payment link

create

Create a new payment link.

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.paymentLinks.create({
    amount: 1299,
    country: "DE",
    currency: "EUR",
    store: true,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { paymentLinksCreate } from "@gr4vy/sdk/funcs/paymentLinksCreate.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 paymentLinksCreate(gr4vy, {
    amount: 1299,
    country: "DE",
    currency: "EUR",
    store: true,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("paymentLinksCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
paymentLinkCreate components.PaymentLinkCreate ✔️ 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.PaymentLink>

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 */*

list

List all created payment links.

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.paymentLinks.list();

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { paymentLinksList } from "@gr4vy/sdk/funcs/paymentLinksList.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 paymentLinksList(gr4vy);
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("paymentLinksList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
cursor string A pointer to the page of results to return. ZXhhbXBsZTE
limit number The maximum number of items that are returned. 20
buyerSearch string[] Filters the results to only get the items for which some of the buyer data contains exactly the provided buyer_search values. [
"John",
"London"
]
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<operations.ListPaymentLinksResponse>

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 */*

expire

Expire an existing payment link.

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.paymentLinks.expire("a1b2c3d4-5678-90ab-cdef-1234567890ab");


}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { paymentLinksExpire } from "@gr4vy/sdk/funcs/paymentLinksExpire.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 paymentLinksExpire(gr4vy, "a1b2c3d4-5678-90ab-cdef-1234567890ab");
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("paymentLinksExpire failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
paymentLinkId string ✔️ The unique identifier for the payment link. a1b2c3d4-5678-90ab-cdef-1234567890ab
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 */*

get

Fetch the details for a payment link.

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.paymentLinks.get("a1b2c3d4-5678-90ab-cdef-1234567890ab");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { paymentLinksGet } from "@gr4vy/sdk/funcs/paymentLinksGet.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 paymentLinksGet(gr4vy, "a1b2c3d4-5678-90ab-cdef-1234567890ab");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("paymentLinksGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
paymentLinkId string ✔️ The unique identifier for the payment link. a1b2c3d4-5678-90ab-cdef-1234567890ab
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.PaymentLink>

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 */*