diff --git a/resources/celerity/map.php b/resources/celerity/map.php index e72424daf2..7ef90020e9 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -84,7 +84,7 @@ return array( 'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49', 'rsrc/css/application/pholio/pholio.css' => '47dffb9c', 'rsrc/css/application/phortune/phortune-credit-card-form.css' => 'b25b4beb', - 'rsrc/css/application/phortune/phortune.css' => '012360a6', + 'rsrc/css/application/phortune/phortune.css' => '9149f103', 'rsrc/css/application/phrequent/phrequent.css' => 'ffc185ad', 'rsrc/css/application/phriction/phriction-document-css.css' => '7d7f0071', 'rsrc/css/application/policy/policy-edit.css' => '05cca26a', @@ -767,7 +767,7 @@ return array( 'pholio-inline-comments-css' => '8e545e49', 'phortune-credit-card-form' => '2290aeef', 'phortune-credit-card-form-css' => 'b25b4beb', - 'phortune-css' => '012360a6', + 'phortune-css' => '9149f103', 'phrequent-css' => 'ffc185ad', 'phriction-document-css' => '7d7f0071', 'phui-action-header-view-css' => '83e2cc86', diff --git a/src/applications/phortune/controller/PhortuneCartCheckoutController.php b/src/applications/phortune/controller/PhortuneCartCheckoutController.php index bd2738e73d..b697e7ca4c 100644 --- a/src/applications/phortune/controller/PhortuneCartCheckoutController.php +++ b/src/applications/phortune/controller/PhortuneCartCheckoutController.php @@ -146,6 +146,13 @@ final class PhortuneCartCheckoutController $viewer); } + $one_time_options = phutil_tag( + 'div', + array( + 'class' => 'phortune-payment-onetime-list', + ), + $one_time_options); + $provider_form = new PHUIFormLayoutView(); $provider_form->appendChild( id(new AphrontFormMarkupControl()) diff --git a/src/applications/phortune/provider/PhortunePaymentProvider.php b/src/applications/phortune/provider/PhortunePaymentProvider.php index 23d90cab8b..09178446ec 100644 --- a/src/applications/phortune/provider/PhortunePaymentProvider.php +++ b/src/applications/phortune/provider/PhortunePaymentProvider.php @@ -181,7 +181,37 @@ abstract class PhortunePaymentProvider { PhortuneAccount $account, PhortuneCart $cart, PhabricatorUser $user) { - throw new PhortuneNotImplementedException($this); + + require_celerity_resource('phortune-css'); + + $icon_uri = $this->getPaymentMethodIcon(); + $description = $this->getPaymentMethodProviderDescription(); + $details = $this->getPaymentMethodDescription(); + + $icon = id(new PHUIIconView()) + ->setImage($icon_uri) + ->addClass('phortune-payment-icon'); + + $button = id(new PHUIButtonView()) + ->setSize(PHUIButtonView::BIG) + ->setColor(PHUIButtonView::GREY) + ->setIcon($icon) + ->setText($description) + ->setSubtext($details); + + $uri = $this->getControllerURI( + 'checkout', + array( + 'cartID' => $cart->getID(), + )); + + return phabricator_form( + $user, + array( + 'action' => $uri, + 'method' => 'POST', + ), + $button); } diff --git a/src/applications/phortune/provider/PhortunePaypalPaymentProvider.php b/src/applications/phortune/provider/PhortunePaypalPaymentProvider.php index ad55a4e32b..b2b9efd690 100644 --- a/src/applications/phortune/provider/PhortunePaypalPaymentProvider.php +++ b/src/applications/phortune/provider/PhortunePaypalPaymentProvider.php @@ -17,18 +17,17 @@ final class PhortunePaypalPaymentProvider extends PhortunePaymentProvider { } public function getPaymentMethodDescription() { - return 'Paypal Account'; + return pht('Credit Card or Paypal Account'); } public function getPaymentMethodIcon() { - return 'rsrc/phortune/paypal.png'; + return celerity_get_resource_uri('rsrc/image/phortune/paypal.png'); } public function getPaymentMethodProviderDescription() { return 'Paypal'; } - public function canHandlePaymentMethod(PhortunePaymentMethod $method) { $type = $method->getMetadataValue('type'); return ($type == 'paypal'); @@ -58,33 +57,6 @@ final class PhortunePaypalPaymentProvider extends PhortunePaymentProvider { return true; } - public function renderOneTimePaymentButton( - PhortuneAccount $account, - PhortuneCart $cart, - PhabricatorUser $user) { - - $uri = $this->getControllerURI( - 'checkout', - array( - 'cartID' => $cart->getID(), - )); - - return phabricator_form( - $user, - array( - 'action' => $uri, - 'method' => 'POST', - ), - phutil_tag( - 'button', - array( - 'class' => 'green', - 'type' => 'submit', - ), - pht('Pay with Paypal'))); - } - - /* -( Controllers )-------------------------------------------------------- */ diff --git a/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php b/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php index 0295f31256..ea3ad1b548 100644 --- a/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php +++ b/src/applications/phortune/provider/PhortuneWePayPaymentProvider.php @@ -22,14 +22,13 @@ final class PhortuneWePayPaymentProvider extends PhortunePaymentProvider { } public function getPaymentMethodIcon() { - return 'rsrc/phortune/wepay.png'; + return celerity_get_resource_uri('/rsrc/image/phortune/wepay.png'); } public function getPaymentMethodProviderDescription() { return 'WePay'; } - public function canHandlePaymentMethod(PhortunePaymentMethod $method) { $type = $method->getMetadataValue('type'); return ($type == 'wepay'); @@ -64,32 +63,6 @@ final class PhortuneWePayPaymentProvider extends PhortunePaymentProvider { return true; } - public function renderOneTimePaymentButton( - PhortuneAccount $account, - PhortuneCart $cart, - PhabricatorUser $user) { - - $uri = $this->getControllerURI( - 'checkout', - array( - 'cartID' => $cart->getID(), - )); - - return phabricator_form( - $user, - array( - 'action' => $uri, - 'method' => 'POST', - ), - phutil_tag( - 'button', - array( - 'class' => 'green', - 'type' => 'submit', - ), - pht('Pay with WePay'))); - } - /* -( Controllers )-------------------------------------------------------- */ diff --git a/src/applications/phortune/query/PhortunePaymentMethodQuery.php b/src/applications/phortune/query/PhortunePaymentMethodQuery.php index e165363380..e151bb9178 100644 --- a/src/applications/phortune/query/PhortunePaymentMethodQuery.php +++ b/src/applications/phortune/query/PhortunePaymentMethodQuery.php @@ -47,6 +47,15 @@ final class PhortunePaymentMethodQuery } protected function willFilterPage(array $methods) { + foreach ($methods as $key => $method) { + try { + $method->buildPaymentProvider(); + } catch (Exception $ex) { + unset($methods[$key]); + continue; + } + } + $accounts = id(new PhortuneAccountQuery()) ->setViewer($this->getViewer()) ->withPHIDs(mpull($methods, 'getAccountPHID')) diff --git a/src/applications/phortune/storage/PhortunePaymentMethod.php b/src/applications/phortune/storage/PhortunePaymentMethod.php index be71203c98..16296fb660 100644 --- a/src/applications/phortune/storage/PhortunePaymentMethod.php +++ b/src/applications/phortune/storage/PhortunePaymentMethod.php @@ -48,7 +48,8 @@ final class PhortunePaymentMethod extends PhortuneDAO } public function getDescription() { - return '...'; + $provider = $this->buildPaymentProvider(); + return $provider->getPaymentMethodProviderDescription(); } public function getMetadataValue($key, $default = null) { diff --git a/webroot/rsrc/css/application/phortune/phortune.css b/webroot/rsrc/css/application/phortune/phortune.css index e01e3e49c9..10ddf2c245 100644 --- a/webroot/rsrc/css/application/phortune/phortune.css +++ b/webroot/rsrc/css/application/phortune/phortune.css @@ -15,3 +15,12 @@ margin: 4px 0; width: 100%; } + +.phortune-payment-onetime-list { + width: 280px; +} + +.phortune-payment-onetime-list button { + margin: 0 0 8px 0; + width: 100%; +}