mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Give Stripe complete payment workflow logic in Phortune
Summary: Ref T2787. This basically already works correctly since the hard logic is external to the provider on API providers. Tweak a couple of things. Failures still just fail the cart completely, for now. Test Plan: Completed a charge with Stripe. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2787 Differential Revision: https://secure.phabricator.com/D10640
This commit is contained in:
parent
4ef547f8d6
commit
83e1a1ddb2
2 changed files with 13 additions and 4 deletions
|
@ -39,6 +39,7 @@ final class PhortuneStripePaymentProvider extends PhortunePaymentProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phutil-external-symbol class Stripe_Charge
|
* @phutil-external-symbol class Stripe_Charge
|
||||||
|
* @phutil-external-symbol class Stripe_CardError
|
||||||
*/
|
*/
|
||||||
protected function executeCharge(
|
protected function executeCharge(
|
||||||
PhortunePaymentMethod $method,
|
PhortunePaymentMethod $method,
|
||||||
|
@ -58,13 +59,20 @@ final class PhortuneStripePaymentProvider extends PhortunePaymentProvider {
|
||||||
'capture' => true,
|
'capture' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
$stripe_charge = Stripe_Charge::create($params, $secret_key);
|
$stripe_charge = Stripe_Charge::create($params, $secret_key);
|
||||||
|
} catch (Stripe_CardError $ex) {
|
||||||
|
// TODO: Fail charge explicitly.
|
||||||
|
throw $ex;
|
||||||
|
}
|
||||||
|
|
||||||
$id = $stripe_charge->id;
|
$id = $stripe_charge->id;
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
throw new Exception('Stripe charge call did not return an ID!');
|
throw new Exception('Stripe charge call did not return an ID!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$charge->setMetadataValue('stripe.chargeID', $id);
|
$charge->setMetadataValue('stripe.chargeID', $id);
|
||||||
|
$charge->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPublishableKey() {
|
private function getPublishableKey() {
|
||||||
|
|
|
@ -163,14 +163,15 @@ final class PhortuneWePayPaymentProvider extends PhortunePaymentProvider {
|
||||||
'funding_sources' => 'bank,cc'
|
'funding_sources' => 'bank,cc'
|
||||||
);
|
);
|
||||||
|
|
||||||
$cart->willApplyCharge($viewer, $this);
|
$charge = $cart->willApplyCharge($viewer, $this);
|
||||||
|
|
||||||
$result = $wepay->request('checkout/create', $params);
|
$result = $wepay->request('checkout/create', $params);
|
||||||
|
|
||||||
$cart->setMetadataValue('provider.checkoutURI', $result->checkout_uri);
|
$cart->setMetadataValue('provider.checkoutURI', $result->checkout_uri);
|
||||||
$cart->setMetadataValue('wepay.checkoutID', $result->checkout_id);
|
|
||||||
$cart->save();
|
$cart->save();
|
||||||
|
|
||||||
|
$charge->setMetadataValue('wepay.checkoutID', $result->checkout_id);
|
||||||
|
$charge->save();
|
||||||
|
|
||||||
$uri = new PhutilURI($result->checkout_uri);
|
$uri = new PhutilURI($result->checkout_uri);
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setIsExternal(true)
|
->setIsExternal(true)
|
||||||
|
|
Loading…
Reference in a new issue