Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/292296
Change subject: [WIP] Support certificate authentication ...................................................................... [WIP] Support certificate authentication TODO: Make signature stuff optional Bug: T136743 Change-Id: I3a4817f76ffab6d83f1e3dfe666e1e39e9bdde8b --- M DonationInterface.php M paypal_gateway/express_checkout/paypal_express.adapter.php 2 files changed, 49 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/96/292296/1 diff --git a/DonationInterface.php b/DonationInterface.php index 420155d..6190528 100644 --- a/DonationInterface.php +++ b/DonationInterface.php @@ -411,19 +411,27 @@ # 'AccountEmail' => "", # ); -$wgPaypalExpressGatewayAccountInfo['test'] = array( - //'User' => 'abc', - //'Password' => '12345', - //'Signature' => 'or 123123123', - //TODO: credential authentication is not supported, yet. - //XXX 'Credential' => '123123123123', #OR - // TODO: Use parameter substitution. - 'RedirectURL' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=', -); -# FIXME: These are only for signature authentication. +/** + * Example PayPal Express Checkout account: + * + * $wgPaypalExpressGatewayAccountInfo['test'] = array( + * 'User' => 'abc', + * 'Password' => '12345', + * + * Use either certificate (preferred) OR signature authentication: + * 'Signature' => 'or 123123123', + * 'CertificatePath' => '/absolute path to cert_key_pem.txt', + * + * TODO: Use parameter substitution. + * 'RedirectURL' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=', + * ); + */ + # https://developer.paypal.com/docs/classic/api/endpoints/ -$wgPaypalExpressGatewayURL = 'https://api-3t.paypal.com/nvp'; -$wgPaypalExpressGatewayTestingURL = 'https://api-3t.sandbox.paypal.com/nvp'; +$wgPaypalExpressGatewayCertificateURL = 'https://api.paypal.com/nvp'; +$wgPaypalExpressGatewaySignatureURL = 'https://api-3t.paypal.com/nvp'; +$wgPaypalExpressGatewayTestingCertificateURL = 'https://api.sandbox.paypal.com/nvp'; +$wgPaypalExpressGatewayTestingSignatureURL = 'https://api-3t.sandbox.paypal.com/nvp'; $wgAdyenGatewayHtmlFormDir = __DIR__ . '/adyen_gateway/forms/html'; diff --git a/paypal_gateway/express_checkout/paypal_express.adapter.php b/paypal_gateway/express_checkout/paypal_express.adapter.php index a878cb6..33976f6 100644 --- a/paypal_gateway/express_checkout/paypal_express.adapter.php +++ b/paypal_gateway/express_checkout/paypal_express.adapter.php @@ -19,10 +19,28 @@ const IDENTIFIER = 'paypal_ec'; const GLOBAL_PREFIX = 'wgPaypalExpressGateway'; - const API_VERSION = 124; + // https://developer.paypal.com/docs/classic/release-notes/#ec + const API_VERSION = 204; public function getCommunicationType() { return 'namevalue'; + } + + protected function getCommunicationUrl() { + if ( !self::getGlobal( 'Test' ) ) { + if ( isset( $this->account_config['CertificatePath'] ) ) { + $url = self::getGlobal( 'CertificateURL' ); + } else { + $url = self::getGlobal( 'SignatureURL' ); + } + } else { + if ( isset( $this->account_config['CertificatePath'] ) ) { + $url = self::getGlobal( 'TestingCertificateURL' ); + } else { + $url = self::getGlobal( 'TestingSignatureURL' ); + } + } + return $url; } public function getResponseType() { @@ -59,6 +77,16 @@ } function setGatewayDefaults() {} + public function getCurlBaseOpts() { + $opts = parent::getCurlBaseOpts(); + + if ( $this->account_config['CertificatePath'] ) { + $opts[CURLOPT_SSLCERT] = $this->account_config['CertificatePath']; + } + + return $opts; + } + // TODO: Support "response" specification. function defineTransactions() { $this->transactions = array(); -- To view, visit https://gerrit.wikimedia.org/r/292296 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3a4817f76ffab6d83f1e3dfe666e1e39e9bdde8b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits