/** * execute payment * * @param OnlineShop_Framework_IPrice $price * @param string $reference * * @return OnlineShop_Framework_Payment_IStatus * @throws Exception */ public function executeDebit(OnlineShop_Framework_IPrice $price = null, $reference = null) { // TODO: Implement executeDebit() method. # https://integration.wirecard.at/doku.php/wcp:toolkit_light:start # https://integration.wirecard.at/doku.php/wcs:backend_operations?s[]=deposit # https://integration.wirecard.at/doku.php/backend:deposit if ($price) { // recurPayment $request = ['customerId' => $this->customer, 'toolkitPassword' => $this->toolkitPassword, 'command' => 'recurPayment', 'language' => $this->authorizedData['language'], 'requestFingerprint' => '', 'orderDescription' => $reference, 'sourceOrderNumber' => $this->authorizedData['orderNumber'], 'amount' => $price->getAmount(), 'currency' => $price->getCurrency()->getShortName()]; // add fingerprint $request['requestFingerprint'] = $this->computeFingerprint($request['customerId'], $request['toolkitPassword'], $this->secret, $request['command'], $request['language'], $request['sourceOrderNumber'], $request['orderDescription'], $request['amount'], $request['currency']); } else { // default clearing auth $price = new OnlineShop_Framework_Impl_Price($this->authorizedData['amount'], new Zend_Currency($this->authorizedData['currency'], $this->currencyLocale)); $request = ['customerId' => $this->customer, 'toolkitPassword' => $this->toolkitPassword, 'command' => 'deposit', 'language' => $this->authorizedData['language'], 'requestFingerprint' => '', 'orderNumber' => $this->authorizedData['orderNumber'], 'amount' => $price->getAmount(), 'currency' => $price->getCurrency()->getShortName()]; // add fingerprint $request['requestFingerprint'] = $this->computeFingerprint($request['customerId'], $request['toolkitPassword'], $this->secret, $request['command'], $request['language'], $request['orderNumber'], $request['amount'], $request['currency']); } // execute request $response = $this->serverToServerRequest('https://checkout.wirecard.com/page/toolkit.php', $request); // check response if ($response['status'] === '0') { // Operation successfully done. return new OnlineShop_Framework_Impl_Payment_Status($reference, $response['paymentNumber'] ?: $response['orderNumber'], '', OnlineShop_Framework_Payment_IStatus::STATUS_CLEARED, ['qpay_amount' => (string) $price, 'qpay_command' => $request['command'], 'qpay_response' => print_r($response, true)]); } else { if ($response['errors']) { // https://integration.wirecard.at/doku.php/backend:response_parameters $error = []; for ($e = 1; $e <= $response['errors']; $e++) { $error[] = $response['error_' . $e . '_error_message']; } return new OnlineShop_Framework_Impl_Payment_Status($reference, $response['paymentNumber'] ?: $response['orderNumber'], implode("\n", $error), OnlineShop_Framework_Payment_IStatus::STATUS_CANCELLED, ['qpay_amount' => (string) $price, 'qpay_command' => $request['command'], 'qpay_response' => print_r($response, true)]); } else { throw new Exception(print_r($response, true)); } } }
public function __construct($amount, Zend_Currency $currency, $minPrice = false, $description = null) { parent::__construct($amount, $currency, $minPrice); $this->description = $description; }
/** * gutschrift ausführen * @param OnlineShop_Framework_IPrice $price * @param string $reference * @param string $transactionId * * @return OnlineShop_Framework_Payment_IStatus */ public function executeCredit(OnlineShop_Framework_IPrice $price, $reference, $transactionId) { if ($this->authorizedData['reqtype'] == 'NOA' && $this->authorizedData['uppTransactionId']) { // restore price object for payment status $price = new OnlineShop_Framework_Impl_Price($this->authorizedData['amount'] / 100, new Zend_Currency($this->authorizedData['currency'], $this->currencyLocale)); // complete authorized payment $xml = $this->xmlSettlement(self::TRANS_TYPE_CREDIT, $this->authorizedData['amount'], $this->authorizedData['currency'], $this->authorizedData['refno'], $this->authorizedData['uppTransactionId']); } else { // complete authorized payment $xml = $this->xmlSettlement(self::TRANS_TYPE_CREDIT, $price->getAmount() * 100, $price->getCurrency()->getShortName(), $reference, $transactionId); } // handle response $transaction = $xml->body->transaction; $status = (string) $transaction->attributes()['trxStatus']; $response = $transaction->{$status}; $message = null; $paymentState = null; if ($status == 'response' && in_array($response->responseCode, ['01', '02'])) { $paymentState = OnlineShop_Framework_AbstractOrder::ORDER_STATE_COMMITTED; $message = (string) $response->responseMessage; } else { $paymentState = OnlineShop_Framework_AbstractOrder::ORDER_STATE_ABORTED; $message = (string) $response->errorMessage . ' | ' . (string) $response->errorDetail; } // create and return status $status = new OnlineShop_Framework_Impl_Payment_Status((string) $transaction->attributes()['refno'], (string) $response->uppTransactionId, $message, $paymentState, ['datatrans_amount' => (string) $price, 'datatrans_responseXML' => $transaction->asXML(), 'datatrans_acqAuthorizationCode' => (string) $response->acqAuthorizationCode]); return $status; }