Capture an authorized AfterPay payment

@since 1.0.0

@param string $paymentID
@param int $amount
@param string $currency
@return object
546875
public function captureFull($paymentID, $amount = 0, $currency = '')
    {
        $obj = new stdClass();
        
        $obj->MerchantID = $this->getMerchantID();
        $obj->Timestamp = $this->getTimestamp();
        $obj->amount = $amount;
        $obj->currency = $currency;
        $obj->PaymentID = $paymentID;
        
        // Generate checksum for the request
        $obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
        
        // Make the request
        $request = $this->client->CaptureFull($obj);
        
        // Fetch the result
        $result = $request->CaptureFullResult;
        
        // Store result checksum
        $resultChecksum = $result->Checksum;
        
        // Remove result checksum from object
        unset($result->Checksum);
        
        // Create result checksum
        $checkSum = $this->generateChecksum($result, $this->getSecretCode());
        
        // Compare generated checksum and result checksum
        if ($resultChecksum !== $checkSum)
            throw new Exception('Data could not be verified');
        
        // Return result
        return $result;
    }
1171784
private function createMoney($amount, $currency) { $precision = isset($this->config[$currency]) ? $this->config[$currency]['precision'] : 2;
        return new Money($amount, new Currency($currency, $precision));
    }
152714
public function execute($paymentId)
    {
        $url = $this->environment->getApiQueryURL() . '1/sales/' . $paymentId;

        return $this->sendRequest('GET', $url);
    }
663617
public function authorize(Varien_Object $payment, $amount)
    {
        parent::authorize($payment, $amount);
        $payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);

        /** @var Mage_Sales_Model_Order $order */
        $order = $payment->getOrder();
        $amount = $order->getGrandTotal();

        // check if a zero auth should be done for this order
        $useZeroAuth = (bool)Mage::helper('adyen')->getConfigData('use_zero_auth', null, $order->getStoreId());
        $zeroAuthDateField = Mage::helper('adyen')->getConfigData(
            'base_zero_auth_on_date', null,
            $order->getStoreId()
        );

        if ($useZeroAuth) { // zero auth should be used
            // only orders that are scheduled to be captured later than
            // the auth valid period use zero auth
            // the period is 7 days since this works for most payment methods
            $scheduledDate = strtotime($order->getData($zeroAuthDateField));
            if ($scheduledDate > strtotime("+7 days")) { // scheduled date is higher than now + 7 days
                $amount = 0; // set amount to 0 for zero auth
            }
        }

        /*
         * ReserveOrderId for this quote so payment failed notification
         * does not interfere with new successful orders
         */
        $incrementId = $order->getIncrementId();
        $quoteId = $order->getQuoteId();
        $quote = Mage::getModel('sales/quote')
            ->load($quoteId)
            ->setReservedOrderId($incrementId)
            ->save();

        // by zero authentication payment is authorised when api responds is succesfull
        if ($order->getGrandTotal() == 0) {
            $payment->setIsTransactionPending(false);
        }

        /*
         * Do not send a email notification when order is created.
         * Only do this on the AUHTORISATION notification.
         * For Boleto and Multibanco send it on order creation
         */
        if (!in_array($this->getCode(), array('adyen_boleto', 'adyen_multibanco'))) {
            $order->setCanSendNewEmailFlag(false);
        }

        if ($this->getCode() == 'adyen_boleto' || $this->getCode() == 'adyen_cc' || substr(
            $this->getCode(), 0,
            14
        ) == 'adyen_oneclick' || $this->getCode() == 'adyen_sepa' || $this->getCode() == 'adyen_apple_pay' || $this->getCode() == 'adyen_multibanco') {
            if (substr($this->getCode(), 0, 14) == 'adyen_oneclick') {
                // set payment method to adyen_oneclick otherwise backend can not view the order
                $payment->setMethod("adyen_oneclick");

                $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");

                // load agreement based on reference_id (option to add an index on reference_id in database)
                $agreement = Mage::getModel('sales/billing_agreement')->load($recurringDetailReference, 'reference_id');

                // agreement could be a empty object
                if ($agreement && $agreement->getAgreementId() > 0 && $agreement->isValid()) {
                    $agreement->addOrderRelation($order);
                    $agreement->setIsObjectChanged(true);
                    $order->addRelatedObject($agreement);
                    $message = Mage::helper('adyen')->__(
                        'Used existing billing agreement #%s.',
                        $agreement->getReferenceId()
                    );

                    $comment = $order->addStatusHistoryComment($message);
                    $order->addRelatedObject($comment);
                }
            }

            $_authorizeResponse = $this->_processRequest($payment, $amount, "authorise");
        }

        return $this;
    }
1199447
public function execute($paymentId)
    {
        $url    = $this->environment->getApiUrl() . '1/sales/' . $paymentId . '/' . $this->type;
        $params = [];

        if ($this->amount != null) {
            $params['amount'] = $this->amount;
        }

        if ($this->serviceTaxAmount != null) {
            $params['serviceTaxAmount'] = $this->serviceTaxAmount;
        }

        $url .= '?' . http_build_query($params);

        return $this->sendRequest('PUT', $url);
    }
613754
public function capture($money, $authorization, $options = array())
  {
      $this->post = array('trans_id' => $authorization);
      $this->add_customer_data($options);

      return $this->commit('PRIOR_AUTH_CAPTURE', $money);
  }
735961
public function processPayment(StripeMethod $paymentMethod, $amount)
    {
        /**
         * check and set payment data.
         */
        $chargeParams = $this->prepareData(
            $paymentMethod,
            $amount
        );

        /**
         * make payment.
         */
        $transaction = $this
            ->transactionFactory
            ->create($chargeParams);

        /**
         * Payment paid done.
         *
         * Paid process has ended ( No matters result )
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderDone(
                $this->paymentBridge,
                $paymentMethod
            );

        /**
         * when a transaction is successful, it is marked as 'closed'.
         */
        if ($transaction['paid'] != 1) {

            /**
             * Payment paid failed.
             *
             * Paid process has ended failed
             */
            $this
                ->paymentEventDispatcher
                ->notifyPaymentOrderFail(
                    $this->paymentBridge,
                    $paymentMethod
                );

            throw new PaymentException();
        }

        $paymentMethod
            ->setTransactionId($transaction['id'])
            ->setTransactionStatus('paid')
            ->setTransactionResponse($transaction);

        /**
         * Payment paid successfully.
         *
         * Paid process has ended successfully
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderSuccess(
                $this->paymentBridge,
                $paymentMethod
            );

        return $this;
    }
977362
function DoReauthorization($txnID, $amount = 0, $currency = 'USD') {
    $values['AUTHORIZATIONID'] = $txnID;
    $values['AMT'] = number_format($amount, 2, '.', ',');
    $values['CURRENCYCODE'] = $currency;
    return $this->_request($values, 'DoReauthorization');
  }
76039
public function DMSTransaction($txn_id, $amount, $currency = 981, $description = '', $language = 'GE')
    {
        return $this->transaction('t', $amount, $currency, $description, $language, 'DMS', [
            'trans_id' => $txn_id,
        ]);
    }
134578
public function getPayment($userId, $monetaryAccountId, $id)
    {
        $paymentResponse = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId) . '/' . (int)$id);

        $payment = $paymentResponse['Response'][0]['Payment'];

        $payment['amount']['value'] = $this->floatToCents($payment['amount']['value']);

        return $payment;
    }
205363
public function capture($transactionId, $amount)
    {
        HpsInputValidation::checkAmount($amount);

        $xml = new DOMDocument();
        $transaction = $xml->createElement('hps:Transaction');
        $capture = $xml->createElement('hps:AltPaymentCapture');

        $capture->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType));
        $capture->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
        $capture->appendChild($xml->createElement('hps:Amt', $amount));

        $payment = $xml->createElement('hps:Payment');
        $nvp = $xml->createElement('hps:NameValuePair');
        $nvp->appendChild($xml->createElement('hps:Name', 'FullyCapturedFlag'));
        $nvp->appendChild($xml->createElement('hps:Value', 'true'));
        $payment->appendChild($nvp);

        $capture->appendChild($payment);
        $transaction->appendChild($capture);
        return $this->_submitTransaction($transaction, 'AltPaymentCapture');
    }
1212665
public static function setPayStatus($orderId, $paymentId, $status, $params)
    {
        if (($model = static::findOne(['id' => $orderId])) != null && $status == true) {
            $coin = static::getCoin($model->money, $model->currency);
            coin($model->user_id, 'purchase', $coin);
            return true;
        }
        return false;
    }
439053
def capture_funds
      
      resp = StdClass.new      
      it = InvoiceTransaction.where(:invoice_id => self.id, :success => true).first
            
      if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED
        resp.error = "Funds for this invoice have already been captured."    
      elsif self.total > it.amount
        resp.error = "The invoice total exceeds the authorized amount."
      elsif it.nil?
        resp.error = "This invoice doesn't seem to be authorized."
      else
                        
        sc = self.site.store_config                
        case sc.pp_name
          
          #when 'authorize.net'
          #  transaction = AuthorizeNet::AIM::Transaction.new(sc.authnet_api_login_id, sc.authnet_api_transaction_key)
          #  response = transaction.prior_auth_capture(t.transaction_id, self.total)
          #  
          #  ot = Caboose::InvoiceTransaction.create(
          #    :invoice_id        => self.id,
          #    :date_processed    => DateTime.now.utc,
          #    :transaction_type  => InvoiceTransaction::TYPE_CAPTURE,
          #    :payment_processor => sc.pp_name,
          #    :amount            => self.total,        
          #    :success           => response.response_code && response.response_code == '1',            
          #    :transaction_id    => response.transaction_id,
          #    :auth_code         => response.authorization_code,
          #    :response_code     => response.response_code
          #  )
          #  if ot.success
          #    self.date_captured = DateTime.now.utc
          #    self.save              
          #  end                                    
          #  self.update_attribute(:financial_status, Invoice::FINANCIAL_STATUS_CAPTURED)
          #  resp.success = 'Captured funds successfully'
                                    
          when StoreConfig::PAYMENT_PROCESSOR_STRIPE
                                          
            it = Caboose::InvoiceTransaction.where(:invoice_id => self.id, :success => true).first
            if it.nil?
              resp.error = "Error capturing funds for invoice #{self.id}. No previous successful authorization for this invoice exists."
              return false
            else                        
              Stripe.api_key = sc.stripe_secret_key.strip
              bt = nil
              begin
                c = Stripe::Charge.retrieve(it.transaction_id)
                c = c.capture
                bt = Stripe::BalanceTransaction.retrieve(c.balance_transaction)
              rescue Exception => ex
                resp.error = "Error during capture process\n#{ex.message}"                
              end
              
              if resp.error.nil?
                InvoiceTransaction.create(
                  :invoice_id => self.id,
                  :transaction_id => bt.id,
                  :transaction_type => InvoiceTransaction::TYPE_CAPTURE,
                  :payment_processor => sc.pp_name,
                  :amount => bt.amount / 100,                
                  :date_processed => DateTime.strptime(bt.created.to_s, '%s'),
                  :success => bt.status == 'succeeded' || bt.status == 'pending'
                )
                if bt.status == 'succeeded' || bt.status == 'pending'
                  self.financial_status = Invoice::FINANCIAL_STATUS_CAPTURED
                  self.save
                  resp.success = true
                else
                  resp.error = "Error capturing funds."
                end
              end
            end
          
        end        
      end      
      return resp
    end
34776
public function create($payment, $paymentId = null)
    {
        if (isset($paymentId)) {
            return $this->client()->put($payment, 'payments/{paymentId}', ['paymentId' => $paymentId]);
        }

        return $this->client()->post($payment, 'payments');
    }
175080
public function capture($paymentId, CaptureRequest $captureRequest){        
        $uri = Braspag::$apiBase . "sales/{$paymentId}/capture"; 
        
        if($captureRequest != null){
            $uri = $uri . "?amount={$captureRequest->amount}&serviceTaxAmount={$captureRequest->serviceTaxAmount}";
        }
        
        $response = Request::put($uri)
            ->sendsJson()
            ->addHeaders($this->headers)
            ->send();
        
        if($response->code == HttpStatus::Ok){    
            
            $captureResponse = new CaptureResponse();
            $captureResponse->status = $response->body->Status;
            $captureResponse->reasonCode = $response->body->ReasonCode;
            $captureResponse->reasonMessage = $response->body->ReasonMessage;
            
            $captureResponse->links = $this->parseLinks($response->body->Links);
            
            return $captureResponse;
            
        }elseif($response->code == HttpStatus::BadRequest){            
            Utils::handleApiError($response);            
        }   
        
        return $response->code;
    }
911162
def capture(self, payment_id, amount, data={}, **kwargs):
        "
        url = "{}/{}/capture".format(self.base_url, payment_id)
        data['amount'] = amount
        return self.post_url(url, data, **kwargs)
377891
public function captureTransaction($location_id, $transaction_id)
    {
        list($response, $statusCode, $httpHeader) = $this->captureTransactionWithHttpInfo ($location_id, $transaction_id);
        return $response; 
    }