SOL & SPL Payments

Enables the developer to facilitate a transaction in which both the merchant and the customer want to use SOL or an SPL token (e.g. USDC) as payment.

Make sure you are following the rules of the API!

Example (SOL Payment)

import requests #make HTTP requests
import urllib.parse #encode the URL

#get a reference key
ref_url = 'http://api.mtnapi.com/ref'
r = requests.get(url = ref_url)
ref = r.json()['ref']

wallet='Ar7XrWtrGsB2xCnrTFLs9HyJ1bA62gXCAUZa8Fa7VMc5' #receiver
account = 'DaNDvvjZ3gdhjxeA3jKLGPTF7kNU8HupKKEgVTuHQwLi' #payer 
payerToken = 'usdc'
size = 0.1

#base URL
api_url = 'http://api.mtnapi.com/pay'
#query string parameters
params = {'wallet': wallet, 'size' : size, 'payerToken' : payerToken, 'ref' : ref}
#request body
data = {'account': account} 
#make the POST request
r = requests.post(url = api_url, params=params, json=data)

#encode the url
encoded_url = urllib.parse.quote(r.url)  
#append solana
solana_pay_url = 'solana:' + encoded_url

print(solana_pay_url)

Last updated