List incoming payments
Esta página aún no está disponible en tu idioma.
After one or more incoming payments are created on a wallet address, an authorized client can look up active and pending incoming payments on that wallet address.
These code snippets retrieve the first ten incoming payments on the given wallet address.
Before you begin
Section titled “Before you begin”We recommend creating a wallet account on the test wallet. Creating an account allows you to test your client against the Open Payments APIs by using an ILP-enabled wallet funded with play money.
List all incoming payments on a wallet address
Section titled “List all incoming payments on a wallet address” Prerequisites
Initial configuration
If you’re using JavaScript, only do the first step.
- Add
"type": "module"topackage.json. - Add the following to
tsconfig.json{"compilerOptions": {"target": "ES2022","module": "ES2022"}}
// Import dependenciesimport { createAuthenticatedClient } from '@interledger/open-payments'
// Initialize clientconst client = await createAuthenticatedClient({ walletAddressUrl: WALLET_ADDRESS, privateKey: PRIVATE_KEY_PATH, keyId: KEY_ID})
// Get wallet address informationconst walletAddress = await client.walletAddress.get({ url: WALLET_ADDRESS})
// List incoming paymentsconst incomingPayments = await client.incomingPayment.list( { url: walletAddress.resourceServer, walletAddress: WALLET_ADDRESS, accessToken: INCOMING_PAYMENT_ACCESS_TOKEN }, { first: 10, last: undefined, cursor: undefined, 'wallet-address': WALLET_ADDRESS })
// Outputconsole.log('INCOMING PAYMENTS:', JSON.stringify(incomingPayments, null, 2))For TypeScript, run tsx path/to/directory/index.ts. View full TS source
For JavaScript, run node path/to/directory/index.js. View full JS source
Prerequisites View full source
// Import dependenciesuse open_payments::client::api::AuthenticatedResources;use open_payments::client::utils::get_resource_server_url;use open_payments::snippets::utils::{create_authenticated_client, get_env_var, load_env};
// Initialize clientlet client = create_authenticated_client()?;
// List incoming paymentslet access_token = get_env_var("INCOMING_PAYMENT_ACCESS_TOKEN")?;
let wallet_address_url = get_env_var("WALLET_ADDRESS_URL")?;let resource_server_url = get_resource_server_url(&wallet_address_url)?;let response = client .incoming_payments() .list( &resource_server_url, &wallet_address_url, None, Some(10), None, Some(&access_token), ) .await?;
// Outputprintln!("Incoming payments: {:#?}", response.result);println!("Pagination info: {:#?}", response.pagination);
if response.pagination.has_next_page { if let Some(end_cursor) = response.pagination.end_cursor { let next_page = client .incoming_payments() .list( &resource_server_url, &wallet_address_url, Some(&end_cursor), Some(10), None, Some(&access_token), ) .await?; println!("Next page of incoming payments: {:#?}", next_page.result); }} Prerequisites View full source
// Import dependenciesuse OpenPayments\AuthClient;use OpenPayments\Config\Config;
// Initialize client$config = new Config( $WALLET_ADDRESS, $PRIVATE_KEY, $KEY_ID);$opClient = new AuthClient($config);
// Get wallet address information$wallet = $opClient->walletAddress()->get([ 'url' => $config->getWalletAddressUrl()]);
// List incoming payments$incomingPaymentsList = $opClient->incomingPayment()->list( [ 'url' => $wallet->resourceServer, 'access_token' => $INCOMING_PAYMENT_GRANT_ACCESS_TOKEN ], [ 'wallet-address' => $config->getWalletAddressUrl(), 'first' => 10, 'start'=> '96d964f0-3421-4df0-bb04-cb8d653bc571' ]);
// Outputecho 'INCOMING PAYMENTS ' . PHP_EOL . print_r($incomingPaymentsList, true); Prerequisites
package main
// Import dependenciesimport ( "context" "encoding/json" "fmt" "log"
op "github.com/interledger/open-payments-go")
func main() { // Initialize client client, err := op.NewAuthenticatedClient(WALLET_ADDRESS_URL, PRIVATE_KEY_BASE_64, KEY_ID) if err != nil { log.Fatalf("Error creating authenticated client: %v\n", err) }
// List incoming payments incomingPayments, err := client.IncomingPayment.List(context.TODO(), op.IncomingPaymentListParams{ BaseURL: RESOURCE_SERVER_URL, AccessToken: INCOMING_PAYMENT_ACCESS_TOKEN, WalletAddress: WALLET_ADDRESS_URL, Pagination: op.Pagination{ First: "10", }, }) if err != nil { log.Fatalf("Error listing incoming payments: %v\n", err) }
// Output incomingPaymentsJSON, err := json.MarshalIndent(incomingPayments, "", " ") if err != nil { log.Fatalf("Error marshaling incoming payments: %v\n", err) } fmt.Println("INCOMING PAYMENTS:", string(incomingPaymentsJSON))} Prerequisites
// Import dependenciesimport org.interledger.openpayments.httpclient.OpenPaymentsHttpClient;import org.interledger.openpayments.IOpenPaymentsClient;
// Initialize clientvar client = OpenPaymentsHttpClient.defaultClient("WalletAddress","PrivateKeyPEM","KeyId");
// Get wallet address informationvar receiverWallet = client.getWalletAddress("https://cloudninebank.example.com/merchant");var senderWallet = client.getWalletAddress("https://cloudninebank.example.com/customer");
// Create incoming paymentvar grantRequest = this.client.createGrantIncomingPayment(receiverWallet);var incomingPayment = this.client.createIncomingPayment(receiverWallet, grantRequest, BigDecimal.valueOf(11.25));
// Retrieve the created incoming payments (by walletAddress)var incomingPaymentsFetched = this.client.getIncomingPayments(senderWallet, senderWallet.getId(), grantRequest);
// Outputlog.info("INCOMING_PAYMENT_RESULT: {}", incomingPaymentsFetched.getResult().size());incomingPaymentsFetched.getResult().forEach(p -> log.info("INCOMING_PAYMENT: {}", p));