-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.js
32 lines (32 loc) · 1.2 KB
/
checkout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { ListingClient, CommerceCatalog, AtellixClient } from '@atellix/catalog'
import anchor from '@coral-xyz/anchor'
async function main() {
const provider = anchor.AnchorProvider.env()
const listingClient = new ListingClient(provider)
const merchants = await listingClient.getListings({
catalog: 'commerce',
category: 'http://www.productontology.org/id/Test_drive',
})
for (var merchantListing of merchants.listings) {
const merchantOffers = await listingClient.getListingEntries({
url: merchantListing.url
})
const commerce = new CommerceCatalog()
const order = await commerce.prepareOrder({
items: [{'id': merchantOffers.entries[0].id}],
payment_method: 'atellixpay',
billing_address: {
'country': 'us',
},
shipping_address: {
'email': '[email protected]',
'country': 'us',
},
})
console.log(order)
const atxpay = new AtellixClient(provider)
const ckout = await atxpay.checkout(order.payments, provider.wallet.publicKey, 'USDC')
console.log(ckout)
}
}
main().then(() => {})