Paypal付款按钮 - 您能动态设置价格

时间:2016-05-14 02:27:00

标签: php paypal e-commerce

我当然对使用PayPal的标准付款按钮感兴趣;但是,我希望能够在代码中设置自己的金额,而不是被迫通过Paypal创建固定金额的按钮。例如,我认为以下代码可以工作:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="amount" value="5.00">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIH2wYJKoZIhvcNAQcEoIIHzDCCB8gCAQExggE6MIIBNgIBADCBnjCBmDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMRUwEwYDVQQKEwxQYXlQYWwsIEluYy4xFjAUBgNVBAsUDXNhbmRib3hfY2VydHMxFDASBgNVBAMUC3NhbmRib3hfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMA0GCSqGSIb3DQEBAQUABIGAH+DqNBRlDwSh687j3TxNmxEdl5QzHnS7yVrZpgBots7qg9fODfjYUlgXXMPz35gB65jiD+jsCd1dc3yVZ5mNRtMu8uyLkKO4APlg4qJZETM5zmtoMeom4AMXCm+1hagsWjMEE3o5oUGyjEkFwz+pflNqviUoEQwdCv2OwVTUD3sxCzAJBgUrDgMCGgUAMIIBJQYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAg6YkTw6MwNS4CCAQDYJ/09z9A6ApCy4d4xtEkMuTkTvCESa5b9Lk00U+hNiOEaEW8e8aO/08AzeKG9PmnZE+GC59Esr4TMMpxoLRyl5nyWk0jfGQX4CwRYlWQXgLRcfe2psN1iFy2vdMOpa5mruZB65iWZvd432790pmYP24Tmq3mAhJLKfkeR0Hqyc9n2bW/al3DuGvjZROSLw9z63FxZI8Hmvzcms2TBTNij1i72+jXB1yyIUBFVd0H5xk5l5hrpSm12+dCm/sIR5NNKfPFreJ84h3xef2dXDR62fGhP3vHfSJ0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DXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBXNvPA2Bl/hl9vlj/3cHV8H4nH/q5RvtFfRgTyWWCmSUNOvVv2UZFLlhUPjqXdsoT6Z3hns5sN2lNttghq3SoTqwSUUXKaDtxYxx5l1pKoG0Kg1nRu0vv5fJ9UHwz6fo6VCzq3JxhFGONSJo2SU8pWyUNW+TwQYxoj9D6SuPHHRTGCAaQwggGgAgEBMIGeMIGYMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2UxFTATBgNVBAoTDFBheVBhbCwgSW5jLjEWMBQGA1UECxQNc2FuZGJveF9jZXJ0czEUMBIGA1UEAxQLc2FuZGJveF9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE2MDUxNDAyMTQ1NlowIwYJKoZIhvcNAQkEMRYEFEZCu52pVGGuQnysWYPrliEa73/0MA0GCSqGSIb3DQEBAQUABIGAdbJUsYUTVyNZ/0/ivmpPr1xSzk9okSRA6lrmgSOWwZP7/sukM/mSZ9b/nvjStbspSK1HPgmDyeDmKy355dX83/42P04b/faGikPPaBHSvEsoL4MmMSj/Jqfzg1iV8tbynyf/VT9DlitZlho54CygGaT/ZcML6M/JRJlECWzsnc0=-----END PKCS7-----
">
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

这也不起作用:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="U7K937HLYPW6L">
<input type="hidden" name="amount" value="5.00">
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

该页面不是将用户引导到他们可以支付5.00的页面,而是允许用户输入他们自己的金额。在我的实际应用程序中,我将使用PHP来计算总数(在购物车样式页面上)并将该值与“amount”键相关联,但即使使用静态值,我甚至无法使其工作。解决方案是什么?

非常感谢!

1 个答案:

答案 0 :(得分:0)

您需要利用他们的API来制作动态定价,以摆脱paypal提供的“购物车”类型系统。从本质上讲,您可以使用API​​通过编码替换paypal“cart”页面。