(paymentMethods)
- list - List all payment methods
- create - Create payment method
- get - Get payment method
- delete - Delete payment method
List all stored payment method.
import { Gr4vy } from "@gr4vy/sdk";
const gr4vy = new Gr4vy({
merchantAccountId: "<id>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.paymentMethods.list();
for await (const page of result) {
console.log(page);
}
}
run();
The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { withToken } from "@gr4vy/sdk/lib/auth.js";
import { paymentMethodsList } from "@gr4vy/sdk/funcs/paymentMethodsList.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>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const res = await paymentMethodsList(gr4vy);
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("paymentMethodsList failed:", res.error);
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.ListPaymentMethodsRequest | ✔️ | The request object to use for the 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. |
Promise<operations.ListPaymentMethodsResponse>
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 | */* |
Store a new payment method.
import { Gr4vy } from "@gr4vy/sdk";
const gr4vy = new Gr4vy({
merchantAccountId: "<id>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.paymentMethods.create({
id: "4137b1cf-39ac-42a8-bad6-1c680d5dab6b",
});
console.log(result);
}
run();
The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { withToken } from "@gr4vy/sdk/lib/auth.js";
import { paymentMethodsCreate } from "@gr4vy/sdk/funcs/paymentMethodsCreate.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>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const res = await paymentMethodsCreate(gr4vy, {
id: "4137b1cf-39ac-42a8-bad6-1c680d5dab6b",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("paymentMethodsCreate failed:", res.error);
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
requestBody |
operations.CreatePaymentMethodBody | ✔️ | 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. |
Promise<components.PaymentMethod>
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 | */* |
Retrieve a payment method.
import { Gr4vy } from "@gr4vy/sdk";
const gr4vy = new Gr4vy({
merchantAccountId: "<id>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const result = await gr4vy.paymentMethods.get("ef9496d8-53a5-4aad-8ca2-00eb68334389");
console.log(result);
}
run();
The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { withToken } from "@gr4vy/sdk/lib/auth.js";
import { paymentMethodsGet } from "@gr4vy/sdk/funcs/paymentMethodsGet.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>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const res = await paymentMethodsGet(gr4vy, "ef9496d8-53a5-4aad-8ca2-00eb68334389");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("paymentMethodsGet failed:", res.error);
}
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
paymentMethodId |
string | ✔️ | The ID of the payment method | [object Object] |
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. |
Promise<components.PaymentMethod>
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 | */* |
Delete a payment method.
import { Gr4vy } from "@gr4vy/sdk";
const gr4vy = new Gr4vy({
merchantAccountId: "<id>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
await gr4vy.paymentMethods.delete("ef9496d8-53a5-4aad-8ca2-00eb68334389");
}
run();
The standalone function version of this method:
import { Gr4vyCore } from "@gr4vy/sdk/core.js";
import { withToken } from "@gr4vy/sdk/lib/auth.js";
import { paymentMethodsDelete } from "@gr4vy/sdk/funcs/paymentMethodsDelete.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>",
server: "sandbox",
id: "example",
bearerAuth: withToken({
privateKey: fs.readFileSync("private_key.pem", "utf8"),
}),
});
async function run() {
const res = await paymentMethodsDelete(gr4vy, "ef9496d8-53a5-4aad-8ca2-00eb68334389");
if (res.ok) {
const { value: result } = res;
} else {
console.log("paymentMethodsDelete failed:", res.error);
}
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
paymentMethodId |
string | ✔️ | The ID of the payment method | [object Object] |
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. |
Promise<void>
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 | */* |