Payment With USD
Stable Coins
Stable coins, such as USDC (Circle), USDT (Tether), or BUSD (Binance and Paxos), represent a unique category of cryptocurrencies (tokens) that maintain a stable value by being pegged to a traditional currency, most commonly the US Dollar (USD). Simply put:
- 1 USDC (or any stable coin) is roughly equivalent to 1 USD
Key Characteristics of Stable Coins:
- Value Stability: Stable coins are designed to have a consistent value, providing a stable medium of exchange in the often volatile crypto market.
- Asset-Backed: They are typically backed by USD or equivalent assets, such as US treasury bonds, ensuring their stability.
Choosing a Stable Coin:
The selection of a stable coin for use is contingent upon your personal use and assessment of each option. While all stable coins aim to maintain a stable value, the mechanisms and assets backing them may vary, but shouldn't affect the overall flow or result.
Create a Charge
Charge
Below, we will demonstrate how to utilize USDC on the Polygon Chain:
USDC Token Address on Polygon: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
To create a charge
for 10 USD
:
import { sphereoneSdk } from "./your-implementation-file";
import { SupportedChains } from "websdk";
// ...
const [chargeId, setChargeId] = useState("");
const [paymentLink, setPaymentLink] = useState("");
const {chargeId} = await WebSDK.createCharge({
chargeData: {
symbol: "USDC",
chain: SupportedChains.POLYGON,
successUrl: "https://sphereone.xyz/",
cancelUrl: "https://sphereone.xyz/consumer",
tokenAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
items: [
{
name: "USDC",
image:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/US10dollarbill-Series_2004A.jpg/2880px-US10dollarbill-Series_2004A.jpg",
amount: 10,
quantity: 1,
}
]
},
})
using SphereOne;
// ...
var chargeItems = new List<ChargeItem>
{
new ChargeItem
{
name = "Your Item",
image = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/US10dollarbill-Series_2004A.jpg/2880px-US10dollarbill-Series_2004A.jpg",
amount = 10.0,
quantity = 1,
}
};
var chargeRequest = new ChargeReqBody
{
chain = SupportedChains.SOLANA,
symbol = "POLYGON",
amount = 10.0,
tokenAddress = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
items = chargeItems,
successUrl = "https://your-website.com/success",
cancelUrl = "https://your-website.com/cancel",
};
var isTest = false;
var charge = await SphereOneManager.Instance.CreateCharge(chargeRequest, isTest);
if (charge == null) {
// Handle the error
return;
}
Debug.Log(charge.ToString());
From here, we can call payCharge
by passing in the chargeId
that we receive from createCharge
to begin our process.
// importing the initialized WebSDK
import { sphereoneSdk } from "your-implementation-file";
import { SupportedChains } from "websdk";
// ...
// these are from previous section from: https://docs.sphereone.xyz/docs/create-charge#web-sdk
const [chargeId, setChargeId] = useState("");
const [paymentLink, setPaymentLink] = useState("");
// ... createCharge example ...
const pay = async () => {
try {
await sphereoneSdk.payCharge(chargeId);
} catch (e: any) {
console.error(e);
}
};
Updated 6 months ago