Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230253
Change subject: Clear out old Amazon code to prepare for PwA
......................................................................
Clear out old Amazon code to prepare for PwA
Sun is setting on simple payments, so we can ditch most of what
we had. Pay with Amazon will require a lot less code!
Remove old forms and settings and most of adapter code.
Switch to Mustache renderer and add a skeletal Amazon partial.
Set "is_{$payment_method}" in mustache context, not just is_cc
Add placeholder css and js modules
Bug: T108112
Change-Id: I621db21ded4cc91aed5426026830c7e94ac1bfb9
---
M DonationInterface.php
M DonationInterfaceFormSettings.php
M amazon_gateway/amazon.adapter.php
A amazon_gateway/amazon.css
A amazon_gateway/amazon.js
M amazon_gateway/amazon_gateway.body.php
D amazon_gateway/forms/html/amazon-recurring.html
D amazon_gateway/forms/html/amazon.html
M gateway_forms/Mustache.php
A gateway_forms/mustache/amazon_payment.html.mustache
M gateway_forms/mustache/index.html.mustache
11 files changed, 74 insertions(+), 599 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/53/230253/1
diff --git a/DonationInterface.php b/DonationInterface.php
index b77d594..327435f 100644
--- a/DonationInterface.php
+++ b/DonationInterface.php
@@ -292,30 +292,17 @@
'' => 100, //No code returned. All the points.
);
-
-//n.b. "-Testing-" urls are not wired to anything, they're just here for
-// your copy n paste pleasure.
-
-$wgAmazonGatewayURL = "https://authorize.payments.amazon.com/pba/paypipeline";
-$wgAmazonGatewayTestingURL =
"https://authorize.payments-sandbox.amazon.com/pba/paypipeline";
-
-$wgAmazonGatewayFpsURL = "https://fps.amazonaws.com/";
-$wgAmazonGatewayFpsTestingURL = "https://fps.sandbox.amazonaws.com/";
-
# $wgAmazonGatewayAccountInfo['example'] = array(
-# 'AccessKey' => "",
-# 'SecretKey' => "",
-#
-# // the long one, not the AWS account ID
-# 'PaymentsAccountID' => "",
+# 'SellerID' => '',
+# 'ClientID' => '',
+# 'ClientSecret' => '',
+# 'MWSAccessKey' => '',
+# 'MWSSecretKey' => '',
+# 'Region' => '',
# );
-// e.g. http://payments.wikimedia.org/index.php/Special:AmazonGateway --
-// does NOT accept unroutable development names, use the number instead
-// even if it's 127.0.0.1
+// e.g. http://payments.wikimedia.org/index.php/Special:AmazonGateway
$wgAmazonGatewayReturnURL = "";
-
-$wgAmazonGatewayHtmlFormDir = __DIR__ . '/amazon_gateway/forms/html';
$wgPaypalGatewayURL = 'https://www.paypal.com/cgi-bin/webscr';
$wgPaypalGatewayTestingURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
@@ -868,6 +855,20 @@
'remoteExtPath' => 'DonationInterface/gateway_forms/mustache'
);
+$wgResourceModules['ext.donationinterface.amazon.styles'] = array(
+ 'styles' => 'amazon.css',
+ 'localBasePath' => __DIR__ . '/amazon_gateway',
+ 'remoteExtPath' => 'DonationInterface/amazon_gateway',
+ 'position' => 'top',
+);
+
+$wgResourceModules['ext.donationinterface.amazon.code'] = array(
+ 'scripts' => 'amazon.js',
+ 'localBasePath' => __DIR__ . '/amazon_gateway',
+ 'remoteExtPath' => 'DonationInterface/amazon_gateway',
+ 'position' => 'bottom',
+);
+
// load any rapidhtml related resources
require_once( __DIR__ . '/gateway_forms/rapidhtml/RapidHtmlResources.php' );
@@ -986,7 +987,6 @@
*/
$wgDonationInterfaceFormDirs = array(
'adyen' => $wgAdyenGatewayHtmlFormDir,
- 'amazon' => $wgAmazonGatewayHtmlFormDir,
'default' => $wgDonationInterfaceHtmlFormDir,
'gc' => $wgGlobalCollectGatewayHtmlFormDir,
'paypal' => $wgPaypalGatewayHtmlFormDir,
diff --git a/DonationInterfaceFormSettings.php
b/DonationInterfaceFormSettings.php
index 84a5f0d..da65e46 100644
--- a/DonationInterfaceFormSettings.php
+++ b/DonationInterfaceFormSettings.php
@@ -7,21 +7,19 @@
$forms_whitelist = array();
$form_dirs = $wgDonationInterfaceFormDirs;
-/**********
- * Amazon *
- **********/
+/*
+ * Amazon dummy config - see AstroPay
+ */
$forms_whitelist['amazon'] = array(
- 'file' => $form_dirs['amazon'] . '/amazon.html',
+ 'file' => __DIR__ . '/gateway_forms/mustache/index.html.mustache',
'gateway' => 'amazon',
'payment_methods' => array('amazon' => 'ALL'),
- 'redirect',
);
$forms_whitelist['amazon-recurring'] = array(
- 'file' => $form_dirs['amazon'] . '/amazon-recurring.html',
+ 'file' => __DIR__ . '/gateway_forms/mustache/index.html.mustache',
'gateway' => 'amazon',
'payment_methods' => array('amazon' => 'ALL'),
- 'redirect',
'recurring',
);
diff --git a/amazon_gateway/amazon.adapter.php
b/amazon_gateway/amazon.adapter.php
index 4fb7a5a77..558da2b 100644
--- a/amazon_gateway/amazon.adapter.php
+++ b/amazon_gateway/amazon.adapter.php
@@ -34,10 +34,15 @@
}
}
- public function getCommunicationType() {
- if ( $this->transaction_option( 'redirect' ) ) {
- return 'redirect';
+ public function getFormClass() {
+ if ( strpos( $this->dataObj->getVal_Escaped( 'ffname' ),
'error') === 0 ) {
+ // TODO: make a mustache error form
+ return parent::getFormClass();
}
+ return 'Gateway_Form_Mustache';
+ }
+
+ public function getCommunicationType() {
return 'xml';
}
@@ -71,7 +76,14 @@
'generate' => TRUE,
);
}
- function setGatewayDefaults() {}
+
+ function setGatewayDefaults() {
+ $this->addRequestData( array(
+ 'client_id' => $this->account_config['ClientID'],
+ 'seller_id' => $this->account_config['SellerID'],
+ 'sandbox' => $this->getGlobal( 'TestMode' ) ? 'true' :
'false',
+ ) );
+ }
public function defineErrorMap() {
@@ -85,98 +97,6 @@
function defineTransactions() {
$this->transactions = array();
- $this->transactions[ 'Donate' ] = array(
- 'request' => array(
- 'accessKey',
- 'amount',
- 'collectShippingAddress',
- 'description',
- 'immediateReturn',
- 'ipnUrl',
- 'returnUrl',
- 'isDonationWidget',
- 'processImmediate',
- 'referenceId',
- //'signature',
- 'signatureMethod',
- 'signatureVersion',
- ),
- 'values' => array(
- 'accessKey' => $this->account_config[
'AccessKey' ],
- 'collectShippingAddress' => '0',
- 'description' => WmfFramework::formatMessage(
'donate_interface-donation-description' ),
- 'immediateReturn' => '1',
- 'ipnUrl' =>
$this->account_config['IpnOverride'],
- 'isDonationWidget' => '1',
- 'processImmediate' => '1',
- 'signatureMethod' => 'HmacSHA256',
- 'signatureVersion' => '2',
- ),
- 'redirect' => TRUE,
- );
-
- $this->transactions[ 'DonateMonthly' ] = array(
- 'request' => array(
- 'accessKey',
- 'amount',
- 'collectShippingAddress',
- 'description',
- 'immediateReturn',
- 'ipnUrl',
- 'processImmediate',
- 'recurringFrequency',
- 'referenceId',
- 'returnUrl',
- //'signature',
- 'signatureMethod',
- 'signatureVersion',
- //'subscriptionPeriod',
- ),
- 'values' => array(
- // FIXME: There is magick available if the
names match.
- 'accessKey' => $this->account_config[
'AccessKey' ],
- 'collectShippingAddress' => '0',
- 'description' => WmfFramework::formatMessage(
'donate_interface-monthly-donation-description' ),
- 'immediateReturn' => '1',
- 'ipnUrl' =>
$this->account_config['IpnOverride'],
- 'processImmediate' => '1',
- 'recurringFrequency' => "1 month",
- 'signatureMethod' => "HmacSHA256",
- 'signatureVersion' => "2",
- // FIXME: this is the documented default, but
passing it explicitly is buggy
- //'subscriptionPeriod' => "forever",
- ),
- 'redirect' => TRUE,
- );
-
- $this->transactions[ 'VerifySignature' ] = array(
- 'request' => array(
- 'Action',
- 'HttpParameters',
- 'UrlEndPoint',
- 'Version',
- //'Signature',
- 'SignatureMethod',
- 'SignatureVersion',
- 'AWSAccessKeyId',
- 'Timestamp',
- ),
- 'values' => array(
- 'Action' => "VerifySignature",
- 'AWSAccessKeyId' => $this->account_config[
'AccessKey' ],
- 'UrlEndPoint' => $this->getGlobal( "ReturnURL"
),
- 'Version' => "2010-08-28",
- 'SignatureMethod' => "HmacSHA256",
- 'SignatureVersion' => "2",
- 'Timestamp' => date( 'c' ),
- ),
- 'url' => $this->getGlobal( "FpsURL" ),
- );
-
- $this->transactions[ 'ProcessAmazonReturn' ] = array(
- 'request' => array(),
- 'values' => array(),
- );
}
public function definePaymentMethods() {
@@ -210,92 +130,6 @@
);
}
- function do_transaction( $transaction ) {
- global $wgRequest, $wgOut;
- $this->session_addDonorData();
-
- $this->setCurrentTransaction( $transaction );
- $this->transaction_response = new PaymentTransactionResponse();
-
- $override_url = $this->transaction_option( 'url' );
- if ( !empty( $override_url ) ) {
- $this->url = $override_url;
- }
- else {
- $this->url = $this->getGlobal( "URL" );
- }
-
- switch ( $transaction ) {
- case 'Donate':
- case 'DonateMonthly':
- $return_url = $this->getGlobal( 'ReturnURL' );
- //check if ReturnURL already has a query string
- $return_query = parse_url( $return_url, PHP_URL_QUERY );
- $return_url .= ( $return_query ? '&' : '?' );
- $return_url .=
"ffname=amazon&order_id={$this->getData_Unstaged_Escaped( 'order_id' )}";
- $this->transactions[ $transaction ][ 'values' ][
'returnUrl' ] = $return_url;
- break;
- case 'VerifySignature':
- $request_params = $wgRequest->getValues();
- unset( $request_params[ 'title' ] );
- $incoming = http_build_query( $request_params, '', '&'
);
- $this->transactions[ $transaction ][ 'values' ][
'HttpParameters' ] = $incoming;
- $this->logger->debug( "received callback from amazon
with: $incoming" );
- break;
- }
-
- // TODO this will move to a staging function once FR#507 is
deployed
- $query = $this->buildRequestParams();
- $parsed_uri = parse_url( $this->url );
- $signature = $this->signRequest( $parsed_uri[ 'host' ],
$parsed_uri[ 'path' ], $query );
-
- switch ( $transaction ) {
- case 'Donate':
- case 'DonateMonthly':
- $query_str = $this->encodeQuery( $query );
- $this->logger->debug( "At $transaction,
redirecting with query string: $query_str" );
-
- //always have to do this before a redirect.
- $this->dataObj->saveContributionTrackingData();
-
- //@TODO: This shouldn't be happening here. Oh
Amazon... Why can't you be more like PayPalAdapter?
- $wgOut->redirect("{$this->getGlobal( "URL"
)}?{$query_str}&signature={$signature}");
- break;
-
- case 'VerifySignature':
- // We don't currently use this. In fact we just
ignore the return URL signature.
- // However, it's perfectly good code and we may
go back to using it at some point
- // so I didn't want to remove it.
- $query_str = $this->encodeQuery( $query );
- $this->url .=
"?{$query_str}&Signature={$signature}";
-
- $this->logger->debug( "At $transaction, query
string: $query_str" );
-
- parent::do_transaction( $transaction );
-
- if ( $this->getFinalStatus() ===
FinalStatus::COMPLETE ) {
- $this->unstaged_data =
$this->dataObj->getDataEscaped(); // XXX not cool.
- $this->runPostProcessHooks();
- $this->doLimboStompTransaction( true );
- $this->deleteLimboMessage();
- }
- break;
-
- case 'ProcessAmazonReturn':
- // What we need to do here is make sure THE WHAT
- // FIXME: This is resultswitcher logic.
- $this->addDataFromURI();
- $this->analyzeReturnStatus();
- break;
-
- default:
- $this->logger->critical( "At $transaction; THIS
IS NOT DEFINED!" );
- $this->finalizeInternalStatus(
FinalStatus::FAILED );
- }
-
- return $this->transaction_response;
- }
-
static function getCurrencies() {
// See
https://payments.amazon.com/sdui/sdui/about?nodeId=73479#feat_countries
return array(
@@ -304,153 +138,10 @@
}
/**
- * Looks at the 'status' variable in the amazon return URL get string
and places the data
- * in the appropriate Final Status and sends to STOMP.
- */
- protected function analyzeReturnStatus() {
- // We only want to analyze this if we don't already have a
Final Status... Therefore we
- // won't overwrite things.
- if ( $this->getFinalStatus() === false ) {
-
- $txnid = $this->dataObj->getVal_Escaped(
'gateway_txn_id' );
- $this->transaction_response->setGatewayTransactionId(
$txnid );
-
- // Second make sure that the inbound request had a
matching outbound session. If it
- // doesn't we drop it.
- if ( !self::session_hasDonorData( 'order_id',
$this->getData_Unstaged_Escaped( 'order_id' ) ) ) {
-
- // We will however log it if we have a
seemingly valid transaction id
- if ( $txnid != null ) {
- $ctid =
$this->getData_Unstaged_Escaped( 'contribution_tracking_id' );
- $this->logger->alert( "$ctid failed
orderid verification but has txnid '$txnid'. Investigation required." );
- if ( $this->getGlobal(
'UseOrderIdValidation' ) ) {
- $this->finalizeInternalStatus(
FinalStatus::FAILED );
- return;
- }
- } else {
- $this->finalizeInternalStatus(
FinalStatus::FAILED );
- return;
- }
- }
-
- // Third: we did have an outbound request; so let's
look at what amazon is telling us
- // about the transaction.
- // todo: lots of other statuses we can interpret
- // see:
http://docs.amazonwebservices.com/AmazonSimplePay/latest/ASPAdvancedUserGuide/ReturnValueStatusCodes.html
- $this->logger->info( "Transaction $txnid returned with
status " . $this->dataObj->getVal_Escaped( 'gateway_status' ) );
- switch ( $this->dataObj->getVal_Escaped(
'gateway_status' ) ) {
- case 'PS': // Payment success
- $this->finalizeInternalStatus(
FinalStatus::COMPLETE );
- $this->doStompTransaction();
- break;
-
- case 'PI': // Payment initiated, it will
complete later
- $this->finalizeInternalStatus(
FinalStatus::PENDING );
- $this->doStompTransaction();
- break;
-
- case 'SS': // Subscription success --
processing handled by the IPN listener
- $this->finalizeInternalStatus(
FinalStatus::COMPLETE );
- break;
-
- case 'SI': // Subscription initiated --
processing handled by the IPN listener
- $this->finalizeInternalStatus(
FinalStatus::PENDING );
- break;
-
- case 'PF': // Payment failed
- case 'SF': // Subscription failed
- case 'SE': // This one is interesting; service
failure... can we do something here?
- default: // All other errorz
- $status =
$this->dataObj->getVal_Escaped( 'gateway_status' );
- $errString =
$this->dataObj->getVal_Escaped( 'error_message' );
- $this->logger->info( "Transaction
$txnid failed with ($status) $errString" );
- $this->finalizeInternalStatus(
FinalStatus::FAILED );
- break;
- }
- } else {
- $this->logger->error( 'Apparently we attempted to
process a transaction that already had a final status... Odd' );
- }
- }
-
- /**
- * Adds translated data from the URI string into donation data
- * FIXME: This should be done by unstaging functions.
- */
- function addDataFromURI() {
- global $wgRequest;
-
- // Obtain data parameters for STOMP message injection
- //n.b. these request vars were from the _previous_ api call
- $add_data = array();
- foreach ( $this->var_map as $gateway_key => $normal_key ) {
- $value = $wgRequest->getVal( $gateway_key, null );
- if ( !empty( $value ) ) {
- // Deal with some fun special cases
- switch ( $gateway_key ) {
- case 'transactionAmount':
- list ($currency, $amount) =
explode( ' ', $value );
- $add_data['currency'] =
$currency;
- $add_data['amount'] = $amount;
- break;
-
- case 'buyerName':
- list ($fname, $lname) =
explode( ' ', $value, 2 );
- $add_data['fname'] = $fname;
- $add_data['lname'] = $lname;
- break;
- case 'paymentMethod':
- $submethods = array (
- 'Credit Card' =>
'amazon_cc',
- 'Amazon Payments
Balance' => 'amazon_wallet',
- );
- if ( array_key_exists( $value,
$submethods ) ) {
-
$add_data['payment_submethod'] = $submethods[$value];
- } else {
- //We don't rely on this
anywhere serious, but I want to know about it anyway.
- $this->logger->error(
"Amazon just coughed up a surprise payment submethod of '$value'." );
-
$add_data['payment_submethod'] = 'unknown';
- }
- break;
- default:
- $add_data[ $normal_key ] =
$value;
- break;
- }
- }
- }
- //TODO: consider prioritizing the session vars
- $this->addResponseData( $add_data ); //using the gateway's
addData function restages everything
-
- $txnid = $this->dataObj->getVal_Escaped( 'gateway_txn_id' );
- $email = $this->dataObj->getVal_Escaped( 'email' );
-
- $this->logger->info( "Added data to session for txnid $txnid.
Now serving email $email." );
- }
-
- /**
- * We would call this function for the VerifySignature transaction, if
we
- * ever used that.
- * @param DomDocument $response
- * @throws ResponseProcessingException
+ * Don't need this if we use the SDK!
*/
public function processResponse( $response ) {
- $this->transaction_response->setErrors(
$this->parseResponseErrors( $response ) );
- if ( $this->getCurrentTransaction() !== 'VerifySignature' ) {
- return;
- }
- $statuses = $response->getElementsByTagName(
'VerificationStatus' );
- $verified = false;
- $commStatus = false;
- foreach ( $statuses as $node ) {
- $commStatus = true;
- if ( strtolower( $node->nodeValue ) == 'success' ) {
- $verified = true;
- }
- }
- $this->transaction_response->setCommunicationStatus(
$commStatus );
- if ( !$verified ) {
- $this->logger->info( "Transaction failed in response
data verification." );
- $this->finalizeInternalStatus( FinalStatus::FAILED );
- }
+
}
function encodeQuery( $params ) {
@@ -495,40 +186,6 @@
$opts[CURLOPT_CAPATH] = __DIR__ . "/ca-bundle.crt";
return $opts;
- }
-
- function parseResponseCommunicationStatus( $response ) {
- $aok = false;
-
- if ( $this->getCurrentTransaction() == 'VerifySignature' ) {
-
- foreach ( $response->getElementsByTagName(
'VerifySignatureResult' ) as $node ) {
- // All we care about is that the node exists
- $aok = true;
- }
- }
-
- return $aok;
- }
-
- // @todo FIXME: This doesn't go anywhere.
- function parseResponseErrors( $response ) {
- $errors = array( );
- foreach ( $response->getElementsByTagName( 'Error' ) as $node )
{
- $code = '';
- $message = '';
- foreach ( $node->childNodes as $childnode ) {
- if ( $childnode->nodeName === "Code" ) {
- $code = $childnode->nodeValue;
- }
- if ( $childnode->nodeName === "Message" ) {
- $message = $childnode->nodeValue;
- }
- // TODO: Convert to internal codes and
translate.
- // $errors[$code] = $message;
- }
- }
- return $errors;
}
/**
diff --git a/amazon_gateway/amazon.css b/amazon_gateway/amazon.css
new file mode 100644
index 0000000..fbd8c29
--- /dev/null
+++ b/amazon_gateway/amazon.css
@@ -0,0 +1,9 @@
+#walletWidget {
+ width: 400px;
+ height: 228px;
+}
+
+#consentWidget {
+ width: 400px;
+ height: 140px;
+}
diff --git a/amazon_gateway/amazon.js b/amazon_gateway/amazon.js
new file mode 100644
index 0000000..0461bca
--- /dev/null
+++ b/amazon_gateway/amazon.js
@@ -0,0 +1 @@
+// TODO: everything!
diff --git a/amazon_gateway/amazon_gateway.body.php
b/amazon_gateway/amazon_gateway.body.php
index b518e52..dc692e7 100644
--- a/amazon_gateway/amazon_gateway.body.php
+++ b/amazon_gateway/amazon_gateway.body.php
@@ -27,54 +27,14 @@
/**
* Show the special page
- *
- * @todo
- * - Finish error handling
*/
protected function handleRequest() {
$this->getOutput()->allowClickjacking();
$this->setHeaders();
+ $this->getOutput()->addModules(
'ext.donationinterface.amazon.styles' );
+ $this->getOutput()->addModules(
'ext.donationinterface.amazon.code' );
- if ( $this->validateForm() ) {
- $this->displayForm();
- } else {
- if ( $this->getRequest()->getText( 'redirect', 0 ) ) {
- if ( $this->getRequest()->getText( 'ffname',
'default' ) === 'amazon-recurring'
- || $this->getRequest()->getText(
'recurring', 0 )
- ) {
- // FIXME: do this in the form param
harvesting step
- $this->adapter->addRequestData( array(
- 'recurring' => 1,
- ) );
- }
- $this->adapter->doPayment();
- // TODO: move redirect here.
- return;
- }
-
- // TODO: move resultswitching out
- $this->logger->info( 'At gateway return with params: '
. json_encode( $this->getRequest()->getValues() ) );
- if ( $this->adapter->checkTokens() &&
$this->getRequest()->getText( 'status' ) ) {
- $this->adapter->do_transaction(
'ProcessAmazonReturn' );
-
- $status = $this->adapter->getFinalStatus();
-
- // FIXME: Isn't this why we have
$goToThankYouOn?
- if ( $status === FinalStatus::COMPLETE ||
$status === FinalStatus::PENDING ) {
- $this->getOutput()->redirect(
$this->adapter->getThankYouPage() );
- }
- else {
- $this->getOutput()->redirect(
$this->adapter->getFailPage() );
- }
- } else {
- $specialform = $this->getRequest()->getText(
'ffname', null );
- if ( !is_null( $specialform ) &&
$this->adapter->isValidSpecialForm( $specialform ) ){
- $this->displayForm();
- } else {
- $this->logger->error( 'Failed to
process gateway return. Tokens bad or no status.' );
- }
- }
- }
+ $this->displayForm();
}
}
diff --git a/amazon_gateway/forms/html/amazon-recurring.html
b/amazon_gateway/forms/html/amazon-recurring.html
deleted file mode 100644
index 90d549a..0000000
--- a/amazon_gateway/forms/html/amazon-recurring.html
+++ /dev/null
@@ -1,83 +0,0 @@
-<script type="text/javascript">
- mw.loader.load('basicDonationForm');
- // these must go through RapidHTML and thus are inline
- var amountErrors =
['#general|escape','#retryMsg|escape','#amount|escape'];
- var billingErrors = [];
- var paymentErrors = [];
- var actionURL = "@action";
- var scriptPath = "@script_path";
-</script>
-<style type="text/css">
-#selected-amount {
- font-size: larger;
- font-weight: bold;
-}
-</style>
-
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
- <tbody>
- <tr>
- <td id="appeal" valign="top">
- {{LanguageSwitch|2011FR/@appeal/text|@language}}
- </td>
- <td id="donate" valign="top">
- <div id="greenBackground" class="">
- @noscript
- <p id="topError"
class="creditcard-error-msg"></p>
-
- <form name="payment" method="post" action="@action">
- <div id="payment_gateway-personal-info">
- <table id="payment-table-donor">
- <tbody>
- <tr>
- <td colspan="2">
- <div
id="step1header">
- <h3
class="amount_header">%donate_interface-monthlybox-amount%</h3>
-
<p><input class="halfwidth" type="text" width="4" name="amount" value="@amount"
/> <span id="selected-amount">@currency_code</span></p>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <div
id="paymentContinue" style="margin-top: 10px;">
- <input
class="btn" id="paymentContinueBtn" type="button"
value="%donate_interface-continue%" />
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <input type="hidden" name="returnto"
value="Thank_You/en" />
- <input type="hidden" value="0"
name="PaypalRedirect" id="PaypalRedirect">
- <input type="hidden" value="@country"
name="country" id="country" />
- <input type="hidden" value="@currency_code"
name="currency_code" />
- <input type="hidden" value="@utm_source"
name="utm_source"/>
- <input type="hidden" value="@utm_medium"
name="utm_medium"/>
- <input type="hidden" value="@utm_campaign"
name="utm_campaign"/>
- <input type="hidden" value="@language"
name="language"/>
- <input type="hidden" value="@referrer"
name="referrer"/>
- <input type="hidden" value="1"
name="email-opt"/>
- <input type="hidden" value="@token"
name="token"/>
- <input type="hidden" value="@order_id"
name="order_id"/>
- <input type="hidden"
value="@contribution_tracking_id" name="contribution_tracking_id"/>
- <input type="hidden" value="@data_hash"
name="data_hash"/>
- <input type="hidden" value="@owa_session"
name="owa_session"/>
- <input type="hidden" value="@owa_ref"
name="owa_ref"/>
- <input type="hidden" value="@gateway"
name="gateway" />
- <input type="hidden" value="1"
name="recurring"/>
- <input type="hidden" value="1" name="redirect"/>
- </form>
- </div>
- <p
id="informationsharing">%donate_interface-informationsharing|url%</p>
- <table>
- <tr>
- <td>
- {% block moreinfolinks %}
- </td>
- <td>@verisign_logo</td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
-</table>
diff --git a/amazon_gateway/forms/html/amazon.html
b/amazon_gateway/forms/html/amazon.html
deleted file mode 100644
index 3550734..0000000
--- a/amazon_gateway/forms/html/amazon.html
+++ /dev/null
@@ -1,83 +0,0 @@
-<script type="text/javascript">
- mw.loader.load('basicDonationForm');
- // these must go through RapidHTML and thus are inline
- var amountErrors =
['#general|escape','#retryMsg|escape','#amount|escape'];
- var billingErrors = [];
- var paymentErrors = [];
- var actionURL = "@action";
- var scriptPath = "@script_path";
-</script>
-<style type="text/css">
-#selected-amount {
- font-size: larger;
- font-weight: bold;
-}
-</style>
-
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
- <tbody>
- <tr>
- <td id="appeal" valign="top">
- {{LanguageSwitch|2011FR/@appeal/text|@language}}
- </td>
- <td id="donate" valign="top">
- <div id="greenBackground" class="">
- @noscript
- <p id="topError"
class="creditcard-error-msg"></p>
-
- <form name="payment" method="post" action="@action">
- <div id="payment_gateway-personal-info">
- <table id="payment-table-donor">
- <tbody>
- <tr>
- <td colspan="2">
- <div
id="step1header">
- <h3
class="amount_header">%donate_interface-amount-legend%</h3>
-
<p><input class="halfwidth" type="text" width="4" name="amount" value="@amount"
/> <span id="selected-amount">@currency_code</span></p>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <div
id="paymentContinue" style="margin-top: 10px;">
- <input
class="btn" id="paymentContinueBtn" type="button"
value="%donate_interface-continue%" />
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <input type="hidden" name="returnto"
value="Thank_You/en" />
- <input type="hidden" value="0"
name="PaypalRedirect" id="PaypalRedirect">
- <input type="hidden" value="@country"
name="country" id="country" />
- <input type="hidden" value="@currency_code"
name="currency_code" />
- <input type="hidden" value="@utm_source"
name="utm_source"/>
- <input type="hidden" value="@utm_medium"
name="utm_medium"/>
- <input type="hidden" value="@utm_campaign"
name="utm_campaign"/>
- <input type="hidden" value="@language"
name="language"/>
- <input type="hidden" value="@referrer"
name="referrer"/>
- <input type="hidden" value="1"
name="email-opt"/>
- <input type="hidden" value="@token"
name="token"/>
- <input type="hidden" value="@order_id"
name="order_id"/>
- <input type="hidden"
value="@contribution_tracking_id" name="contribution_tracking_id"/>
- <input type="hidden" value="@data_hash"
name="data_hash"/>
- <input type="hidden" value="@owa_session"
name="owa_session"/>
- <input type="hidden" value="@owa_ref"
name="owa_ref"/>
- <input type="hidden" value="@gateway"
name="gateway" />
- <input type="hidden" value="0"
name="recurring"/>
- <input type="hidden" value="1" name="redirect"/>
- </form>
- </div>
- <p
id="informationsharing">%donate_interface-informationsharing|url%</p>
- <table>
- <tr>
- <td>
- {% block moreinfolinks %}
- </td>
- <td>@verisign_logo</td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
-</table>
diff --git a/gateway_forms/Mustache.php b/gateway_forms/Mustache.php
index da704d9..5823d85 100644
--- a/gateway_forms/Mustache.php
+++ b/gateway_forms/Mustache.php
@@ -103,7 +103,7 @@
$data['button_class'] = count( $data['submethods'] ) % 4 === 0
? 'four-per-line'
: 'three-per-line';
- $data['is_cc'] = ( $this->gateway->getPaymentMethod() === 'cc'
);
+ $data['is_' . $this->gateway->getPaymentMethod()] = true;
$required_fields = $this->gateway->getRequiredFields();
foreach( $required_fields as $field ) {
diff --git a/gateway_forms/mustache/amazon_payment.html.mustache
b/gateway_forms/mustache/amazon_payment.html.mustache
new file mode 100644
index 0000000..054114c
--- /dev/null
+++ b/gateway_forms/mustache/amazon_payment.html.mustache
@@ -0,0 +1,11 @@
+ <tr>
+ <td>
+ <script
type="text/javascript">
+ var
clientId = '{{ client_id }}',
+
sellerId = '{{ seller_id }}',
+
sandbox = {{ sandbox }};
+ </script>
+ <div
id="walletWidget"></div>
+ <div
id="consentWidget"></div>
+ </td>
+ </tr>
diff --git a/gateway_forms/mustache/index.html.mustache
b/gateway_forms/mustache/index.html.mustache
index 5731429..73bc6f5 100644
--- a/gateway_forms/mustache/index.html.mustache
+++ b/gateway_forms/mustache/index.html.mustache
@@ -26,8 +26,13 @@
<h3
class="cc_header">{{ l10n "donate_interface-cc-form-header-personal" }}<img
src="{{ script_path
}}/extensions/DonationInterface/gateway_forms/includes/padlock.gif"
style="vertical-align:baseline;margin-left:8px;"></h3>
</td>
</tr>
+{{# is_amazon }}
+{{> amazon_payment }}
+{{/ is_amazon }}
+{{^ is_amazon }}
{{> personal_info }}
{{> payment_method }}
+{{/ is_amazon }}
</tbody>
</table>
</div>
--
To view, visit https://gerrit.wikimedia.org/r/230253
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I621db21ded4cc91aed5426026830c7e94ac1bfb9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: payWithAmazon
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits