Example #1
0
 /**
  * Suspend billing agreement with paypal
  * @param object $createdAgreement Agreement
  * @param $agreementStateDescription
  * @return bool
  * @internal param string $agreementStateDescriptor
  */
 function suspend($createdAgreement, $agreementStateDescription)
 {
     //Create an Agreement State Descriptor, explaining the reason to suspend.
     $agreementStateDescriptor = new AgreementStateDescriptor();
     $agreementStateDescriptor->setNote($agreementStateDescription);
     $createdAgreement->suspend($agreementStateDescriptor, $this->getAdapter()->getApiContext());
     // Lets get the updated Agreement Object
     return Agreement::get($createdAgreement->getId(), $this->getAdapter()->getApiContext());
 }
Example #2
0
 /**
  * Update existing billing agreement at paypal
  * @param $agreementId
  * @param string $description
  * @return bool
  * @internal param object $createdAgreement Agreement
  */
 function cancel($agreementId, $description = "Cancelling the agreement")
 {
     $agreement = Agreement::get($agreementId, $this->getAdapter()->getApiContext());
     $agreementStateDescriptor = new AgreementStateDescriptor();
     $agreementStateDescriptor->setNote($description);
     try {
         $agreement->cancel($agreementStateDescriptor, $this->getAdapter()->getApiContext());
     } catch (\Exception $ex) {
         //@todo add some logging
     }
     return true;
 }
Example #3
0
<?php

// # Suspend an agreement
//
// This sample code demonstrate how you can suspend a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend
// Retrieving the Agreement object from Create Agreement Sample to demonstrate the List
/** @var Agreement $createdAgreement */
$createdAgreement = (require 'CreateBillingAgreementWithCreditCard.php');
use PayPal\Api\Agreement;
use PayPal\Api\AgreementStateDescriptor;
//Create an Agreement State Descriptor, explaining the reason to suspend.
$agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Suspending the agreement");
try {
    $createdAgreement->suspend($agreementStateDescriptor, $apiContext);
    // Lets get the updated Agreement Object
    $agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Suspended the Agreement", "Agreement", $agreement->getId(), $agreementStateDescriptor, $agreement);
return $agreement;
<?php

// # Reactivate an agreement
//
// This sample code demonstrate how you can reactivate a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend
// Retrieving the Agreement object from Suspend Agreement Sample to demonstrate the List
/** @var Agreement $suspendedAgreement */
$suspendedAgreement = (require 'SuspendBillingAgreement.php');
use PayPal\Api\Agreement;
use PayPal\Api\AgreementStateDescriptor;
//Create an Agreement State Descriptor, explaining the reason to suspend.
$agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Reactivating the agreement");
try {
    $suspendedAgreement->reActivate($agreementStateDescriptor, $apiContext);
    // Lets get the updated Agreement Object
    $agreement = Agreement::get($suspendedAgreement->getId(), $apiContext);
} catch (Exception $ex) {
    ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $ex);
    exit(1);
}
ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $agreement);
return $agreement;
 /**
  * @depends testSerializationDeserialization
  * @param AgreementStateDescriptor $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getNote(), "TestSample");
     $this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
 }