Updates to Sample Code

- Updated UI Presentation on samples
- Fixed Bugs
This commit is contained in:
japatel
2014-11-02 17:06:58 -06:00
parent 4d481ad104
commit 3c02790138
97 changed files with 904 additions and 1249 deletions

View File

@@ -100,9 +100,8 @@ try {
// Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
$agreement = $agreement->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex);
exit(1);
}

View File

@@ -80,9 +80,8 @@ try {
}
}
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);
exit(1);
}

View File

@@ -46,7 +46,7 @@ $merchantPreferences = new MerchantPreferences();
$baseUrl = getBaseUrl();
$merchantPreferences->setReturnUrl("$baseUrl/ExecuteAgreement.php?success=true")
->setCancelUrl("$baseUrl/ExecuteAgreement.php?success=false")
->setAutoBillAmount("YES")
->setAutoBillAmount("yes")
->setInitialFailAmountAction("CONTINUE")
->setMaxFailAttempts("0")
->setSetupFee(new Currency(['value' => '1', 'currency' => 'USD']));
@@ -61,9 +61,8 @@ $request = clone $plan;
// ### Create Plan
try {
$output = $plan->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Created Plan", "Plan", null, $request, $ex);
exit(1);
}

View File

@@ -10,9 +10,8 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
try {
$agreement->execute($token, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
exit(1);
}
ResultPrinter::printResult("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $agreement);

View File

@@ -14,9 +14,8 @@ use PayPal\Api\Agreement;
try {
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $ex);
exit(1);
}

View File

@@ -14,9 +14,8 @@ use PayPal\Api\Plan;
try {
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Retrieved a Plan", "Plan", $plan->getId(), null, $ex);
exit(1);
}

View File

@@ -19,9 +19,8 @@ try {
// at https://developer.paypal.com/webapps/developer/docs/api/#list-plans
$params = array('page_size' => '2');
$planList = Plan::all($params, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
exit(1);
}

View File

@@ -24,9 +24,8 @@ try {
// Lets get the updated Agreement Object
$agreement = Agreement::get($suspendedAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $ex);
exit(1);
}

View File

@@ -24,9 +24,8 @@ try {
// Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);
exit(1);
}

View File

@@ -36,9 +36,8 @@ try {
// Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex);
exit(1);
}

View File

@@ -34,9 +34,8 @@ try {
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
} catch (Exception $ex) {
ResultPrinter::printError("Updated the Plan to Active State", "Plan", null, $patchRequest, $ex);
exit(1);
}