2013-04-25 18:45:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhortuneTestPaymentProvider extends PhortunePaymentProvider {
|
|
|
|
|
2013-04-25 18:46:32 +02:00
|
|
|
public function isEnabled() {
|
2013-04-25 18:50:08 +02:00
|
|
|
return PhabricatorEnv::getEnvConfig('phortune.test.enabled');
|
2013-04-25 18:46:32 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 23:41:41 +02:00
|
|
|
public function getName() {
|
|
|
|
return pht('Test Payments');
|
2013-04-25 18:46:32 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 23:41:41 +02:00
|
|
|
public function getConfigureName() {
|
|
|
|
return pht('Test Payments');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getConfigureDescription() {
|
|
|
|
return pht(
|
|
|
|
'Adds a test provider to allow you to test payments. This allows '.
|
|
|
|
'users to make purchases by clicking a button without actually paying '.
|
|
|
|
'any money.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getConfigureInstructions() {
|
|
|
|
return pht('This providers does not require any special configuration.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canRunConfigurationTest() {
|
|
|
|
return false;
|
2013-04-25 18:46:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaymentMethodDescription() {
|
|
|
|
return pht('Add Mountain of Virtual Wealth');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaymentMethodIcon() {
|
2014-10-08 00:07:01 +02:00
|
|
|
return 'TestPayment';
|
2013-04-25 18:46:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaymentMethodProviderDescription() {
|
|
|
|
return pht('Infinite Free Money');
|
|
|
|
}
|
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
public function getDefaultPaymentMethodDisplayName(
|
|
|
|
PhortunePaymentMethod $method) {
|
|
|
|
return pht('Vast Wealth');
|
|
|
|
}
|
|
|
|
|
2013-04-25 18:45:43 +02:00
|
|
|
protected function executeCharge(
|
|
|
|
PhortunePaymentMethod $payment_method,
|
|
|
|
PhortuneCharge $charge) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-07 23:41:41 +02:00
|
|
|
public function getAllConfigurableProperties() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAllConfigurableSecretProperties() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processEditForm(
|
|
|
|
AphrontRequest $request,
|
|
|
|
array $values) {
|
|
|
|
|
|
|
|
$errors = array();
|
|
|
|
$issues = array();
|
|
|
|
$values = array();
|
|
|
|
|
|
|
|
return array($errors, $issues, $values);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function extendEditForm(
|
|
|
|
AphrontRequest $request,
|
|
|
|
AphrontFormView $form,
|
|
|
|
array $values,
|
|
|
|
array $issues) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-25 18:50:08 +02:00
|
|
|
|
|
|
|
/* -( Adding Payment Methods )--------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function canCreatePaymentMethods() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function translateCreatePaymentMethodErrorCode($error_code) {
|
|
|
|
return $error_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getCreatePaymentMethodErrorMessage($error_code) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function validateCreatePaymentMethodToken(array $token) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function createPaymentMethodFromRequest(
|
|
|
|
AphrontRequest $request,
|
|
|
|
PhortunePaymentMethod $method,
|
|
|
|
array $token) {
|
|
|
|
|
|
|
|
$method
|
|
|
|
->setExpires('2050', '01')
|
|
|
|
->setBrand('FreeMoney')
|
2014-08-11 21:07:35 +02:00
|
|
|
->setLastFourDigits('9999')
|
|
|
|
->setMetadata(
|
|
|
|
array(
|
|
|
|
'type' => 'test.wealth',
|
|
|
|
));
|
2013-04-25 18:50:08 +02:00
|
|
|
|
2014-08-11 21:07:35 +02:00
|
|
|
return array();
|
2013-04-25 18:50:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @task addmethod
|
|
|
|
*/
|
|
|
|
public function renderCreatePaymentMethodForm(
|
|
|
|
AphrontRequest $request,
|
|
|
|
array $errors) {
|
|
|
|
|
|
|
|
$ccform = id(new PhortuneCreditCardForm())
|
|
|
|
->setUser($request->getUser())
|
|
|
|
->setErrors($errors);
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'test-payment-form',
|
|
|
|
array(
|
|
|
|
'formID' => $ccform->getFormID(),
|
|
|
|
));
|
|
|
|
|
|
|
|
return $ccform->buildForm();
|
|
|
|
}
|
2013-04-25 18:45:43 +02:00
|
|
|
}
|