Пример #1
1
 function set_gateway_param()
 {
     global $psts;
     Twocheckout::$sid = $psts->get_setting('2co_acc_number');
     Twocheckout::username($psts->get_setting('2co_api_username'));
     Twocheckout::password($psts->get_setting('2co_api_password'));
     if ($psts->get_setting('2co_checkout_mode') == 'Y') {
         Twocheckout::sandbox(true);
     }
 }
 function __construct($gateway = NULL)
 {
     if (!class_exists("Twocheckout")) {
         require_once dirname(__FILE__) . "/../../includes/lib/Twocheckout/Twocheckout.php";
     }
     //set API connection vars
     Twocheckout::sellerId(pmpro_getOption('twocheckout_accountnumber'));
     Twocheckout::username(pmpro_getOption('twocheckout_apiusername'));
     Twocheckout::password(pmpro_getOption('twocheckout_apipassword'));
     Twocheckout::$verifySSL = false;
     $this->gateway = $gateway;
     return $this->gateway;
 }
Пример #3
0
/**
 * Cancel a 2checkout subscriber
 *
 * @access      private
 * @since       2.4
 */
function rcp_2checkout_cancel_member($member_id = 0)
{
    global $rcp_options;
    $user_name = defined('TWOCHECKOUT_ADMIN_USER') ? TWOCHECKOUT_ADMIN_USER : '';
    $password = defined('TWOCHECKOUT_ADMIN_PASSWORD') ? TWOCHECKOUT_ADMIN_PASSWORD : '';
    if (empty($user_name) || empty($password)) {
        return new WP_Error('missing_username_or_password', __('The 2Checkout API username and password must be defined', 'rcp'));
    }
    if (!class_exists('Twocheckout')) {
        require_once RCP_PLUGIN_DIR . 'includes/libraries/twocheckout/Twocheckout.php';
    }
    $secret_word = isset($rcp_options['sandbox']) ? trim($rcp_options['twocheckout_secret_word']) : '';
    $test_mode = isset($rcp_options['sandbox']);
    if ($test_mode) {
        $secret_key = isset($rcp_options['twocheckout_test_private']) ? trim($rcp_options['twocheckout_test_private']) : '';
        $publishable_key = isset($rcp_options['twocheckout_test_publishable']) ? trim($rcp_options['twocheckout_test_publishable']) : '';
        $seller_id = isset($rcp_options['twocheckout_test_seller_id']) ? trim($rcp_options['twocheckout_test_seller_id']) : '';
        $environment = 'sandbox';
    } else {
        $secret_key = isset($rcp_options['twocheckout_live_private']) ? trim($rcp_options['twocheckout_live_private']) : '';
        $publishable_key = isset($rcp_options['twocheckout_live_publishable']) ? trim($rcp_options['twocheckout_live_publishable']) : '';
        $seller_id = isset($rcp_options['twocheckout_live_seller_id']) ? trim($rcp_options['twocheckout_live_seller_id']) : '';
        $environment = 'production';
    }
    try {
        Twocheckout::privateKey($secret_key);
        Twocheckout::sellerId($seller_id);
        Twocheckout::username(TWOCHECKOUT_ADMIN_USER);
        Twocheckout::password(TWOCHECKOUT_ADMIN_PASSWORD);
        Twocheckout::sandbox($test_mode);
        $member = new RCP_Member($member_id);
        $sale_id = str_replace('2co_', '', $member->get_payment_profile_id());
        $cancelled = Twocheckout_Sale::stop(array('sale_id' => $sale_id));
        if ($cancelled['response_code'] == 'OK') {
            return true;
        }
    } catch (Twocheckout_Error $e) {
        return new WP_Error('2checkout_cancel_failed', $e->getMessage());
    }
}
Пример #4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->locator = new ServiceLocator();
     if ($this->username && $this->password) {
         \Twocheckout::username($this->username);
         \Twocheckout::password($this->password);
     }
     if (!$this->privateKey) {
         throw new InvalidConfigException('Invalid private key was specified');
     }
     \Twocheckout::privateKey($this->privateKey);
     if (!$this->sellerId) {
         throw new InvalidConfigException('Invalid seller id was specified');
     }
     \Twocheckout::sellerId($this->sellerId);
     if (!$this->secretWord) {
         throw new InvalidConfigException('Invalid secret word was specified');
     }
     \TwoCheckout::verifySSL($this->verifySSL);
     \Twocheckout::sandbox($this->sandbox);
     \Twocheckout::format($this->format);
 }
Пример #5
0
 public function issue_creditmemo_refund(Varien_Object $payment)
 {
     $refund = Mage::getStoreConfig('payment/twocheckout/refund');
     if ($refund == '1') {
         $order = $payment->getCreditmemo()->getOrder();
         $creditmemo = $payment->getCreditmemo()->getOrder()->getData();
         $creditmemo_amount = $payment->getCreditmemo()->getData();
         $creditmemo_comment = $payment->getCreditmemo()->getCommentsCollection()->toArray();
         if (isset($creditmemo_comment['items'][0]['comment'])) {
             $comment = $creditmemo_comment['items'][0]['comment'];
         } else {
             $comment = 'Refund issued by seller';
         }
         $username = Mage::getStoreConfig('payment/twocheckout/username');
         $password = Mage::getStoreConfig('payment/twocheckout/password');
         $sandbox = Mage::getStoreConfig('payment/twocheckout/demo');
         Twocheckout::username($username);
         Twocheckout::password($password);
         if ($sandbox == "1") {
             Twocheckout::sandbox(true);
         } else {
             Twocheckout::sandbox(false);
         }
         $data = array();
         $data['invoice_id'] = $creditmemo['ext_order_id'];
         $data['comment'] = $comment;
         $data['category'] = '5';
         $data['amount'] = $creditmemo_amount['grand_total'];
         $data['currency'] = 'vendor';
         try {
             $response = Twocheckout_Sale::refund($data);
             $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
             $order->addStatusHistoryComment($response["response_message"]);
             $order->save();
         } catch (Twocheckout_Error $e) {
             Mage::throwException(Mage::helper('core')->__($e->getMessage()));
         }
     }
 }
Пример #6
0
 public function setUp()
 {
     Twocheckout::username('testlibraryapi901248204');
     Twocheckout::password('testlibraryapi901248204PASS');
     Twocheckout::sandbox(true);
 }
 public static function password($value = null)
 {
     self::$password = $value;
 }