/**
  * Create a new payment for an order
  */
 public function createPayment($gateway)
 {
     if (!GatewayInfo::is_supported($gateway)) {
         $this->error(_t("PaymentProcessor.INVALID_GATEWAY", "`{gateway}` isn't a valid payment gateway.", 'gateway is the name of the payment gateway', array('gateway' => $gateway)));
         return false;
     }
     if (!$this->order->canPay(Member::currentUser())) {
         $this->error(_t("PaymentProcessor.CANTPAY", "Order can't be paid for."));
         return false;
     }
     $payment = Payment::create()->init($gateway, $this->order->TotalOutstanding(), ShopConfig::get_base_currency());
     $this->order->Payments()->add($payment);
     return $payment;
 }
Example #2
0
 public function select($data, $form)
 {
     if (!GatewayInfo::is_supported($data['Gateway'])) {
         $form->addErrorMessage("Gateway", _t("PaymentController.METHODNOTSUPPORTED", "Method is not supported"), "bad");
         return $this->redirectBack();
     }
     //create payment using gateway
     $payment = $this->createPayment($data['Gateway']);
     //redirect to offsite gateway, if there are no fields to fill out
     return $this->redirectBack();
 }