Esempio n. 1
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $vars = array('vpc_Version' => '1', 'vpc_Command' => 'pay', 'vpc_MerchTxnRef' => $invoice->public_id, 'vpc_AccessCode' => $this->getConfig('access_code'), 'vpc_Merchant' => $this->getConfig('merchant_id'), 'vpc_OrderInfo' => $invoice->public_id, 'vpc_Amount' => intval($invoice->first_total * 100), 'vpc_Locale' => 'en', 'vpc_ReturnURL' => $this->getPluginUrl('thanks'));
     $vars = array_filter($vars);
     ksort($vars);
     $vars['vpc_SecureHash'] = strtoupper(md5($h = $this->getConfig('secure_hash') . implode('', array_values($vars))));
     foreach ($vars as $k => $v) {
         $a->__set($k, $v);
     }
     $result->setAction($a);
 }
Esempio n. 2
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $action = new Am_Paysystem_Action_Redirect($this->getURL($invoice));
     $action->name = $invoice->getName();
     $action->email = $invoice->getEmail();
     $action->country = $invoice->getCountry();
     $action->postal_zip = $invoice->getZip();
     $action->__set('sku[]', $invoice->getItem(0)->getBillingPlanData('safecart_sku'));
     $action->payment_id = $invoice->public_id;
     $action->rbvar = 6;
     // I don't know what is it. Ported from v3 plugin
     $result->setAction($action);
 }
Esempio n. 3
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $u = $invoice->getUser();
     if (!is_null($invoice->second_period)) {
         $a = new Am_Paysystem_Action_Redirect($url = ($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL) . '/connect/subscriptions/new');
         $coef = 1;
         if ($invoice->second_period == Am_Period::MAX_SQL_DATE) {
             $interval_unit = 'month';
             $interval_length = 12 * (2037 - date('Y'));
         } else {
             $second_period = new Am_Period($invoice->second_period);
             switch ($second_period->getUnit()) {
                 case 'd':
                     $interval_unit = 'day';
                     break;
                 case 'm':
                     $interval_unit = 'month';
                     break;
                 case 'y':
                     $interval_unit = 'month';
                     $coef = 12;
                     break;
             }
             $interval_length = $second_period->getCount();
         }
         $first_period = new Am_Period($invoice->first_period);
         $start_at = new DateTime($first_period->addTo(date('Y-m-d')), new DateTimeZone('UTC'));
         $payment_details = array('amount' => $invoice->second_total, 'interval_length' => $interval_length * $coef, 'interval_unit' => $interval_unit, 'name' => $invoice->getLineDescription(), 'start_at' => $start_at->format('Y-m-d\\TH:i:s\\Z'));
         if ($invoice->rebill_times != IProduct::RECURRING_REBILLS) {
             $payment_details['interval_count'] = $invoice->rebill_times;
         }
         if (doubleval($invoice->first_total) > 0) {
             $payment_details['setup_fee'] = $invoice->first_total;
         }
     } else {
         $a = new Am_Paysystem_Action_Redirect($url = ($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL) . '/connect/bills/new');
         $payment_details = array('amount' => $invoice->first_total, 'name' => $invoice->getLineDescription());
     }
     $user_details = array('first_name' => $u->name_f, 'last_name' => $u->name_l, 'email' => $u->email);
     $payment_details['merchant_id'] = $this->getConfig('merchant_id');
     ksort($payment_details);
     ksort($user_details);
     if (is_null($invoice->second_period)) {
         foreach ($payment_details as $v => $k) {
             $a->__set("bill[{$v}]", $k);
         }
         foreach ($user_details as $v => $k) {
             $a->__set("bill[user][{$v}]", $k);
         }
     }
     $a->cancel_uri = $this->getCancelUrl();
     $a->client_id = $this->getConfig('app_id');
     $a->nonce = $this->generate_nonce();
     $a->redirect_uri = $this->getDi()->config->get('root_url') . "/payment/gocardless/thanks";
     $a->state = $invoice->public_id;
     if (!is_null($invoice->second_period)) {
         foreach ($payment_details as $v => $k) {
             $a->__set("subscription[{$v}]", $k);
         }
         foreach ($user_details as $v => $k) {
             $a->__set("subscription[user][{$v}]", $k);
         }
     }
     $date = new DateTime(null, new DateTimeZone('UTC'));
     $a->timestamp = $date->format('Y-m-d\\TH:i:s\\Z');
     $url = parse_url($a->getUrl());
     $a->signature = hash_hmac('sha256', $url['query'], $this->getConfig('app_secret'));
     $result->setAction($a);
 }