Answer the question
In order to leave comments, you need to log in
How to technically implement the conversion of national currencies to USD of the Perfect Money payment system?
Now, with the back-end team, we are finishing work on a service where you can buy various gift cards through crypto and perfect money. On the site, when entering the national currency, for example, RUR, the amount of USD PM should be immediately calculated. For example, a user wants to buy a gift card with a face value of 1000 RUR, and pay USD perfect money, that is, how to automatically calculate the amount of RUR/USD?
Answer the question
In order to leave comments, you need to log in
a separate service with the determination of rates depending on the Central Bank of Russia and the conversion costs
and then simply multiply as USD currency
You should have two rates, usd -> rub exchange rate and rub -> usd exchange rate, and they should be different. Correct implementation - you must keep somewhere where you can change rubles and dollars back and forth (ideally, the exchange, since there is a minimum spread), some cash amount in both currencies, and at the moment when your client makes a deal, make an exchange, exactly the same amount on this exchange. Thus, the total number of bucks and rubles on the exchange and on your perfectmoney wallet should not change. Then, when the bias on the exchange becomes dangerous, make a transfer from perfectmoney to the exchange (or vice versa), returning the ratio of the amounts of currencies to a certain base.
To understand how much of which currency you need to keep, you need to decide in which currency you will keep the deposit - this will be the main currency, all other currencies should be on the balance exactly in the amount that may be needed to serve the users who came up at the same time. At the same time - it means from the moment when the user came up and you showed him the course and he pressed the button 'yes I'm paying' someone else does the same.
If you will not (or cannot) do as I said (for example, clients came to you at the same time for an amount greater than the cash amount on the exchange), then you can cover your risks of changing the rate (as long as you have bucks on hand and you need rubles, for example ) an increase in the difference between the buying and selling rates (at which you show the price on the site) relative to the rates on the exchange where you keep the cash amount. For example, banks do this - on the stock exchange, the spread is a fraction of a percent, and the bank exchange rate gives you a few percent.
Of course, the above scheme is universal, when you need conversion in both directions, usually it is needed only in one direction, which means that you can only hold one currency on the exchange.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question