@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow PhortuneTestProvider to add payment methods

Summary: Provide a bare implementation so that you can add PhortuneTestProvider as a payment method. Ref 2787.

Test Plan: Added "cards" through the test provider.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D5772

+109 -1
+12
src/__celerity_resource_map__.php
··· 2280 2280 ), 2281 2281 'disk' => '/rsrc/js/application/phortune/behavior-stripe-payment-form.js', 2282 2282 ), 2283 + 'javelin-behavior-test-payment-form' => 2284 + array( 2285 + 'uri' => '/res/a8fe8616/rsrc/js/application/phortune/behavior-test-payment-form.js', 2286 + 'type' => 'js', 2287 + 'requires' => 2288 + array( 2289 + 0 => 'javelin-behavior', 2290 + 1 => 'javelin-dom', 2291 + 2 => 'phortune-credit-card-form', 2292 + ), 2293 + 'disk' => '/rsrc/js/application/phortune/behavior-test-payment-form.js', 2294 + ), 2283 2295 'javelin-behavior-toggle-class' => 2284 2296 array( 2285 2297 'uri' => '/res/79921b7f/rsrc/js/core/behavior-toggle-class.js',
+15
src/applications/phortune/option/PhabricatorPhortuneConfigOptions.php
··· 25 25 $this->newOption('phortune.balanced.secret-key', 'string', null) 26 26 ->setHidden(true) 27 27 ->setDescription(pht('Balanced secret key.')), 28 + $this->newOption('phortune.test.enabled', 'bool', false) 29 + ->setBoolOptions( 30 + array( 31 + pht('Enable Test Provider'), 32 + pht('Disable Test Provider'), 33 + )) 34 + ->setSummary(pht('Enable test payment provider.')) 35 + ->setDescription( 36 + pht( 37 + "Enable the test payment provider.\n\n". 38 + "NOTE: Enabling this provider gives all users infinite free ". 39 + "money! You should enable it **ONLY** for testing and ". 40 + "development.")) 41 + ->setLocked(true) 42 + 28 43 ); 29 44 } 30 45
+57 -1
src/applications/phortune/provider/PhortuneTestPaymentProvider.php
··· 3 3 final class PhortuneTestPaymentProvider extends PhortunePaymentProvider { 4 4 5 5 public function isEnabled() { 6 - return true; 6 + return PhabricatorEnv::getEnvConfig('phortune.test.enabled'); 7 7 } 8 8 9 9 public function getProviderType() { ··· 37 37 return; 38 38 } 39 39 40 + 41 + /* -( Adding Payment Methods )--------------------------------------------- */ 42 + 43 + 44 + public function canCreatePaymentMethods() { 45 + return true; 46 + } 47 + 48 + 49 + public function translateCreatePaymentMethodErrorCode($error_code) { 50 + return $error_code; 51 + } 52 + 53 + 54 + public function getCreatePaymentMethodErrorMessage($error_code) { 55 + return null; 56 + } 57 + 58 + 59 + public function validateCreatePaymentMethodToken(array $token) { 60 + return true; 61 + } 62 + 63 + 64 + public function createPaymentMethodFromRequest( 65 + AphrontRequest $request, 66 + PhortunePaymentMethod $method, 67 + array $token) { 68 + 69 + $method 70 + ->setExpires('2050', '01') 71 + ->setBrand('FreeMoney') 72 + ->setLastFourDigits('9999'); 73 + 74 + } 75 + 76 + 77 + /** 78 + * @task addmethod 79 + */ 80 + public function renderCreatePaymentMethodForm( 81 + AphrontRequest $request, 82 + array $errors) { 83 + 84 + $ccform = id(new PhortuneCreditCardForm()) 85 + ->setUser($request->getUser()) 86 + ->setErrors($errors); 87 + 88 + Javelin::initBehavior( 89 + 'test-payment-form', 90 + array( 91 + 'formID' => $ccform->getFormID(), 92 + )); 93 + 94 + return $ccform->buildForm(); 95 + } 40 96 }
+6
src/applications/phortune/provider/__tests__/PhortunePaymentProviderTestCase.php
··· 9 9 } 10 10 11 11 public function testNoPaymentProvider() { 12 + $env = PhabricatorEnv::beginScopedEnv(); 13 + $env->overrideEnvConfig('phortune.test.enabled', true); 14 + 12 15 $method = id(new PhortunePaymentMethod()) 13 16 ->setMetadataValue('type', 'hugs'); 14 17 ··· 26 29 } 27 30 28 31 public function testMultiplePaymentProviders() { 32 + $env = PhabricatorEnv::beginScopedEnv(); 33 + $env->overrideEnvConfig('phortune.test.enabled', true); 34 + 29 35 $method = id(new PhortunePaymentMethod()) 30 36 ->setMetadataValue('type', 'test.multiple'); 31 37
+19
webroot/rsrc/js/application/phortune/behavior-test-payment-form.js
··· 1 + /** 2 + * @provides javelin-behavior-test-payment-form 3 + * @requires javelin-behavior 4 + * javelin-dom 5 + * phortune-credit-card-form 6 + */ 7 + 8 + JX.behavior('test-payment-form', function(config) { 9 + var ccform = new JX.PhortuneCreditCardForm(JX.$(config.formID), onsubmit); 10 + 11 + function onsubmit(card_data) { 12 + onresponse(); 13 + } 14 + 15 + function onresponse() { 16 + ccform.submitForm([], {test: true}); 17 + } 18 + 19 + });