我正在为我的学校终端项目工作,在我的网站上你可以买硬币打开礼物,但我想自动付款。当客户完成付款后,他被重定向到 success.php 我如何安排在付款成功后,他会在他的帐户中自动获得X金额?
很抱歉使用SQL会将其更新为PDO或mySQLi
像:
if (payment_finished){
sql= UPDATE 'users' SET 'balance' = $boughtamount WHERE username = '$username'
}
我将此按钮用于paypal。
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" style="display: inline-block;">
<input type="hidden" name="cmd" value="_s-xclick">
<table>
<tr align="center"><td><input type="hidden" name="on0" value="Coins">Number of Coins</td></tr><tr><td><select name="os0">
<option value="25 PackArmy Coins">25 Coins €0,50 EUR</option>
<option value="40 PackArmy Coins">40 Coins €0,80 EUR</option>
<option value="50 PackArmy Coins">50 Coins €1,00 EUR</option>
<option value="75 PackArmy Coins">75 Coins €1,50 EUR</option>
<option value="100 PackArmy Coins">100 Coins €2,00 EUR</option>
<option value="500 PackArmy Coins">500 Coins €5,00 EUR</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIJcQYJKoZIhvcNAQcEoIIJYjCCCV4CAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBsZdmwiE1gO3wLqzFAmwXBJweA121VGPH9H2h7G14AZyezyqdX7gMBwaOTmbF55+LRwskUyMoEcm5LrUuq6KaumR6crn/qeRvXinrSMkcuhv5l+lhnynEhrh5IW1vY3CaKBX5iehsGBsusN1r2Q8cpRBh3uH7sXEAIYOHkscALuDELMAkGBSsOAwIaBQAwggLtBgkqhkiG9w0BB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XwrEBb3dgNbMUa+u4qectsMAXpVHnD9wIyfmHMYIBmjCCAZYCAQEwgZQwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNTEyMTcyMTI5NDJaMCMGCSqGSIb3DQEJBDEWBBQiA60VyokC0xSOGim56NrzsvqgejANBgkqhkiG9w0BAQEFAASBgGX4gaSMF33+MvQsSytKNlNNG2Cb/Tl0hrsaMvT84hRwMZe+9casqkBn2SxaTXW04aJxv7fbSKe/jCjTgaVaFxJ+y2gIOQGOz2N8Hx3LcjVdKm46BhRtbls0mTsI5bhp9BbhzYo21DAFcTLEC51enQX+k22ALwE5P3sCzeVaGpU8-----END PKCS7-----
">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
</form>
我希望有人可以帮助我! 非常感谢。
亲切的问候, 菊兰
答案 0 :(得分:0)
根据您的paypal配置,当重定向时,付款将具有特定状态(成功/失败/取消/错误)。您可以检索该状态(和您的参考)以自动执行该过程。通常,当用户被“重定向”时,您将通过POST接收该数据。另一个选项是paypal在用户被重定向后发送数据的钩子。 为了了解如何获取数据,您应该阅读适合您在paypal上配置/方法的文档。