Home  >  Article  >  Backend Development  >  Integrate mobile web payment on ecshop

Integrate mobile web payment on ecshop

WBOY
WBOYOriginal
2016-07-25 09:01:11911browse
Refer to the code of alipay web payment interface

In fact, the principle is similar to the alipay payment integrated on ecshop. It is because the response time when using curl request is too long, so you cannot directly post the data first and then generate the button.
  1. /**
  2. * Generate payment code
  3. * @param array $order order information
  4. * @param array $payment payment method information
  5. */
  6. function get_code($order, $payment)
  7. {
  8. if (!defined('EC_CHARSET'))
  9. {
  10. $charset = 'utf-8';
  11. }
  12. else
  13. {
  14. $charset = EC_CHARSET;
  15. }
  16. $jsonorder = json_encode($order);
  17. $jsonpayment = json_encode($payment);
  18. $jsonorder = urlencode($jsonorder);
  19. $jsonpayment = urlencode($jsonpayment );
  20. $button = '
    ';
  21. return $button;
  22. }
Copy code
  1. if (isset($set_modules) && $set_modules == TRUE)
  2. {
  3. $i = isset($modules) ? count($modules) : 0;
  4. /* Code*/
  5. $modules[$ i]['code'] = basename(__FILE__, '.php');
  6. /* Describe the corresponding language item*/
  7. $modules[$i]['desc'] = 'alipay_mobile_desc';
  8. /* Whether to support cash on delivery*/
  9. $modules[$i]['is_cod'] = '0';
  10. /* Whether to support online payment*/
  11. $modules[$i]['is_online'] = '1' ;
  12. /* Author*/
  13. $modules[$i]['author'] = 'luoluo';
  14. /* URL*/
  15. $modules[$i]['website'] = ALIPAY_WEBSITE_URL;
  16. / * Version number*/
  17. $modules[$i]['version'] = '1.0.2';
  18. /* Configuration information*/
  19. $modules[$i]['config'] = array(
  20. array( 'name' => 'alipay_account', 'type' => 'text', 'value' => ''),
  21. array('name' => 'alipay_key', 'type' => ' text', 'value' => ''),
  22. array('name' => 'alipay_partner', 'type' => 'text', 'value' => ''),
  23. );
  24. return;
  25. }
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn