|
| 1 | +<?php |
| 2 | + |
| 3 | +final class PhortuneAccountBuyController |
| 4 | + extends PhortuneController { |
| 5 | + |
| 6 | + private $accountID; |
| 7 | + private $id; |
| 8 | + |
| 9 | + public function willProcessRequest(array $data) { |
| 10 | + $this->accountID = $data['accountID']; |
| 11 | + $this->id = $data['id']; |
| 12 | + } |
| 13 | + |
| 14 | + public function processRequest() { |
| 15 | + $request = $this->getRequest(); |
| 16 | + $user = $request->getUser(); |
| 17 | + |
| 18 | + $account = id(new PhortuneAccountQuery()) |
| 19 | + ->setViewer($user) |
| 20 | + ->withIDs(array($this->accountID)) |
| 21 | + ->executeOne(); |
| 22 | + if (!$account) { |
| 23 | + return new Aphront404Response(); |
| 24 | + } |
| 25 | + |
| 26 | + $account_uri = $this->getApplicationURI($account->getID().'/'); |
| 27 | + |
| 28 | + $product = id(new PhortuneProductQuery()) |
| 29 | + ->setViewer($user) |
| 30 | + ->withIDs(array($this->id)) |
| 31 | + ->executeOne(); |
| 32 | + if (!$product) { |
| 33 | + return new Aphront404Response(); |
| 34 | + } |
| 35 | + |
| 36 | + $title = pht('Buy %s', $product->getProductName()); |
| 37 | + |
| 38 | + $payment_method_uri = $this->getApplicationURI( |
| 39 | + $account->getID().'/paymentmethod/edit/'); |
| 40 | + |
| 41 | + $new_method = phutil_tag( |
| 42 | + 'a', |
| 43 | + array( |
| 44 | + 'href' => $payment_method_uri, |
| 45 | + 'sigil' => 'workflow', |
| 46 | + ), |
| 47 | + pht('Add New Payment Method')); |
| 48 | + |
| 49 | + |
| 50 | + $form = id(new AphrontFormView()) |
| 51 | + ->setUser($user) |
| 52 | + ->appendChild( |
| 53 | + id(new AphrontFormStaticControl()) |
| 54 | + ->setLabel(pht('Stuff')) |
| 55 | + ->setValue($product->getProductName())) |
| 56 | + ->appendChild( |
| 57 | + id(new AphrontFormRadioButtonControl()) |
| 58 | + ->setLabel(pht('Payment Method'))) |
| 59 | + ->appendChild( |
| 60 | + id(new AphrontFormMarkupControl()) |
| 61 | + ->setValue($new_method)) |
| 62 | + ->appendChild( |
| 63 | + id(new AphrontFormSubmitControl()) |
| 64 | + ->setValue(pht("Dolla Dolla Bill Y'all"))); |
| 65 | + |
| 66 | + return $this->buildApplicationPage( |
| 67 | + $form, |
| 68 | + array( |
| 69 | + 'title' => $title, |
| 70 | + 'device' => true, |
| 71 | + 'dust' => true, |
| 72 | + )); |
| 73 | + |
| 74 | + } |
| 75 | +} |
0 commit comments