当前位置: 首页>>代码示例>>PHP>>正文


PHP Gateway::instance方法代码示例

本文整理汇总了PHP中Gateway::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Gateway::instance方法的具体用法?PHP Gateway::instance怎么用?PHP Gateway::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gateway的用法示例。


在下文中一共展示了Gateway::instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Creates a new customer transaction.
  *
  * @param Model_Customer_Paymentmethod $payment_method The payment method.
  * @param string                       $amount         The amount to transact.
  * @param array                        $data           Optional data.
  *
  * @return Model_Customer_Transaction
  */
 public static function create(Model_Customer_Paymentmethod $payment_method, $amount, array $data = array())
 {
     $gateway_instance = Gateway::instance($payment_method->gateway, $payment_method->customer);
     if ($gateway_instance) {
         $external_id = $gateway_instance->transaction()->create(array('payment_method' => $payment_method, 'amount' => $amount));
         if (!$external_id) {
             return false;
         }
     } else {
         $external_id = null;
     }
     $transaction = Model_Customer_Transaction::forge();
     $transaction->customer = $payment_method->customer;
     $transaction->gateway = $payment_method->gateway;
     $transaction->external_id = $external_id;
     $transaction->type = $payment_method->gateway->type;
     $transaction->provider = $payment_method->provider;
     $transaction->account = $payment_method->account;
     $transaction->amount = $amount;
     try {
         $transaction->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     Service_Event::trigger('customer.transaction.create', $transaction->customer->seller, $transaction->to_array());
     return $transaction;
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:37,代码来源:transaction.php

示例2: forge

 /**
  * Gets a new instance of gateway $class_name.
  *
  * @param Model_Gateway  $gateway    The gateway model to use for the driver.
  * @param Model_Customer $customer   The customer model to use for the driver.
  * @param string         $class_name The class name to call on the driver.
  *
  * @return Gateway_Model
  */
 public static function forge(Model_Gateway $gateway, Model_Customer $customer = null, $class_name)
 {
     $driver_name = str_replace('Gateway_', '', get_called_class());
     $driver_name = str_replace('_Driver', '', $driver_name);
     $class = 'Gateway_' . Str::ucwords(Inflector::denamespace($driver_name)) . '_' . Str::ucwords(Inflector::denamespace($class_name));
     if (!class_exists($class)) {
         throw new GatewayException('Call to undefined class ' . $class);
     }
     $driver = Gateway::instance($gateway, $customer);
     return new $class($driver);
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:20,代码来源:driver.php

示例3: create

 /**
  * Creates a new customer gateway relation.
  *
  * @param Model_Customer $customer The customer.
  * @param Model_Gateway  $gateway  The gateway.
  * @param array          $data     Optional data.
  *
  * @return Model_Customer
  */
 public static function create(Model_Customer $customer, Model_Gateway $gateway, array $data = array())
 {
     if (!($contact = Arr::get($data, 'contact'))) {
         $contact = current($customer->contacts);
     }
     $external_id = Gateway::instance($gateway)->customer()->create(array('customer' => $customer, 'contact' => $contact));
     if (!$external_id) {
         return false;
     }
     $customer_gateway = Model_Customer_Gateway::forge();
     $customer_gateway->customer_id = $customer->id;
     $customer_gateway->gateway_id = $gateway->id;
     $customer_gateway->external_id = $external_id;
     try {
         $customer_gateway->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     return $customer_gateway;
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:30,代码来源:gateway.php

示例4: delete

 /**
  * Deletes a payment method.
  *
  * @param Model_Customer_Paymentmethod $payment_method The payment method to delete.
  *
  * @return bool
  */
 public static function delete(Model_Customer_Paymentmethod $payment_method)
 {
     // A primary payment method cannot be deleted.
     if ($payment_method->primary()) {
         return false;
     }
     $gateway = $payment_method->gateway;
     $customer = $payment_method->customer;
     $gateway_instance = Gateway::instance($gateway, $customer);
     if ($gateway_instance) {
         $gateway_payment_method = $gateway_instance->paymentmethod($payment_method->external_id);
         if (!$gateway_payment_method) {
             return false;
         }
         if (!$gateway_payment_method->delete()) {
             return false;
         }
     }
     $payment_method->status = 'deleted';
     try {
         $payment_method->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     Service_Event::trigger('customer.paymentmethod.delete', $payment_method->customer->seller, $payment_method->to_array());
     return true;
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:35,代码来源:paymentmethod.php


注:本文中的Gateway::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。