Merge pull request #836 from xiaoleih41/master

Add getToken() to Payment class to get the EC token from the Approval URL
This commit is contained in:
Xiaolei Wheelock
2017-05-04 11:46:09 -05:00
committed by GitHub
2 changed files with 34 additions and 1 deletions

View File

@@ -544,7 +544,19 @@ class Payment extends PayPalResourceModel
{
return $this->getLink(PayPalConstants::APPROVAL_URL);
}
/**
* Get token from Approval Link
*
* @return null|string
*/
public function getToken()
{
$parameter_name = "token";
parse_str(parse_url($this->getApprovalLink(), PHP_URL_QUERY), $query);
return !isset($query[$parameter_name]) ? null : $query[$parameter_name];
}
/**
* Creates and processes a payment. In the JSON request body, include a `payment` object with the intent, payer, and transactions. For PayPal payments, include redirect URLs in the `payment` object.
*