public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { if (!$this->getConfig('wallet_id')) { throw new Am_Exception_Configuration("There is a configuration error in [okpay] plugin - no [wallet_id] Wallet ID or e-mail"); } $a = new Am_Paysystem_Action_Redirect(self::URL); $result->setAction($a); # Payment config $a->ok_receiver = $this->getConfig('wallet_id'); $a->ok_invoice = $invoice->getRandomizedId(); $a->ok_currency = strtoupper($invoice->currency); $a->ok_item_1_name = $invoice->getLineDescription(); $a->ok_item_1_price = $invoice->first_total; # Payer data $a->ok_payer_first_name = $invoice->getFirstName(); $a->ok_payer_last_name = $invoice->getLastName(); $a->ok_payer_street = $invoice->getStreet(); $a->ok_payer_city = $invoice->getCity(); $a->ok_payer_state = $invoice->getState(); $a->ok_payer_zip = $invoice->getZip(); $a->ok_payer_country = $invoice->getCountry(); # IPN and Return URLs $a->ok_ipn = $this->getPluginUrl('ipn'); $a->ok_return_success = $this->getReturnUrl(); $a->ok_return_fail = $this->getCancelUrl(); }
function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { if (!$this->getConfig('business')) { throw new Am_Exception_Configuration("There is a configuration error in [paypal] plugin - no [business] e-mail configured"); } $a = new Am_Paysystem_Action_Redirect('https://' . $this->domain . '/cgi-bin/webscr'); $result->setAction($a); $a->business = $this->getConfig('business'); $a->return = $this->getReturnUrl(); $a->notify_url = $this->getPluginUrl('ipn'); $a->cancel_return = $this->getCancelUrl(); $a->item_name = html_entity_decode($invoice->getLineDescription(), null, 'UTF-8'); $a->no_shipping = $invoice->hasShipping() ? 0 : 1; $a->shipping = $invoice->first_shipping; $a->currency_code = strtoupper($invoice->currency); $a->no_note = 1; $a->invoice = $invoice->getRandomizedId(); $a->bn = 'CgiCentral.aMemberPro'; $a->first_name = $invoice->getFirstName(); $a->last_name = $invoice->getLastName(); $a->address1 = $invoice->getStreet(); $a->city = $invoice->getCity(); $a->state = $invoice->getState(); $a->zip = $invoice->getZip(); $a->country = $invoice->getCountry(); $a->charset = 'utf-8'; if ($lc = $this->getConfig('lc')) { $a->lc = $lc; } $a->rm = 2; if ($invoice->rebill_times) { $a->cmd = '_xclick-subscriptions'; $a->sra = 1; if ($invoice->rebill_times == 1) { $a->src = 0; } else { $a->src = 1; //Ticket #HPU-80211-470: paypal_r plugin not passing the price properly (or at all)? if ($invoice->rebill_times != IProduct::RECURRING_REBILLS) { $a->srt = $invoice->rebill_times; } } /** @todo check with rebill times = 1 */ $a->a1 = $invoice->first_total; $p = new Am_Period($invoice->first_period); $a->p1 = $p->getCount(); $a->t1 = $this->getPeriodUnit($p->getUnit()); $a->tax1 = $invoice->first_tax; $a->a3 = $invoice->second_total; $p = new Am_Period($invoice->second_period); $a->p3 = $p->getCount(); $a->t3 = $this->getPeriodUnit($p->getUnit()); $a->tax3 = $invoice->second_tax; } else { $a->cmd = '_xclick'; $a->amount = $invoice->first_total - $invoice->first_tax - $invoice->first_shipping; $a->tax = $invoice->first_tax; } }
function createRecurringPaymentProfile(Invoice $invoice, CcRecord $cc = null, $token = null, $payerId = null) { if (!$cc && !$token) { throw new Am_Exception_Paysystem("Either [token] or [cc] must be specified for " . __METHOD__); } $periodConvert = array(Am_Period::DAY => 'Day', Am_Period::MONTH => 'Month', Am_Period::YEAR => 'Year'); $this->addPostParameter('METHOD', 'CreateRecurringPaymentsProfile'); if ($token) { $this->addPostParameter('TOKEN', $token); $this->addPostParameter('PAYERID', $payerId); } $this->addPostParameter('DESC', $invoice->getTerms()); $this->addPostParameter('PROFILESTARTDATE', gmdate('Y-m-d\\TH:i:s.00\\Z', strtotime($invoice->calculateRebillDate(1) . ' 00:00:01'))); $this->addPostParameter('PROFILEREFERENCE', $invoice->getRandomizedId('site')); //$this->addPostParameter('MAXFAILEDPAYMENTS', ''); //$this->addPostParameter('AUTOBILLOUTAMT', 'AddToNextBilling'); $p = new Am_Period($invoice->first_period); $pp = $periodConvert[$p->getUnit()]; if (!$pp) { throw new Am_Exception_Configuration("Could not find billing unit for invoice#{$invoice->invoice_id}.first_period: {$invoice->first_period}"); } /// first period - removed as handled with START_DATE //$this->addPostParameter('TRIALBILLINGPERIOD', $pp); //$this->addPostParameter('TRIALBILLINGFREQUENCY', $p->getCount()); //$this->addPostParameter('TRIALTOTALBILLINGCYCLES', '1'); //$this->addPostParameter('TRIALAMT', $invoice->second_total); // bill at the end of trial period // it may take up to 24hours to process it! so enabled only for credit card payments if ($cc && $invoice->first_total > 0) { $this->addPostParameter('INITAMT', $invoice->first_total); } // bill right now /// second period $p = new Am_Period($invoice->second_period); $pp = $periodConvert[$p->getUnit()]; if (!$pp) { throw new Am_Exception_Configuration("Could not find billing unit for invoice#{$invoice->invoice_id}.second_period: {$invoice->second_period}"); } $this->addPostParameter('BILLINGPERIOD', $pp); $this->addPostParameter('BILLINGFREQUENCY', $p->getCount()); if ($invoice->rebill_times != IProduct::RECURRING_REBILLS) { $this->addPostParameter('TOTALBILLINGCYCLES', $invoice->rebill_times); } $this->addPostParameter('AMT', $invoice->second_total - $invoice->second_tax); // bill at end of each payment period $this->addPostParameter('TAXAMT', $invoice->second_tax); $this->addPostParameter('CURRENCYCODE', $invoice->currency); // @todo $this->addPostParameter('NOTIFYURL', $this->plugin->getPluginUrl('ipn')); $i = 0; foreach ($invoice->getItems() as $item) { /* @var $item InvoiceItem */ $this->addPostParameter("L_PAYMENTREQUEST_0_NAME{$i}", $item->item_title); $this->addPostParameter("L_PAYMENTREQUEST_0_NUMBER{$i}", $item->item_id); $this->addPostParameter("L_PAYMENTREQUEST_0_QTY{$i}", $item->qty); $i++; } $this->addPostParameter('L_BILLINGTYPE0', 'RecurringPayments'); $this->addPostParameter('L_BILLINGAGREEMENTDESCRIPTION0', $invoice->getTerms()); if ($cc) { $this->setCC($invoice, $cc); } if ($this->plugin->getConfig('send_shipping')) { $this->setShippingAddress($invoice); } return $this; }
public function getAdminCancelUrl(Invoice $invoice) { return 'https://' . $this->domain . '/checkout/api/r.php' . http_build_query(array('invoice' => $invoice->getRandomizedId()), '', '&'); }