public function capture($data)
 {
     $extradata = isset($data['ExtraData']) ? $data['ExtraData'] : false;
     if ($extradata) {
         unset($data['ExtraData']);
     }
     $this->payment->AccountPaymentNumber = isset($extradata['AccountPaymentNumber']) ? $extradata['AccountPaymentNumber'] : null;
     parent::capture($data);
     // Do redirection
     $this->doRedirect();
 }
 /**
  * tests the Capture-function
  */
 public function testCapture()
 {
     $this->assertTrue($this->ProcessPayment(false));
     $preauthId = $this->_paymentProcessor->getPreauthId();
     $this->assertInternalType('string', $preauthId);
     $this->_paymentProcessor->capture();
     $transactionId = $this->_paymentProcessor->getTransactionId();
     $result = $this->_transactionObject->getOne($transactionId);
     $this->assertInternalType('array', $result);
     $this->assertEquals('20000', $result['response_code']);
     $this->assertEquals($transactionId, $result['id']);
 }
 public function capture($data)
 {
     parent::capture($data);
     // Set the return link
     $this->gateway->returnURL = Director::absoluteURL(Controller::join_links($this->link(), 'complete', $this->methodName, $this->payment->ID));
     // Authorise the payment and get token
     $result = $this->gateway->authorise($this->paymentData);
     if ($result && !$result->isSuccess()) {
         $this->payment->updateStatus($result);
         $this->doRedirect();
         return;
     }
     // Save the token for good measure
     $this->payment->Token = $this->gateway->tokenID;
     $this->payment->write();
     // Process payment
     $result = $this->gateway->process($this->paymentData);
     // Processing may not get to here if all goes smoothly, customer will be at the 3rd party gateway
     if ($result && !$result->isSuccess()) {
         $this->payment->updateStatus($result);
         $this->doRedirect();
         return;
     }
 }
Exemple #4
0
 /**
  * Process a gateway-hosted payment. Users will be redirected to
  * the external gateway to enter payment info. Redirect back to
  * our site when the payment is completed.
  *
  * @see PaymentProcessor::capture()
  * @param Array $data
  */
 public function capture($data)
 {
     parent::capture($data);
     // Set the return link
     $this->gateway->returnURL = Director::absoluteURL(Controller::join_links($this->link(), 'complete', $this->methodName, $this->payment->ID));
     // Set the cancel link
     $this->gateway->cancelURL = Director::absoluteURL(Controller::join_links($this->link(), 'cancel', $this->methodName, $this->payment->ID));
     // Send a request to the gateway
     $result = $this->gateway->process($this->paymentData);
     // Processing may not get to here if all goes smoothly, customer will be at the 3rd party gateway
     if ($result && !$result->isSuccess()) {
         // Gateway did not respond or responded with error
         // Need to save the gateway response and save HTTP Status, errors etc. to Payment
         $this->payment->updateStatus($result);
         // Payment has failed - redirect to confirmation page
         // Developers can get the failure data from the database to show
         // the proper errors to users
         $this->doRedirect();
     }
 }