mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-69166 pg_paypal: Ability to connect to sandbox or live environment
This commit is contained in:
parent
16099e4038
commit
330f492089
@ -72,13 +72,14 @@ class transaction_complete extends external_api {
|
||||
]);
|
||||
|
||||
$config = get_config('pg_paypal');
|
||||
$sandbox = $config->environment == 'sandbox';
|
||||
|
||||
[
|
||||
'amount' => $amount,
|
||||
'currency' => $currency
|
||||
] = \core_payment\helper::get_cost($component, $componentid);
|
||||
|
||||
$paypalhelper = new paypal_helper($config->clientid, $config->secret, false);
|
||||
$paypalhelper = new \pg_paypal\paypal_helper($config->clientid, $config->secret, $sandbox);
|
||||
$authorization = $paypalhelper->capture_authorization($authorizationid, $amount, $currency);
|
||||
|
||||
$success = false;
|
||||
|
@ -28,13 +28,17 @@ $string['captureauthorizationfailed'] = 'Could not capture authorization.';
|
||||
$string['clientid'] = 'Client ID';
|
||||
$string['clientid_desc'] = 'The client ID that PayPal generated for your application.';
|
||||
$string['echecknotsupported'] = 'E-check is not supported.';
|
||||
$string['environment'] = 'Environment';
|
||||
$string['environment_desc'] = 'You can set this to Sandbox if you are using sandbox accounts (for testing purpose only).';
|
||||
$string['gatewaydescription'] = 'PayPal is an authorised payment gateway provider for processing credit card transactions.';
|
||||
$string['gatewayname'] = 'PayPal';
|
||||
$string['internalerror'] = 'Internal error.';
|
||||
$string['live'] = 'Live';
|
||||
$string['paymentauthorizationwarning'] = 'For PayPal payment authorizations, you must enable this feature on your PayPal account.';
|
||||
$string['paymentnotcleared'] = 'payment not cleared by PayPal.';
|
||||
$string['pluginname'] = 'PayPal';
|
||||
$string['pluginname_desc'] = 'The PayPal plugin allows you to receive payments via PayPal.';
|
||||
$string['repeatedorder'] = 'This order has already been processed earlier.';
|
||||
$string['sandbox'] = 'Sandbox';
|
||||
$string['secret'] = 'Secret';
|
||||
$string['secret_desc'] = 'The secret thatPayPal generated for your application.';
|
||||
|
@ -37,4 +37,11 @@ if ($ADMIN->fulltree) {
|
||||
get_string('clientid_desc', 'pg_paypal'), '', PARAM_TEXT));
|
||||
$settings->add(new admin_setting_configtext('pg_paypal/secret', get_string('secret', 'pg_paypal'),
|
||||
get_string('secret_desc', 'pg_paypal'), '', PARAM_TEXT));
|
||||
|
||||
$options = [
|
||||
'live' => get_string('live', 'pg_paypal'),
|
||||
'sandbox' => get_string('sandbox', 'pg_paypal'),
|
||||
];
|
||||
$settings->add(new admin_setting_configselect('pg_paypal/environment', get_string('environment', 'pg_paypal'),
|
||||
get_string('environment_desc', 'pg_paypal'), 'live', $options));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user