payments-py

module payments


class Payments

A class representing a payment system.

Attributes:

Methods:

method __init__

__init__(
    nvm_api_key: str,
    environment: Environment,
    app_id: Optional[str] = None,
    version: Optional[str] = None,
    ai_protocol: bool = False,
    headers: Optional[dict] = None,
    web_socket_options: Optional[dict] = None
)

method burn_credits

burn_credits(plan_did: str, amount: str)  BurnResultDto

Burn credits for a given Payment Plan DID.

This method is only can be called by the owner of the Payment Plan.

Args:

Returns:

Raises:

Example: response = your_instance.burn_credits(plan_did=”did:nv:e405a91e3152be1430c5d0607ebdf9236c19f34bfba0320798d81ba5f5e3e3a5”, amount=”12”) print(response)


method create_credits_plan

create_credits_plan(
    name: str,
    description: str,
    price: int,
    token_address: str,
    amount_of_credits: int,
    tags: Optional[List[str]] = None
)  CreateAssetResultDto

It allows to an AI Builder to create a Payment Plan on Nevermined based on Credits. A Nevermined Credits Plan limits the access by the access/usage of the Plan. With them, AI Builders control the number of requests that can be made to an agent or service. Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits. When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.

This method is oriented to AI Builders.

https://docs.nevermined.app/docs/tutorials/builders/create-plan

Args:

Returns:

Raises:

Example: response = your_instance.create_credits_plan(name=”Basic Plan”, description=”100 credits plan”, price=1, token_address=”0x1234”, amount_of_credits=100, tags=[“basic”]) print(response)


method create_file

create_file(
    plan_did: str,
    asset_type: str,
    name: str,
    description: str,
    files: List[dict],
    data_schema: Optional[str] = None,
    sample_code: Optional[str] = None,
    files_format: Optional[str] = None,
    usage_example: Optional[str] = None,
    programming_language: Optional[str] = None,
    framework: Optional[str] = None,
    task: Optional[str] = None,
    training_details: Optional[str] = None,
    variations: Optional[str] = None,
    fine_tunable: Optional[bool] = None,
    amount_of_credits: Optional[int] = None,
    tags: Optional[List[str]] = None
)  CreateAssetResultDto

It creates a new asset with file associated to it. The file asset must be associated to a Payment Plan. Users that are subscribers of a payment plan can download the files attached to it. Depending on the Payment Plan and the configuration of the file asset, the download will consume credits. When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue downloading the files.

This method is oriented to AI Builders

https://docs.nevermined.app/docs/tutorials/builders/register-file-asset

Args:

Returns:

Raises:

Example: response = your_instance.create_file(plan_did=”did:nv:xyz789”, asset_type=”dataset”, name=”Sample Dataset”, description=”A sample dataset”, files=[{“name”: “file1.csv”, “url”: “https://example.com/file1.csv”}]) print(response)


method create_service

create_service(
    plan_did: str,
    service_type: str,
    name: str,
    description: str,
    service_charge_type: str,
    auth_type: str,
    amount_of_credits: int = 1,
    min_credits_to_charge: Optional[int] = 1,
    max_credits_to_charge: Optional[int] = 1,
    username: Optional[str] = None,
    password: Optional[str] = None,
    token: Optional[str] = None,
    endpoints: Optional[List[dict]] = None,
    open_endpoints: Optional[List[str]] = [],
    open_api_url: Optional[str] = None,
    integration: Optional[str] = None,
    sample_link: Optional[str] = None,
    api_description: Optional[str] = None,
    tags: Optional[List[str]] = None,
    is_nevermined_hosted: Optional[bool] = None,
    implements_query_protocol: Optional[bool] = None,
    query_protocol_version: Optional[str] = None,
    service_host: Optional[str] = None
)  CreateAssetResultDto

It creates a new AI Agent or Service on Nevermined. The agent/service must be associated to a Payment Plan. Users that are subscribers of a payment plan can access the agent/service. Depending on the Payment Plan and the configuration of the agent/service, the usage of the agent/service will consume credits. When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent/service.

This method is oriented to AI Builders

https://docs.nevermined.app/docs/tutorials/builders/register-agent

Args:

Returns:

Raises:

Example: response = your_instance.create_service(plan_did=”did:nv:abc123”, service_type=”service”, name=”My Service”, description=”A sample service”, service_charge_type=”fixed”, auth_type=”none”) print(response)


method create_time_plan

create_time_plan(
    name: str,
    description: str,
    price: int,
    token_address: str,
    duration: Optional[int] = 0,
    tags: Optional[List[str]] = None
)  CreateAssetResultDto

It allows to an AI Builder to create a Payment Plan on Nevermined based on Time. A Nevermined Time Plan limits the access by the a specific amount of time. With them, AI Builders can specify the duration of the Payment Plan (1 month, 1 year, etc.). When the time period is over, the plan automatically expires and the user needs to renew it.

This method is oriented to AI Builders

https://docs.nevermined.app/docs/tutorials/builders/create-plan

Args:

Returns:

Raises:

Example: response = your_instance.create_time_plan(name=”Yearly Plan”, description=”Annual plan”, price=1200, token_address=”0x5678”, duration=365, tags=[“yearly”, “premium”]) print(response)


method download_file

download_file(
    file_did: str,
    destination: str,
    agreement_id: Optional[str] = None
)  DownloadFileResultDto

Downloads the file.

Args:

Returns:

Returns:

Raises:

Example: response = your_instance.download_file(file_did=”did:nv:7e38d39405445ab3e5435d8c1c6653a00ddc425ba629789f58fbefccaa5e5a5d”, destination=”/tmp”) print(response)


method get_asset_ddo

get_asset_ddo(did: str)

Get the Metadata (aka Decentralized Document or DDO) for a given asset identifier (DID).

https://docs.nevermined.io/docs/architecture/specs/Spec-DID https://docs.nevermined.io/docs/architecture/specs/Spec-METADATA

Args:

Returns:


method get_checkout_plan

get_checkout_plan(plan_did: str)

Gets the checkout plan.

Args:

Returns:


method get_file_details_url

get_file_details_url(file_did: str)

Gets the file details.

Args:

Returns:


method get_plan_associated_files

get_plan_associated_files(plan_did: str)

Get array of files DIDs associated with a payment plan.

Args:

Returns:


method get_plan_associated_services

get_plan_associated_services(plan_did: str)

Get array of services/agent DIDs associated with a payment plan.

Args:

Returns:


method get_plan_balance

get_plan_balance(plan_did: str, account_address: str)  BalanceResultDto

Get the balance of an account for a Payment Plan.

Args:

Returns:

Raises:

Example: response = your_instance.get_plan_balance(plan_did=”did:example:123456”, account_address=”0xABC123”) response.raise_for_status() balance = BalanceResultDto.model_validate(response.json()) print(balance)

Expected Response: { “planType”: “credits”, “isOwner”: True, “isSubscriptor”: True, “balance”: 10000000 }


method get_plan_details_url

get_plan_details_url(plan_did: str)

Gets the plan details.

Args:

Returns:


method get_service_details_url

get_service_details_url(service_did: str)

Gets the service details.

Args:

Returns:


method get_service_token

get_service_token(service_did: str)  ServiceTokenResultDto

Get the required configuration for accessing a remote service agent. This configuration includes: - The JWT access token - The Proxy url that can be used to query the agent/service.

Args:

Returns:

Raises:

Example: response = your_instance.get_service_token(service_did=”did:nv:xyz789”) print(response)


method mint_credits

mint_credits(plan_did: str, amount: str, receiver: str)  MintResultDto

Mints the credits associated with a plan and sends them to the receiver.

Args:

Returns:

Raises:

Example: response = your_instance.mint_credits(plan_did=”did:nv:e405a91e3152be1430c5d0607ebdf9236c19f34bfba0320798d81ba5f5e3e3a5”, amount=”12”, receiver=”0x4fe3e7d42fA83be4E8cF03451Ac3F25980a73fF6”) print(response)


method order_plan

order_plan(
    plan_did: str,
    agreementId: Optional[str] = None
)  OrderPlanResultDto

Orders a Payment Plan. The user needs to have enough balance in the token selected by the owner of the Payment Plan.

The payment is done using Crypto. Payments using Fiat can be done via the Nevermined App.

Args:

Returns:

Raises:

Example: response = your_instance.order_plan(plan_did=”did:nv:a0079b517e580d430916924f1940b764e17c31e368c509483426f8c2ac2e7116”) print(response)


This file was automatically generated via lazydocs.