Ejemplo n.º 1
3
 private function executePayment(PaymentMethod $paymentMethod)
 {
     try {
         $paymentMethod->execute();
     } catch (Exception $e) {
         throw new PaymentProcessingException('Paying with ' . $paymentMethod . ' has failed with error: ' . $e->message);
     }
 }
 private function executePayment(PaymentMethod $paymentMethod)
 {
     try {
         $paymentMethod->execute();
     } catch (\Exception $e) {
         $message = "Paying with " . $paymentMethod . " has failed with error " . $e->getMessage();
         throw new PaymentProcessingException($message);
     }
 }
 /**
  * @group shopobjects
  */
 function testCreateShippingMethodOnlyName()
 {
     // GIVEN
     $shippingMethodParameter = $this->givenShippingMethodOnlyName();
     // WHEN
     $shippingMethod = new PaymentMethod($shippingMethodParameter);
     // THEN
     $this->assertFalse($shippingMethod->error());
     $this->assertEquals($shippingMethod->getName(), "DHL");
     $this->assertNull($shippingMethod->getID());
 }
 /**
  * @group shopobjects
  */
 function testCreatePaymentMethodOnlyName()
 {
     // GIVEN
     $paymentMethodParameter = $this->givenPaymentMethodOnlyName();
     // WHEN
     $paymentMethod = new PaymentMethod($paymentMethodParameter);
     // THEN
     $this->assertFalse($paymentMethod->error());
     $this->assertEquals($paymentMethod->getName(), "Paypal");
     $this->assertNull($paymentMethod->getID());
 }
Ejemplo n.º 5
0
 public static function getPaymentSystem($systemCode, $methodID = null)
 {
     if (!isset(self::$paymentSystems[$systemCode])) {
         return null;
     }
     $methodModel = null;
     if ($methodID) {
         $methodModel = new PaymentMethod();
         $methodModel->fillFromID($methodID);
     }
     return new self::$paymentSystems[$systemCode]['class_name']($methodModel);
 }
Ejemplo n.º 6
0
 /**
  * @param $methodID
  * @return array
  */
 public static function getMethodArray($methodID)
 {
     if (isset(self::$_test['method_id']) && self::$_test['method_id'] == $methodID) {
         return self::$_test;
     }
     if (!isset(self::$_paymentMethods[$methodID])) {
         return array();
     }
     self::$_test = self::$_paymentMethods[$methodID];
     if (!isset(self::$_test['fields'])) {
         return self::$_test;
     }
     foreach (self::$_test['fields'] as $k => $v) {
         if (!is_array($v)) {
             self::$_test['fields'][$v] = array();
             unset(self::$_test['fields'][$k]);
             $fieldName = $v;
         } else {
             $fieldName = $k;
         }
         if (isset(self::$_defaultPaymentsFields[$fieldName])) {
             self::$_test['fields'][$fieldName] = array_replace_recursive(self::$_defaultPaymentsFields[$fieldName], self::$_test['fields'][$fieldName]);
         }
     }
     return self::$_test;
 }
Ejemplo n.º 7
0
function createPaymentMethod($type)
{
    $paymentMethod = new PaymentMethod();
    switch ($type) {
        case "cartao":
            $paymentMethod->setCode(PaymentMethodEnum::VISA);
            break;
        case "boleto":
            $paymentMethod->setCode(PaymentMethodEnum::BANK_SLIP);
            break;
        case "transferencia":
            $paymentMethod->setCode(PaymentMethodEnum::BB_ONLINE_TRANSFER);
            break;
    }
    return $paymentMethod;
}
Ejemplo n.º 8
0
 protected function __construct($parent)
 {
     parent::__construct($parent);
     // register payment method
     $this->name = 'stripe';
     $this->registerPaymentMethod();
 }
Ejemplo n.º 9
0
 public function run()
 {
     //$faker = Faker::create();
     //foreach(range(1, 10) as $index)
     //{
     PaymentMethod::create(['name' => '工商银行', 'content' => '银行:中国工商银行 卡号:6335758301540489 开户名:蓝燕光']);
     //}
 }
Ejemplo n.º 10
0
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->CallBackSlug = !$this->CallBackSlug ? 'worldpay' : $this->CallBackSlug;
     if (!$this->Summary) {
         $this->Summary = "Pay with credit/debit card securely via WorldPay";
     }
 }
 /**
  * Constructor
  */
 protected function __construct($parent)
 {
     global $section;
     parent::__construct($parent);
     // register payment method
     $this->name = 'google_checkout';
     $this->registerPaymentMethod();
 }
Ejemplo n.º 12
0
 /**
  * Constructor
  */
 protected function __construct($parent)
 {
     global $section;
     parent::__construct($parent);
     // register payment method
     $this->name = 'tranzila';
     $this->registerPaymentMethod();
 }
Ejemplo n.º 13
0
 public function GetPaymentMethod($type)
 {
     try {
         $sPaymentMethod = PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId AND `Type` = :Type", array(":CampaignId" => $this->sId, ":Type" => $type), 30, true);
     } catch (NotFoundException $e) {
         throw new NotFoundException("No valid payment method specified.");
     }
     return $sPaymentMethod;
 }
Ejemplo n.º 14
0
 /**
  * Constructor
  */
 protected function __construct($parent)
 {
     global $section;
     parent::__construct($parent);
     // register payment method
     $this->name = 'paypal_express';
     $this->registerPaymentMethod();
     // connect signal handler
     Events::connect('shop', 'before-checkout', 'beforeCheckout', $this);
 }
function Step2CreateCreditCard($merchantAccountId)
{
    //    $account = get_account_by_merchantAccountId($merchantAccountId);
    //To save a soap call, you can use sparse objects.
    $account = new Account();
    $account->merchantAccountId = $merchantAccountId;
    $merchantPaymentMethodId = $merchantAccountId;
    $paymentMethod = new PaymentMethod();
    $cc = new CreditCard();
    $paymentMethod->setBillingAddress($account->shippingAddress);
    $paymentMethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    // Use Test cards only in ProdTest.  Use Real cards only in Production.
    $cc->setAccount("4112344112344113");
    $cc->setExpirationDate("201811");
    $paymentMethod->setType('CreditCard');
    $paymentMethod->setCreditCard($cc);
    // Do not check AVS, CVN.  Do not validate.
    $replaceOnAutoBills = true;
    $updateBehavior = "Update";
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $srd = '';
    $response = $account->updatePaymentMethod($srd, $paymentMethod, $replaceOnAutoBills, $updateBehavior, $ignoreAvsPolicy, $ignoreCvnPolicy);
    // Log soap id for each API call.
    //    $log->addDebug('Method = Account.updatePaymentMethod' . PHP_EOL);
    //    $log->addDebug('Soap Id = ' . $response['data']->return->soapId . PHP_EOL);
    //    $log->addDebug('Return Code = ' . $response['returnCode'] . PHP_EOL);
    //    $log->addDebug('Return String = ' . $response['returnString'] . PHP_EOL);
    if ($response['returnCode'] == 200) {
        print "Call succeeded" . PHP_EOL;
    } else {
        print "Call failed" . PHP_EOL;
    }
}
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $config = $this->config();
     // Set default colours
     $this->CallBackSlug = !$this->CallBackSlug ? 'epdq' : $this->CallBackSlug;
     $this->Background = !$this->Background ? $config->default_background : $this->Background;
     $this->Text = !$this->Text ? $config->default_text : $this->Text;
     $this->TableBackground = !$this->TableBackground ? $config->default_table_background : $this->TableBackground;
     $this->TableText = !$this->TableText ? $config->default_table_text : $this->TableText;
     $this->ButtonBackground = !$this->ButtonBackground ? $config->default_button_background : $this->ButtonBackground;
     $this->ButtonText = !$this->ButtonText ? $config->default_button_text : $this->ButtonText;
     $this->Summary = !$this->Summary ? "Pay with credit/debit card securely via Barclays" : $this->Summary;
 }
Ejemplo n.º 17
0
 /**
  * Getting The end javascript
  *
  * @return string
  */
 protected function _getEndJs()
 {
     $class = get_called_class();
     $js = $this->_getJSPrefix();
     $js .= parent::_getEndJs();
     $paymentMethods = array_map(create_function('$a', 'return $a->getJson();'), PaymentMethod::getAll());
     $shippingMethods = array_map(create_function('$a', 'return $a->getJson();'), Courier::getAll());
     $supplier = isset($_REQUEST['supplierid']) && ($supplier = Supplier::get(trim($_REQUEST['supplierid']))) instanceof Supplier ? $supplier->getJson() : null;
     $js .= "pageJs";
     $js .= ".setHTMLID('itemDiv', 'detailswrapper')";
     $js .= ".setHTMLID('searchPanel', 'search_panel')";
     $js .= ".setCallbackId('searchSupplier', '" . $this->searchSupplierBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('searchProduct', '" . $this->searchProductBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('saveOrder', '" . $this->saveOrderBtn->getUniqueID() . "')";
     $js .= ".setPaymentMethods(" . json_encode($paymentMethods) . ")";
     $js .= ".setShippingMethods(" . json_encode($shippingMethods) . ")";
     $js .= ".init(" . json_encode($supplier) . ");";
     return $js;
 }
Ejemplo n.º 18
0
 public function actionDelete()
 {
     $companyId = Helper::getCompanyId(Yii::app()->request->getParam('companyId'));
     $ids = Yii::app()->request->getPost('ids');
     Until::isUpdateValid($ids, $companyId, $this);
     //0,表示企业任何时候都在云端更新。
     if (!empty($ids)) {
         foreach ($ids as $id) {
             $model = PaymentMethod::model()->find('lid=:id and dpid=:companyId', array(':id' => $id, ':companyId' => $companyId));
             if ($model) {
                 $model->delete();
             }
         }
         $this->redirect(array('payMethod/index', 'companyId' => $companyId));
     } else {
         Yii::app()->user->setFlash('error', yii::t('app', '请选择要删除的项目'));
         $this->redirect(array('payMethod/index', 'companyId' => $companyId));
     }
 }
Ejemplo n.º 19
0
function create_ecp_PaymentMethod()
{
    $uniqueValue = get_unique_value();
    $merchantAccountId = 'account-' . $uniqueValue;
    $merchantPaymentMethodId = 'pm-' . $uniqueValue;
    $email = get_unique_value() . '@nomail.com';
    $successUrl = 'http://good.com/';
    //need a trailing slash
    $errorUrl = 'http://bad.com/';
    //need a trailing slash
    $name = 'John Vindicia';
    $addr1 = '303 Twin Dolphin Drive';
    $city = 'Redwood City';
    $district = 'CA';
    $postalCode = '94065';
    $country = 'US';
    $address = new Address();
    $address->setName($name);
    $address->setAddr1($addr1);
    $address->setCity($city);
    $address->setDistrict($district);
    $address->setPostalCode($postalCode);
    $address->setCountry($country);
    $paymentmethod = new PaymentMethod();
    $paymentmethod->setType('ECP');
    $paymentmethod->setAccountHolderName($name);
    $paymentmethod->setBillingAddress($address);
    $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $paymentmethod->setCurrency('USD');
    $ecp = new ECP();
    $ecp->setAccount('495958930');
    $ecp->setRoutingNumber('611111111');
    $ecp->setAllowedTransactionType('Inbound');
    $ecp->setAccountType('ConsumerChecking');
    $paymentmethod->setECP($ecp);
    $account = new Account();
    $account->setMerchantAccountId($merchantAccountId);
    $account->setEmailAddress($email);
    $account->setShippingAddress($address);
    $account->setEmailTypePreference('html');
    $account->setName($name);
    $account->setPaymentMethods(array($paymentmethod));
    return $account;
}
Ejemplo n.º 20
0
 public function start(array $items, $settings = array(), $paymentMethod = 'paypal', $currency = 'USD')
 {
     ## unable to authenticate
     if (!$this->authenthication($settings['environment'])) {
         return false;
     }
     #set ApiContext
     $apiContext = PaypalContext::ApiContext($this->credentials, $this->sdkConfiguration);
     #set payment method
     $payer = PaymentMethod::ConfigPayment($paymentMethod);
     #set Items and Total to bill
     if (!($itemsList = Items::setItemsList($items, $currency))) {
         ## unable to load the items to sell.
         return false;
     }
     #set final amount.
     $amount = Amount::setAmount(Items::getTotal(), $currency);
     #set transaction.
     $transaction = Transaction::setTransaction($amount, $itemsList);
     #set redirections.
     $redirectUrls = Redirections::setURLs();
     self::_createPaymentURL($payer, $redirectUrls, $transaction, $apiContext);
 }
function create_paypal_PaymentMethod()
{
    $uniqueValue = get_unique_value();
    $merchantAccountId = 'account-' . $uniqueValue;
    $merchantPaymentMethodId = 'pm-' . $uniqueValue;
    $email = get_unique_value() . '@nomail.com';
    $successUrl = 'http://good.com/';
    //need a trailing slash
    $errorUrl = 'http://bad.com/';
    //need a trailing slash
    $name = 'John Vindicia';
    $addr1 = '303 Twin Dolphin Drive';
    $city = 'Redwood City';
    $district = 'CA';
    $postalCode = '94065';
    $country = 'US';
    $address = new Address();
    $address->setName($name);
    $address->setAddr1($addr1);
    $address->setCity($city);
    $address->setDistrict($district);
    $address->setPostalCode($postalCode);
    $address->setCountry($country);
    $paymentmethod = new PaymentMethod();
    $paymentmethod->setType('PayPal');
    $paymentmethod->setAccountHolderName($name);
    $paymentmethod->setBillingAddress($address);
    $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $paymentmethod->setCurrency('USD');
    $paypal = new PayPal();
    $paypal->setReturnUrl($successUrl);
    $paypal->setCancelUrl($errorUrl);
    $paymentmethod->setPaypal($paypal);
    $account = new Account();
    $account->setMerchantAccountId($merchantAccountId);
    $account->setEmailAddress($email);
    $account->setShippingAddress($address);
    $account->setEmailTypePreference('html');
    $account->setName($name);
    //$account->setPaymentMethods(array($paymentmethod));
    //return $account;
    return array('account' => $account, 'paymentmethod' => $paymentmethod);
}
 public function send()
 {
     parent::sendImp();
 }
<?php

require_once "Vindicia/Soap/Vindicia.php";
require_once "Vindicia/Soap/Const.php";
$account = new Account();
// existing customer's Account ID. Tax will be added based on shippingAddress populated on this Account
$account->setMerchantAccountId("jdoe101");
$pm = new PaymentMethod();
$pm->setMerchantPaymentMethodId('VINTESTPM-' . rand(10000, 99999));
// Unique payment method id
$pm->setType('HostedPage');
$hostedPageInfo = new HostedPage();
$hostedPageInfo->setCountryCode('MY');
$hostedPageInfo->setLanguage('en');
$hostedPageInfo->setReturnUrl('http://www.mysite.co.my/PaymentReturn.php');
// specify a page on your site customer will be redirected to after completing the MOLPay payment
$hostedPageInfo->setProcessorPaymentMethodId('all');
// Customer can choose any payment method type at MOLPay
$provider = new PaymentProvider();
$provider->setName('MOLPay');
$hostedPageInfo->setPaymentProvider($provider);
$pm->setHostedPage($hostedPageInfo);
$transaction = new Transaction();
$transaction->setCurrency('MYR');
// Unique transaction ID, use prefix to tell transactions apart from the subscription transactions
$transaction->setMerchantTransactionId('VINTEST-' . rand(10000, 99999));
$transaction->setAccount($account);
$transaction->setSourcePaymentMethod($pm);
//Create purchase line items. This can also be created by looking up a CashBox Product
$transaction_lineItem0 = new TransactionItem();
$transaction_lineItem0->setSku('MYPRODUCT001');
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = PaymentMethod::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 25
0
<div class="form order-details-page">

<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'multiple-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>
	<?php 
echo $form->errorSummary(array($model, $description));
?>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'payment_method');
?>
		<?php 
echo $form->dropDownList($model, 'payment_method', CHtml::listData(PaymentMethod::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}));
?>
		<?php 
echo $form->error($model, 'payment_method');
?>
	</div>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'shipping_method');
?>
		<?php 
echo $form->dropDownList($model, 'shipping_method', CHtml::listData(ShippingMethod::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}));
Ejemplo n.º 26
0
 public function visit(PaymentMethod $paymentMethod)
 {
     $this->description = '<html><body><div>' . $paymentMethod->getDescription() . '</div></body></html>';
 }
 public function init()
 {
     parent::init();
     // Check if payment ID set and corresponds
     if ($this->request->param('ID') && ($method = PaymentMethod::get()->byID($this->request->param('ID')))) {
         $this->payment_method = $method;
     } elseif ($method = PaymentMethod::get()->byID(Session::get('Checkout.PaymentMethodID'))) {
         $this->payment_method = $method;
     }
     // Setup payment handler
     if ($this->payment_method && $this->payment_method !== null) {
         $handler = $this->payment_method->ClassName;
         $handler = $handler::$handler;
         $this->payment_handler = $handler::create();
         $this->payment_handler->setPaymentGateway($this->getPaymentMethod());
     }
 }
 /**
  * normalize helper function.
  *
  * the utm_source is structured as: banner.landing_page.payment_method_family
  */
 protected function setUtmSource()
 {
     $utm_source = $this->getVal('utm_source');
     $utm_source_id = $this->getVal('utm_source_id');
     if ($this->getVal('payment_method')) {
         $method_object = PaymentMethod::newFromCompoundName($this->gateway, $this->getVal('payment_method'), $this->getVal('payment_submethod'), $this->getVal('recurring'));
         $utm_payment_method_family = $method_object->getUtmSourceName();
     } else {
         $utm_payment_method_family = '';
     }
     $recurring_str = var_export($this->getVal('recurring'), true);
     $this->logger->debug(__FUNCTION__ . ": Payment method is {$this->getVal('payment_method')}, recurring = {$recurring_str}, utm_source = {$utm_payment_method_family}");
     // split the utm_source into its parts for easier manipulation
     $source_parts = explode(".", $utm_source);
     // If we don't have the banner or any utm_source, set it to the empty string.
     if (empty($source_parts[0])) {
         $source_parts[0] = '';
     }
     // If the utm_source_id is set, include that in the landing page
     // portion of the string.
     if ($utm_source_id) {
         $source_parts[1] = $utm_payment_method_family . $utm_source_id;
     } else {
         if (empty($source_parts[1])) {
             $source_parts[1] = '';
         }
     }
     $source_parts[2] = $utm_payment_method_family;
     if (empty($source_parts[2])) {
         $source_parts[2] = '';
     }
     // reconstruct, and set the value.
     $utm_source = implode(".", $source_parts);
     $this->setVal('utm_source', $utm_source);
 }
Ejemplo n.º 29
0
 public function setPaymentFields($array, $valid)
 {
     if ($valid) {
         $validPaymentFields = PaymentMethod::validateFields($array, 1);
     }
 }
Ejemplo n.º 30
0
 /**
  * Creating the PaymentMethod
  * 
  * @param string $name
  * @param string $description
  * 
  * @return PaymentMethod
  */
 public static function create($name, $description = '')
 {
     if (($entity = self::getByName($name)) instanceof PaymentMethod) {
         throw new Exception('The payment method already exsits: ' . $name);
     }
     $entity = new PaymentMethod();
     return $entity->setName(trim($name))->setDescription(trim($description))->save();
 }