/** * Get the raw data array for this message. The format of this varies from gateway to * gateway, but will usually be either an associative array, or a SimpleXMLElement. * * @return mixed */ public function getData() { $this->validate('key', 'partner', 'notify_url', 'subject', 'out_trade_no'); $data = array('service' => 'create_forex_trade', 'partner' => $this->getPartner(), 'notify_url' => $this->getNotifyUrl(), 'return_url' => $this->getReturnUrl(), 'sign_type' => $this->getSignType() ?: 'MD5', 'subject' => $this->getSubject(), '_input_charset' => $this->getInputCharset() ?: 'utf-8', 'body' => $this->getBody(), 'out_trade_no' => $this->getOutTradeNo(), 'currency' => $this->getCurrency() ?: 'USD', 'total_fee' => $this->getTotalFee(), 'rmb_fee' => $this->getRmbFee(), 'supplier' => $this->getSupplier(), 'order_gmt_create' => $this->getOrderGmtCreate(), 'order_valid_time' => $this->getOrderValidTime(), 'timeout_rule' => $this->getTimeoutRule(), 'specified_pay_channel' => $this->getSpecifiedPayChannel(), 'seller_id' => $this->getSellerId(), 'seller_name' => $this->getSellerIndustry()); $data = array_filter($data); $data['sign'] = Helper::sign($data, 'MD5', $this->getKey()); return $data; }
/** * Get the raw data array for this message. The format of this varies from gateway to * gateway, but will usually be either an associative array, or a SimpleXMLElement. * @return mixed * @throws InvalidRequestException */ public function getData() { $this->validate('key', 'partner', 'notify_url', 'subject', 'out_trade_no'); if ($this->getTotalFee() && $this->getRmbFee()) { throw new InvalidRequestException("The 'total_fee' and 'rmb_fee' parameter can not be provide together"); } if (!$this->getTotalFee() && !$this->getRmbFee()) { throw new InvalidRequestException("The 'total_fee' and 'rmb_fee' must be provide one of them"); } $data = array('service' => 'create_forex_trade', 'partner' => $this->getPartner(), 'notify_url' => $this->getNotifyUrl(), 'return_url' => $this->getReturnUrl(), 'sign_type' => $this->getSignType() ?: 'MD5', 'subject' => $this->getSubject(), '_input_charset' => $this->getInputCharset() ?: 'utf-8', 'body' => $this->getBody(), 'out_trade_no' => $this->getOutTradeNo(), 'currency' => $this->getCurrency() ?: 'USD', 'total_fee' => $this->getTotalFee(), 'rmb_fee' => $this->getRmbFee(), 'supplier' => $this->getSupplier(), 'order_gmt_create' => $this->getOrderGmtCreate(), 'order_valid_time' => $this->getOrderValidTime(), 'timeout_rule' => $this->getTimeoutRule(), 'specified_pay_channel' => $this->getSpecifiedPayChannel(), 'seller_id' => $this->getSellerId(), 'seller_name' => $this->getSellerIndustry(), 'split_fund_info' => $this->getSplitFundInfo(), 'product_code' => $this->getProductCode()); $data = array_filter($data); $data['sign'] = Helper::sign($data, 'MD5', $this->getKey()); return $data; }
/** * Get the raw data array for this message. The format of this varies from gateway to * gateway, but will usually be either an associative array, or a SimpleXMLElement. * @return mixed * @throws InvalidRequestException */ public function getData() { $this->validate('partner', 'out_trade_no', 'subject'); $signType = strtoupper($this->getSignType() ?: 'MD5'); if ($signType == 'MD5') { $this->validate('key'); } else { $this->validate('private_key'); } if ($this->getTotalFee() && $this->getRmbFee()) { throw new InvalidRequestException("The 'total_fee' and 'rmb_fee' parameter can not be provide together"); } if (!$this->getTotalFee() && !$this->getRmbFee()) { throw new InvalidRequestException("The 'total_fee' and 'rmb_fee' must be provide one of them"); } $data = array('service' => 'create_forex_trade_wap', 'partner' => $this->getPartner(), '_input_charset' => $this->getInputCharset() ?: 'utf-8', 'sign_type' => $signType, 'notify_url' => $this->getNotifyUrl(), 'return_url' => $this->getReturnUrl(), 'out_trade_no' => $this->getOutTradeNo(), 'currency' => $this->getCurrency() ?: 'USD', 'subject' => $this->getSubject(), 'total_fee' => $this->getTotalFee(), 'rmb_fee' => $this->getRmbFee(), 'supplier' => $this->getSupplier(), 'timeout_rule' => $this->getTimeoutRule(), 'body' => $this->getBody()); $data = array_filter($data); $data['sign'] = Helper::sign($data, $signType, $this->getSignKey($signType)); return $data; }
/** * Send the request with specified data * * @param mixed $data The data to send * * @return ResponseInterface */ public function sendData($data) { $data = $this->getRequestParams(); $signType = strtoupper($this->getRequestParam('sign_type')); $sign = Helper::sign($data, $signType, $this->getSignKey($signType)); $notifyId = $this->getRequestParam('notify_id'); /** * is sign match? */ if (isset($data['sign']) && $data['sign'] && $sign === $data['sign']) { $signMatch = true; } else { $signMatch = false; } /** * Verify through Alipay server if exists notify_id */ if ($notifyId) { $verifyResponse = $this->getVerifyResponse($notifyId); $verifyOk = $this->isNotifyVerifiedOK($verifyResponse); } else { $verifyOk = true; } /** * is paid? */ if ($signMatch && $verifyOk && isset($data['trade_status']) && $data['trade_status'] == 'TRADE_FINISHED') { $paid = true; } else { $paid = false; } $responseData = array('sign_match' => $signMatch, 'notify_id_verify_ok' => $verifyOk, 'paid' => $paid); return $this->response = new CompletePurchaseResponse($this, $responseData); }