Skip to content

Commit

Permalink
MDL-69166 pg_paypal: New helper to get order details from PayPal
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Oct 27, 2020
1 parent 7740c45 commit 9e6630a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions payment/gateway/paypal/classes/paypal_helper.php
Expand Up @@ -133,6 +133,28 @@ public function capture_order(string $orderid): ?array {
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.
*
Expand Down

0 comments on commit 9e6630a

Please sign in to comment.