コード例 #1
0
 /**
  * @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);
 }