Verify payment

@throws ParsianErrorException
328495
protected function verifyPayment()
	{
		$processor = new RSAProcessor($this->config->get('gateway.pasargad.certificate-path'),RSAKeyType::XMLFile);
		$fields = array('invoiceUID' => Input::get('tref'));
		$result = Parser::post2https($fields,$this->checkTransactionUrl);
		$check_array = Parser::makeXMLTree($result);

		if ($check_array['resultObj']['result'] != "True") {
		    $this->newLog(-1, Enum::TRANSACTION_FAILED_TEXT);
		    $this->transactionFailed();
		    throw new PasargadErrorException(Enum::TRANSACTION_FAILED_TEXT, -1);
		}
		
		$fields = array(
			'MerchantCode' => $this->config->get('gateway.pasargad.merchantId'),
			'TerminalCode' => $this->config->get('gateway.pasargad.terminalId'),
			'InvoiceNumber' => $check_array['resultObj']['invoiceNumber'],
			'InvoiceDate' => Input::get('iD'),
			'amount' => $check_array['resultObj']['amount'],
			'TimeStamp' => date("Y/m/d H:i:s"),
			'sign' => '',
		);

		$data = "#" . $fields['MerchantCode'] . "#" . $fields['TerminalCode'] . "#" . $fields['InvoiceNumber'] ."#" . $fields['InvoiceDate'] . "#" . $fields['amount'] . "#" . $fields['TimeStamp'] ."#";
		$data = sha1($data, true);
		$data = $processor->sign($data);
		$fields['sign'] = base64_encode($data);
		$result = Parser::post2https($fields,$this->verifyUrl);
		$array = Parser::makeXMLTree($result);
		if ($array['actionResult']['result'] != "True") {
			$this->newLog(-1, Enum::TRANSACTION_FAILED_TEXT);
			$this->transactionFailed();
			throw new PasargadErrorException(Enum::TRANSACTION_FAILED_TEXT, -1);
		}
		$this->refId = $check_array['resultObj']['referenceNumber'];
		$this->transactionSetRefId();
		$this->trackingCode = Input::get('tref');
		$this->transactionSucceed();
		$this->newLog(0, Enum::TRANSACTION_SUCCEED_TEXT);
	}
1069614
public function verify($cardOrToken, $cardHolder = null, $requestMultiUseToken = false, $clientTransactionId = null)
    {
        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsCreditAccountVerify = $xml->createElement('hps:CreditAccountVerify');
        $hpsBlock1 = $xml->createElement('hps:Block1');

        if ($cardHolder != null) {
            $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml));
        }

        $cardData = $xml->createElement('hps:CardData');
        if ($cardOrToken instanceof HpsCreditCard) {
            $cardData->appendChild($this->_hydrateManualEntry($cardOrToken, $xml));
        } else {
            $cardData->appendChild($this->_hydrateTokenData($cardOrToken, $xml));
        }
        $cardData->appendChild($xml->createElement('hps:TokenRequest', ($requestMultiUseToken) ? 'Y' : 'N'));

        $hpsBlock1->appendChild($cardData);
        $hpsCreditAccountVerify->appendChild($hpsBlock1);
        $hpsTransaction->appendChild($hpsCreditAccountVerify);

        return $this->_submitTransaction($hpsTransaction, 'CreditAccountVerify', $clientTransactionId);
    }
832709
public static boolean verifyNotify(Map<String, String> params, String paternerKey) {
		String sign = params.get("sign");
		String localSign = PaymentKit.createSign(params, paternerKey);
		return sign.equals(localSign);
	}
153393
protected function userPayment()
    {
        $refId = Input::get('au');

        if ($this->refId() != $refId) {
            $this->transactionFailed();
            $this->newLog(-30, JahanPayException::$errors[-30]);
            throw new JahanPayException(-30);
        }

        return true;
    }
155065
public void verify() throws CredentialException {
        try {
            String caCertsLocation = "file:" + CoGProperties.getDefault().getCaCertLocations();

            KeyStore keyStore = Stores.getTrustStore(caCertsLocation + "/" + Stores.getDefaultCAFilesPattern());
            CertStore crlStore = Stores.getCRLStore(caCertsLocation + "/" + Stores.getDefaultCRLFilesPattern());
            ResourceSigningPolicyStore sigPolStore = Stores.getSigningPolicyStore(caCertsLocation + "/" + Stores.getDefaultSigningPolicyFilesPattern());

            X509ProxyCertPathParameters parameters = new X509ProxyCertPathParameters(keyStore, crlStore, sigPolStore, false);
            X509ProxyCertPathValidator validator = new X509ProxyCertPathValidator();
            validator.engineValidate(CertificateUtil.getCertPath(certChain), parameters);
        } catch (Exception e) {
            throw new CredentialException(e);
        }
    }
925220
@RequestMapping(value = "/create-payment", method = RequestMethod.POST)
    public @ResponseBody Map<String, String> createPayment(@RequestParam("performCheckout") Boolean performCheckout) throws PaymentException {
        Map<String, String> response = new HashMap<>();
        Payment createdPayment = paymentService.createPayPalPaymentForCurrentOrder(performCheckout);
        response.put("id", createdPayment.getId());
        return response;
    }
1285028
public static function checkRequirements()
    {
        $extensions = array('curl', 'json');

        foreach ($extensions as $extension) {
            if (!extension_loaded($extension)) {
                throw new Exception\RuntimeException(
                    'You need the PHP ' . $extension
                    . ' extension in order to use EveryPay PHP Library'
                );
            }
        }
    }
1095058
protected function _isPaymentResponseSessionInvalid()
    {
        /** @var OxpsPaymorrowModule $oModule */
        $oModule = oxRegistry::get('OxpsPaymorrowModule');

        // Get Paymorrow response from session
        $aPaymorrowResponse = $oModule->getPaymorrowResponseData();

        // The response must exist and be valid
        return (
            !isset($aPaymorrowResponse['order_status'], $aPaymorrowResponse['response_status']) or
            !in_array($aPaymorrowResponse['order_status'], array('VALIDATED', 'ACCEPTED')) or
            ($aPaymorrowResponse['response_status'] !== 'OK')
        );
    }
836228
public function verifyPayment($paymentToken) {
        $transfer = $this->transferFactory->create([]);

        try {
            $response = $this->getHttpClient('charges/' . $paymentToken, $transfer)->request();
            $result   = (array) json_decode($response->getBody(), true);

            if( array_key_exists('errorCode', $result) ) {
                throw new ApiClientException($result['message'], $result['errorCode'], $result['eventId']);
            }

            $this->putGatewayResponseToHolder($result);

            return $result;
        }
        catch (Zend_Http_Client_Exception $e) {
            throw new ClientException(__($e->getMessage()));
        }
    }
67708
protected function validatePaymentOrder()
    {
        $field = 'payment';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Payment');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        $method = $this->payment->get($value);

        if (empty($method['status'])) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }
1162694
function validatePayment(conn, payload, message_index, objUnit, objValidationState, callback){

	if (!("asset" in payload)){ // base currency
		if (hasFieldsExcept(payload, ["inputs", "outputs"]))
			return callback("unknown fields in payment message");
		if (objValidationState.bHasBasePayment)
			return callback("can have only one base payment");
		objValidationState.bHasBasePayment = true;
		return validatePaymentInputsAndOutputs(conn, payload, null, message_index, objUnit, objValidationState, callback);
	}
	
	// asset
	if (!isStringOfLength(payload.asset, constants.HASH_LENGTH))
		return callback("invalid asset");
	
	var arrAuthorAddresses = objUnit.authors.map(function(author) { return author.address; } );
	// note that light clients cannot check attestations
	storage.loadAssetWithListOfAttestedAuthors(conn, payload.asset, objValidationState.last_ball_mci, arrAuthorAddresses, function(err, objAsset){
		if (err)
			return callback(err);
		if (hasFieldsExcept(payload, ["inputs", "outputs", "asset", "denomination"]))
			return callback("unknown fields in payment message");
		if (!isNonemptyArray(payload.inputs))
			return callback("no inputs");
		if (!isNonemptyArray(payload.outputs))
			return callback("no outputs");
		if (objAsset.fixed_denominations){
			if (!isPositiveInteger(payload.denomination))
				return callback("no denomination");
		}
		else{
			if ("denomination" in payload)
				return callback("denomination in arbitrary-amounts asset")
		}
		if (!!objAsset.is_private !== !!objValidationState.bPrivate)
			return callback("asset privacy mismatch");
		var bIssue = (payload.inputs[0].type === "issue");
		var issuer_address;
		if (bIssue){
			if (arrAuthorAddresses.length === 1)
				issuer_address = arrAuthorAddresses[0];
			else{
				issuer_address = payload.inputs[0].address;
				if (arrAuthorAddresses.indexOf(issuer_address) === -1)
					return callback("issuer not among authors");
			}
			if (objAsset.issued_by_definer_only && issuer_address !== objAsset.definer_address)
				return callback("only definer can issue this asset");
		}
		if (objAsset.cosigned_by_definer && arrAuthorAddresses.indexOf(objAsset.definer_address) === -1)
			return callback("must be cosigned by definer");
		
		if (objAsset.spender_attested){
			if (conf.bLight && objAsset.is_private) // if the asset is public, we trust witnesses to have checked attestations
				return callback("being light, I can't check attestations for private assets");
			if (objAsset.arrAttestedAddresses.length === 0)
				return callback("none of the authors is attested");
			if (bIssue && objAsset.arrAttestedAddresses.indexOf(issuer_address) === -1)
				return callback("issuer is not attested");
		}
		validatePaymentInputsAndOutputs(conn, payload, objAsset, message_index, objUnit, objValidationState, callback);
	});
}
1099645
def verify(self):
        
        self.response = self._postback().decode('ascii')
        self.clear_flag()
        self._verify_postback()
        if not self.flag:
            if self.is_transaction():
                if self.payment_status not in self.PAYMENT_STATUS_CHOICES:
                    self.set_flag("Invalid payment_status. (%s)" % self.payment_status)
                if duplicate_txn_id(self):
                    self.set_flag("Duplicate txn_id. (%s)" % self.txn_id)

        self.save()
1360144
protected function verifyPayment()
    {
        $fields = array(
            "merchantID" => $this->config->get('gateway.saman.merchant'),
            "RefNum" => $this->refId,
            "password" => $this->config->get('gateway.saman.password'),
        );


        try {
            $soap = new SoapClient($this->serverUrl);
            $response = $soap->VerifyTransaction($fields["RefNum"], $fields["merchantID"]);

        } catch (\SoapFault $e) {
            $this->transactionFailed();
            $this->newLog('SoapFault', $e->getMessage());
            throw $e;
        }

        $response = intval($response);

        if ($response == $this->amount) {
            $this->transactionSucceed();
            return true;
        }

        //Reverse Transaction
        if($response>0){
            try {
                $soap = new SoapClient($this->serverUrl);
                $response = $soap->ReverseTransaction($fields["RefNum"], $fields["merchantID"], $fields["password"], $response);

            } catch (\SoapFault $e) {
                $this->transactionFailed();
                $this->newLog('SoapFault', $e->getMessage());
                throw $e;
            }
        }

        //
        $this->transactionFailed();
        $this->newLog($response, SamanException::$errors[$response]);
        throw new SamanException($response);
        


    }
141255
private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse
    {
        if ($exception instanceof CardError) {
            $body = $exception->getJsonBody();
            $data = $body;
            $data['code'] = $body['error']['code'];
            $data['message'] = $body['error']['message'];
            $data['id'] = $body['error']['charge'];
        } else if ($exception instanceof Base) {
            // So it's not a card being declined but something else. ¯\_(ツ)_/¯
            $body = $exception->getJsonBody();
            $data = $body;
            $data['id'] = null;
            $data['message'] = $body['error']['message'] ?? $exception->getMessage();
            $data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode();
        } else {
            throw $exception;
        }

        return new PaymentResponse($data);
    }
252322
public function validatePayment(AnCommandContext $context)
    {
        $data = $context->data;
        $package = $this->getItem();

        if ($data->token) {

            $country = null;
            $identifier = 'com:subscriptions.controller.subscription';
            $method = $this->getService($identifier)->getGateway()->getExpressPaymentMethod($data->token, $country);
            $this->order->setPaymentMethod($method);
            $this->order->country = $country;

        } else {

            $url = route('option=com_subscriptions&view=signup&layout=payment&id='.$package->id);
            $error = false;

            //validate creditcard
            if (!$this->creditcard->is_valid()) {
                $error = true;
                $this->storeValue('credit_card_error', AnTranslator::_('COM-SUBSCRIPTIONS-CREDITCARD-INVALID'));
            }

            //validate contact
            $contact = $this->contact;

            if (! (
                  $contact->address &&
                  $contact->city &&
                  $contact->country &&
                  $contact->state &&
                  $contact->zip
            )) {
                $this->storeValue('address_error', AnTranslator::_('COM-SUBSCRIPTIONS-BILLING-INVALID'));
            }

            if ($error) {
                $context->response->setRedirect($url);
                return false;
            }

            $this->order->country = $contact->country;

            return true;
        }
    }
79706
public Charge confirmCapture(final ConfirmCaptureParams params) throws OpenpayServiceException,
            ServiceUnavailableException {
        String path = String.format(CAPTURE_FOR_MERCHANT_PATH, this.getMerchantId(), params.getChargeId());
        return this.getJsonClient().post(path, params.asMap(), Charge.class);
    }
873182
protected function verifyPayment()
	{
		try {
			$soap = new SoapClient($this->serverUrl);

			$result = $soap->CheckRequestStatusResult(
				$this->transactionId(),
				$this->config->get('gateway.sadad.merchant'),
				$this->config->get('gateway.sadad.terminalId'),
				$this->config->get('gateway.sadad.transactionKey'),
				$this->refId(),
				$this->amount
			);

		} catch (\SoapFault $e) {
			$this->transactionFailed();
			$this->newLog('SoapFault', $e->getMessage());
			throw $e;
		}

		if (empty($result) || !isset($result->AppStatusCode))
			throw new SadadException('در دریافت اطلاعات از بانک خطایی رخ داده است.');

		$statusResult = strval($result->AppStatusCode);
		$appStatus = strtolower($result->AppStatusDescription);

		$message = $this->getMessage($statusResult, $appStatus);

		$this->newLog($statusResult, $message['fa']);

		if ($statusResult != 0 || $appStatus !== 'commit') {
			$this->transactionFailed();
			throw new SadadException($message['fa'], $statusResult);
		}
		$this->trackingCode = $result->TraceNo;
		$this->cardNumber = $result->CustomerCardNumber;
		$this->transactionSucceed();
	}