public function __construct(PhortunePaymentMethod $method, array $providers) { assert_instances_of($providers, 'PhortunePaymentProvider'); $type = $method->getMetadataValue('type'); $provider_names = array(); foreach ($providers as $provider) { $provider_names[] = get_class($provider); } return parent::__construct("More than one payment provider can handle charging payments for this " . "payment method. This is ambiguous and likely indicates that a payment " . "provider is not properly implemented. You may be able to use a " . "different payment method to complete this transaction. The payment " . "method type is '{$type}'. The providers claiming to handle it are: " . implode(', ', $provider_names) . '.'); }
/** * @phutil-external-symbol class Stripe_Charge */ protected function executeCharge(PhortunePaymentMethod $method, PhortuneCharge $charge) { $root = dirname(phutil_get_library_root('phabricator')); require_once $root . '/externals/stripe-php/lib/Stripe.php'; $secret_key = $this->getSecretKey(); $params = array('amount' => $charge->getAmountInCents(), 'currency' => 'usd', 'customer' => $method->getMetadataValue('stripe.customerID'), 'description' => $charge->getPHID(), 'capture' => true); $stripe_charge = Stripe_Charge::create($params, $secret_key); $id = $stripe_charge->id; if (!$id) { throw new Exception('Stripe charge call did not return an ID!'); } $charge->setMetadataValue('stripe.chargeID', $id); }
public function canHandlePaymentMethod(PhortunePaymentMethod $method) { $type = $method->getMetadataValue('type'); return $type === 'test.multiple'; }
public function canHandlePaymentMethod(PhortunePaymentMethod $method) { $type = $method->getMetadataValue('type'); return $type === 'balanced.account'; }
public function __construct(PhortunePaymentMethod $method) { $type = $method->getMetadataValue('type'); return parent::__construct("No available payment provider can handle charging payments for this " . "payment method. You may be able to use a different payment method to " . "complete this transaction. The payment method type is '{$type}'."); }
/** * @phutil-external-symbol class Stripe_Charge * @phutil-external-symbol class Stripe_CardError * @phutil-external-symbol class Stripe_Account */ protected function executeCharge(PhortunePaymentMethod $method, PhortuneCharge $charge) { $this->loadStripeAPILibraries(); $price = $charge->getAmountAsCurrency(); $secret_key = $this->getSecretKey(); $params = array('amount' => $price->getValueInUSDCents(), 'currency' => $price->getCurrency(), 'customer' => $method->getMetadataValue('stripe.customerID'), 'description' => $charge->getPHID(), 'capture' => true); $stripe_charge = Stripe_Charge::create($params, $secret_key); $id = $stripe_charge->id; if (!$id) { throw new Exception(pht('Stripe charge call did not return an ID!')); } $charge->setMetadataValue('stripe.chargeID', $id); $charge->save(); }
public function canHandlePaymentMethod(PhortunePaymentMethod $method) { $type = $method->getMetadataValue('type'); return $type == 'paypal'; }