Page MenuHomePhabricator

D10640.id.diff
No OneTemporary

D10640.id.diff

diff --git a/src/applications/phortune/provider/PhortuneStripePaymentProvider.php b/src/applications/phortune/provider/PhortuneStripePaymentProvider.php
--- a/src/applications/phortune/provider/PhortuneStripePaymentProvider.php
+++ b/src/applications/phortune/provider/PhortuneStripePaymentProvider.php
@@ -39,6 +39,7 @@
/**
* @phutil-external-symbol class Stripe_Charge
+ * @phutil-external-symbol class Stripe_CardError
*/
protected function executeCharge(
PhortunePaymentMethod $method,
@@ -58,13 +59,20 @@
'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
--- a/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php
+++ b/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php
@@ -163,14 +163,15 @@
'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)

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 12:50 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6284238
Default Alt Text
D10640.id.diff (2 KB)

Event Timeline