/** * 成功响应 */ public function success(Unifiedorder $unifiedorder) { $unifiedorder->set('trade_type', 'NATIVE'); $response = $unifiedorder->getResponse(); $options = array('appid' => $unifiedorder['appid'], 'mch_id' => $unifiedorder['mch_id'], 'prepay_id' => $response['prepay_id'], 'nonce_str' => Util::getRandomString(), 'return_code' => static::SUCCESS, 'result_code' => static::SUCCESS); // 按 ASCII 码排序 ksort($options); $signature = urldecode(http_build_query($options)); $signature = strtoupper(md5($signature . '&key=' . $unifiedorder->getKey())); $options['sign'] = $signature; $this->xmlResponse($options); }
/** * 构造方法 */ public function __construct(Unifiedorder $unifiedorder) { $unifiedorder->set('trade_type', 'NATIVE'); $this->unifiedorder = $unifiedorder; }