diff --git a/src/applications/phortune/provider/PhortuneStripePaymentProvider.php b/src/applications/phortune/provider/PhortuneStripePaymentProvider.php index efac0a652d..5a19c928d8 100644 --- a/src/applications/phortune/provider/PhortuneStripePaymentProvider.php +++ b/src/applications/phortune/provider/PhortuneStripePaymentProvider.php @@ -39,6 +39,7 @@ final class PhortuneStripePaymentProvider extends PhortunePaymentProvider { /** * @phutil-external-symbol class Stripe_Charge + * @phutil-external-symbol class Stripe_CardError */ protected function executeCharge( PhortunePaymentMethod $method, @@ -58,13 +59,20 @@ final class PhortuneStripePaymentProvider extends PhortunePaymentProvider { 'capture' => true, ); - $stripe_charge = Stripe_Charge::create($params, $secret_key); + try { + $stripe_charge = Stripe_Charge::create($params, $secret_key); + } catch (Stripe_CardError $ex) { + // TODO: Fail charge explicitly. + throw $ex; + } + $id = $stripe_charge->id; if (!$id) { throw new Exception('Stripe charge call did not return an ID!'); } $charge->setMetadataValue('stripe.chargeID', $id); + $charge->save(); } private function getPublishableKey() { diff --git a/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php b/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php index 0c11e4186b..0bfe334654 100644 --- a/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php +++ b/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php @@ -163,14 +163,15 @@ final class PhortuneWePayPaymentProvider extends PhortunePaymentProvider { 'funding_sources' => 'bank,cc' ); - $cart->willApplyCharge($viewer, $this); - + $charge = $cart->willApplyCharge($viewer, $this); $result = $wepay->request('checkout/create', $params); $cart->setMetadataValue('provider.checkoutURI', $result->checkout_uri); - $cart->setMetadataValue('wepay.checkoutID', $result->checkout_id); $cart->save(); + $charge->setMetadataValue('wepay.checkoutID', $result->checkout_id); + $charge->save(); + $uri = new PhutilURI($result->checkout_uri); return id(new AphrontRedirectResponse()) ->setIsExternal(true)