public static function paymentStatusWithState($sessionState) { $data = new stdClass(); $data->targetGoId = 12345; $data->productName = 'Product Description'; $data->totalPrice = 1000; $data->currency = 'CZK'; $data->orderNumber = '1234'; $data->recurrentPayment = ''; $data->parentPaymentSessionId = ''; $data->preAuthorization = ''; $data->result = GopayHelper::CALL_COMPLETED; $data->sessionState = $sessionState; $data->sessionSubState = ''; $data->paymentChannel = ''; $data->paymentSessionId = 11112222; $data->encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentStatus($data, self::SECURE_KEY)), self::SECURE_KEY); return $data; }
/** * Založení opakovane platby * * @param float $parentPaymentSessionId - identifikator rodicovske platby * @param int $recurrentPaymentOrderNumber - identifikator objednavky * @param int $recurrentPaymentTotalPriceInCents - castka * @param string $recurrentPaymentCurrency - mena (CZK) * @param string $recurrentPaymentProductName - popis objednavky * @param float $targetGoId - identifikator prijemnce - GoId * @param string $secureKey - kryptovaci klic prideleny GoPay * @throws \Exception * @return */ public function performRecurrence($parentPaymentSessionId, $recurrentPaymentOrderNumber, $recurrentPaymentTotalPriceInCents, $recurrentPaymentCurrency, $recurrentPaymentProductName, $targetGoId, $secureKey) { try { //inicializace WS $go_client = self::createSoapClient(); $encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatRecurrenceRequest((double) $parentPaymentSessionId, (int) $recurrentPaymentOrderNumber, (int) $recurrentPaymentTotalPriceInCents, (double) $targetGoId, $secureKey)), $secureKey); $recurrenceRequest = array("parentPaymentSessionId" => (double) $parentPaymentSessionId, "orderNumber" => (int) $recurrentPaymentOrderNumber, "totalPrice" => (int) $recurrentPaymentTotalPriceInCents, "targetGoId" => (double) $targetGoId, "encryptedSignature" => $encryptedSignature); $status = $go_client->__call('createRecurrentPayment', array('recurrenceRequest' => $recurrenceRequest)); if ($status->result == GopayHelper::CALL_COMPLETED) { GopayHelper::checkPaymentStatus($status, GopayHelper::CREATED, (double) $targetGoId, (int) $recurrentPaymentOrderNumber, (int) $recurrentPaymentTotalPriceInCents, $recurrentPaymentCurrency, $recurrentPaymentProductName, $secureKey); return $status->paymentSessionId; } else { throw new Exception("Bad payment status"); } } catch (SoapFault $f) { /* * Chyba v komunikaci s GoPay serverem */ throw new Exception("SOAP error"); } }