Most payment systems use a data signature. You are given (or you yourself specify a certain key in the PS setup on its server). This key is known only to you and the server of the payment system; this key is NEVER transmitted in the request.
You show a form to the user, the user fills it and clicks the "send" button, then YOUR script checks the required fields and forms the query string to the PS server. Usually, the request is the values ​​of the fields filled by the user (amount, currency) + data of the seller (store name, ID, etc.) + signature.
The signature, for example, is md5 from all values ​​of the required fields and the secret key separated by a symbol: md5(fielfd1::field2::field3::secret_key)
. The algorithm for obtaining the signature is described in the documentation for the PS
If the subscriber requests to forward the user to the subscriber server, to confirm the payment, then you create another form with hidden fields required for the transfer + signature. The form can be sent using JavaScript or you can add a "Confirm" button, which the user must click to confirm the payment.
A server accepting data from you also creates a signature using the same algorithm as you, using a secret key. The received signature is compared with the one that was sent in the request, if it does not match, the payment will not be completed. Also, the payment system can send you a "background" request to confirm the payment, which you must answer with a certain code.
If user redirection is not required, then you can send a request to the server using curl
There are payment systems that use personal SSL certificates to establish communication store <-> server PS.
This is an approximate description. Each PS has its own documentation in which the work algorithm and data verification algorithms are described.