public static function fromArray($data) { $refund = new RefundInformation(); foreach ($data as $key => $value) { if (property_exists(get_class($refund), $key)) { if ($key == "errors") { $refund->{$key} = Errors::fromArray($value); } if ($key == "lastRecurringBillResponse") { $refund->{$key} = RefundResponse::fromArray($value); } else { $refund->{$key} = $value; } } } return $refund; }
/** * Service Call: Refund * @param RefundRequest $refundRequest * @return RefundResponse * @throws APIException */ public function Refund($refundRequest, $apiUsername = null) { $ret = new RefundResponse(); $resp = $this->call("Refund", $refundRequest, $apiUsername); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * Service Call: Refund * @param RefundRequest $refundRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return RefundResponse * @throws APIException */ public function Refund($refundRequest, $apiCredential = NULL) { $apiContext = new PPApiContext($this->config); $handlers = array(new PPPlatformServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $ret = new RefundResponse(); $resp = $this->call('AdaptivePayments', 'Refund', $refundRequest, $apiContext, $handlers); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * Service Call: Refund * @param RefundRequest $refundRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return RefundResponse * @throws APIException */ public function Refund($refundRequest, $apiCredential = NULL) { $ret = new RefundResponse(); $resp = $this->call('AdaptivePayments', 'Refund', $refundRequest, $apiCredential); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * @param $id_order * @param $transaction_details */ public function postProcessRefund($id_order, $transaction_details) { include_once _PS_MODULE_DIR_ . 'alipay/api/loader.php'; $service = Configuration::get('ALIPAY_SERVICE_REFUND'); $credentials = AlipayTools::getCredentials($service, false); $gmt_date = date('Ymdhis'); $params = array(); $params['amount'] = Tools::getValue('refund_amount'); $params['refund_reason'] = Tools::getValue('refund_reason'); $params['out_trade_no'] = $transaction_details['out_trade_no']; $params['refund_no'] = md5(date('Ymdhis')); $params['id_order'] = $id_order; $params['currency'] = $transaction_details['currency']; $alipayapi = new AlipayApi($credentials); $alipayapi->setCharset('UTF-8'); $refund_request = new RefundRequest(); $refund_request->setOutReturnNo($params['refund_no']); $refund_request->setOutTradeNo($params['out_trade_no']); $refund_request->setReturnAmount($params['amount']); $refund_request->setCurrency($params['currency']); $refund_request->setGmtReturn($gmt_date); $refund_request->setReason($params['refund_reason']); $alipayapi->prepareRequest($refund_request); $url = $alipayapi->createUrl(); $xml = $alipayapi->getResponse($url); $refund_response = new RefundResponse(); if ($refund_response->processResponse($xml, $params) < 0) { $this->context->controller->errors = array_merge($this->context->controller->errors, $refund_response->getErrors()); } }