예제 #1
0
 case "trade_status_sync":
     $default_config = array('secrete_key' => false);
     $service = Configuration::get('ALIPAY_SERVICE_NOTIFY_VERIFY');
     $credentials = AlipayTools::getCredentials($service, $default_config);
     $alipayapi = new AlipayApi($credentials);
     $alipay_notify->setParamList('notify_verify');
     $alipayapi->prepareRequest($alipay_notify, false);
     $url = $alipayapi->createUrl();
     $alipay_notify->setParamList('compare_sign');
     $params = $alipayapi->getProtocolParams();
     unset($params['partner']);
     unset($params['service']);
     $alipayapi->setProtocolParams($params);
     $alipayapi->setSecreteKey(Configuration::get('ALIPAY_SECRETE_KEY'));
     $alipayapi->prepareRequest($alipay_notify);
     if ($alipayapi->getResponse($url) != 'true' || !$alipay_notify->verifyDupplicates() || $alipayapi->getSign() != Tools::getValue('sign')) {
         return;
     }
     if ($alipay_notify->saveNotify()) {
         $alipay = new Alipay();
         $extra_vars = array();
         $extra_vars['transaction_id'] = $alipay_notify->getTradeNo();
         $alipay->validateOrder((int) $alipay_notify->getIdCart(), Configuration::get('PS_OS_PAYMENT'), $alipay_notify->getTotalFee(), 'Alipay', null, $extra_vars, null, false, $alipay_notify->getSecureKey());
         $id_order = (int) Order::getOrderByCartId($alipay_notify->getIdCart());
         if ($id_order) {
             $alipay_notify->saveOrder($id_order);
             header('HTTP/1.1 200 OK');
             echo "success";
             exit;
         }
     }
예제 #2
0
 /**
  * This method download the Settlement File
  */
 public function postProcessSettlementFile()
 {
     include_once _PS_MODULE_DIR_ . 'alipay/api/loader.php';
     $service = Configuration::get('ALIPAY_SERVICE_LIQUIDATION_FILE');
     $credentials = AlipayTools::getCredentials($service, false);
     $alipayapi = new AlipayApi($credentials);
     $settlement_request = new SettlementFileRequest();
     $settlement_request->setStartDate(str_replace('-', '', Tools::getValue('from_settlement')));
     $settlement_request->setEndDate(str_replace('-', '', Tools::getValue('to_settlement')));
     $alipayapi->prepareRequest($settlement_request);
     $url = $alipayapi->createUrl();
     $xml = simplexml_load_string(Tools::file_get_contents($url));
     if ($xml) {
         $response = $alipayapi->getResponse($url);
         $xmlObj = new SimpleXMLElement($response);
         $this->context->controller->errors[] = sprintf($this->l('An error occurred: %s'), $xmlObj->error);
     } else {
         Tools::redirect($url);
     }
 }