jenkins-bot has submitted this change and it was merged.

Change subject: Add Amazon wallet widget
......................................................................


Add Amazon wallet widget

And show continue button when widget is ready.

Bug: T108116
Change-Id: I565ebca3fdb11167e5ff2b2023ca86d76440bd37
---
M amazon_gateway/amazon.js
1 file changed, 31 insertions(+), 2 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/amazon_gateway/amazon.js b/amazon_gateway/amazon.js
index 55b9386..1b0197d 100644
--- a/amazon_gateway/amazon.js
+++ b/amazon_gateway/amazon.js
@@ -8,7 +8,8 @@
                loginScript = mw.config.get( 'wgAmazonGatewayLoginScript' ),
                loggedIn = false,
                loginError,
-               accessToken;
+               accessToken,
+               billingAgreementId;
 
        // Cribbed from Amazon documentation
        function getURLParameter( name, source ) {
@@ -59,7 +60,9 @@
                amazon.Login.setClientId( clientId );
                amazon.Login.setUseCookie( true );
                amazon.Login.setSandboxMode( sandbox );
-               if ( !loggedIn ) {
+               if ( loggedIn ) {
+                       createWalletWidget();
+               } else {
                        if ( loginError ) {
                                showErrorAndLoginButton(
                                        getURLParameter( 'error_description', 
location.search )
@@ -84,4 +87,30 @@
                        loadScript( loginScript );
                }
        }
+
+       function createWalletWidget() {
+               new OffAmazonPayments.Widgets.Wallet( {
+                       sellerId: sellerId,
+                       onReady: function( billingAgreement ) {
+                               billingAgreementId = 
billingAgreement.getAmazonBillingAgreementId();
+                               $( '#paymentContinue' ).show();
+                               $( '#paymentContinueBtn' ).off( 'click' );
+                               $( '#paymentContinueBtn' ).click( submitPayment 
);
+                       },
+                       agreementType: 'OrderReference',
+                       design: {
+                               designMode: 'responsive'
+                       },
+                       onError: function( error ) {
+                               // Error message appears directly in widget
+                               showErrorAndLoginButton( '' );
+                       }
+               } ).bind( 'walletWidget' );
+       }
+
+       function submitPayment() {
+               $( '#overlay' ).show();
+               // TODO: make an API call
+               $( '#overlay' ).hide();
+       }
 } )( jQuery, mediaWiki );

-- 
To view, visit https://gerrit.wikimedia.org/r/230711
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I565ebca3fdb11167e5ff2b2023ca86d76440bd37
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: payWithAmazon
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to