Helper Function to Retrieve Specific Link from Model Object

- Helper Methods in Payment and Agreement to get ApprovalLink
- Fixes #195
This commit is contained in:
japatel
2014-12-18 15:41:11 -06:00
parent d5450c64aa
commit f090642fae
12 changed files with 89 additions and 387 deletions

View File

@@ -71,14 +71,9 @@ try {
// ### Get redirect url
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $agreement->getLinks()
// the buyer to. Retrieve the url from the $agreement->getApprovalLink()
// method
foreach ($agreement->getLinks() as $link) {
if ($link->getRel() == 'approval_url') {
$approvalUrl = $link->getHref();
break;
}
}
$approvalUrl = $agreement->getApprovalLink();
} catch (Exception $ex) {
ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);

View File

@@ -108,12 +108,7 @@ try {
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $payment->getLinks()
// method
foreach ($payment->getLinks() as $link) {
if ($link->getRel() == 'approval_url') {
$approvalUrl = $link->getHref();
break;
}
}
$approvalUrl = $payment->getApprovalLink();
ResultPrinter::printResult("Created Payment Authorization Using PayPal. Please visit the URL to Authorize.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment);

View File

@@ -104,14 +104,9 @@ try {
// ### Get redirect url
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $payment->getLinks()
// the buyer to. Retrieve the url from the $payment->getApprovalLink()
// method
foreach ($payment->getLinks() as $link) {
if ($link->getRel() == 'approval_url') {
$approvalUrl = $link->getHref();
break;
}
}
$approvalUrl = $payment->getApprovalLink();
ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment);