MDL-69166 pg_paypal: New helper to get order details from PayPal

This commit is contained in:
Shamim Rezaie
2020-10-27 14:37:29 +11:00
parent 7740c45de4
commit 9e6630ab99
@@ -133,6 +133,28 @@ class paypal_helper {
return json_decode($result, true);
}
public function get_order_details(string $orderid): ?array {
$location = "{$this->baseurl}/v2/checkout/orders/{$orderid}";
$options = [
'CURLOPT_RETURNTRANSFER' => true,
'CURLOPT_TIMEOUT' => 30,
'CURLOPT_HTTP_VERSION' => CURL_HTTP_VERSION_1_1,
'CURLOPT_SSLVERSION' => CURL_SSLVERSION_TLSv1_2,
'CURLOPT_HTTPHEADER' => [
'Content-Type: application/json',
"Authorization: Bearer {$this->token}",
],
];
$command = '{}';
$curl = new curl();
$result = $curl->get($location, $command, $options);
return json_decode($result, true);
}
/**
* Request for PayPal REST oath bearer token.
*