コード例 #1
0
 /**
  * $options array includes login parameters of merchant and optional currency.
  *
  * @param array $options
  */
 public function __construct($options = array())
 {
     $this->required_options('login, password, signature', $options);
     if (isset($options['currency'])) {
         self::$default_currency = $options['currency'];
     }
     $this->options = $options;
 }
コード例 #2
0
ファイル: paypal.php プロジェクト: walteraries/anahita
 /**
  * (non-PHPdoc)
  * @see ComSubscriptionsDomainPaymentGatewayAbstract::process()
  */
 public function process(ComSubscriptionsDomainPaymentPayload $payload)
 {
     $options = new KConfig();
     $options->append(array('description' => $payload->description));
     $args = array($payload->getTotalAmount());
     if ($payload->payment_method instanceof ComSubscriptionsDomainPaymentMethodToken) {
         $gateway = new Merchant_Billing_PaypalExpress($this->_gateway_config);
         $options->append($payload->payment_method->options);
     } else {
         $gateway = new Merchant_Billing_Paypal($this->_gateway_config);
         $ip = KRequest::get('server.REMOTE_ADDR', 'raw');
         if (!$this->getService('koowa:filter.ip')->validate($ip) || strlen($ip) <= 7) {
             $ip = '127.0.0.1';
         }
         $contact = $payload->payment_method->address;
         $options->append(array('order_id' => $payload->order_id, 'ip' => $ip, 'address' => array('address1' => $contact->address, 'zip' => $contact->zip, 'state' => $contact->state, 'city' => $contact->city, 'country' => $contact->country)));
         $args[] = $payload->payment_method->creditcard;
     }
     $method = 'purchase';
     if ($payload->getRecurring()) {
         $method = 'recurring';
         $options['occurrences'] = $payload->getRecurring()->frequency;
         $options['unit'] = $payload->getRecurring()->unit;
         $options['start_date'] = $payload->getRecurring()->start_date;
     }
     $args[] = KConfig::unbox($options);
     $gateway->post(array('TAXAMT' => $payload->tax_amount, 'ITEMAMT' => $payload->amount));
     $response = call_object_method($gateway, $method, $args);
     $result = $response->success();
     if (!$result) {
         $this->_logError($response);
     }
     return $result;
 }
コード例 #3
0
ファイル: index.php プロジェクト: bluetechy/Aktive-Merchant
<?php

require_once '../../lib/merchant.php';
require_once '../login.php';
Merchant_Billing_Base::mode('test');
$gateway = new Merchant_Billing_Paypal(array('login' => PAYPAL_PRO_LOGIN, 'password' => PAYPAL_PRO_PASS, 'signature' => PAYPAL_PRO_SIG, 'currency' => 'USD'));
$cc = new Merchant_Billing_CreditCard(array("first_name" => "Test", "last_name" => "User", "number" => "4242500628981382", "month" => "9", "year" => "2019", "verification_value" => "123"));
$options = array('address' => array('address1' => '1 Main St', 'zip' => '95131', 'state' => 'CA', 'country' => 'United States', 'city' => 'San Jose'));
try {
    $response = $gateway->authorize(10, $cc, $options);
    if ($response->success()) {
        echo 'Success payment!';
    } else {
        echo $response->message();
    }
} catch (Exception $exc) {
    echo $exc->getMessage();
}