Пример #1
0
    /**
     * @param $createdPlan
     * @return Plan
     */
    function activate(Plan $createdPlan)
    {
        $patch = new Patch();
        $value = new PayPalModel('{
	       "state":"ACTIVE"
	     }');
        $patch->setOp('replace')->setPath('/')->setValue($value);
        $patchRequest = new PatchRequest();
        $patchRequest->addPatch($patch);
        $createdPlan->update($patchRequest, $this->getAdapter()->getApiContext());
        $result = Plan::get($createdPlan->getId(), $this->getAdapter()->getApiContext());
        if ($result) {
            return ['plan' => $result, 'id' => $result->getId(), 'state' => $result->getState(), 'created' => $result->getCreateTime()];
        }
    }
Пример #2
0
 public function activateBillingPlan($planId, $apiContext)
 {
     $patch = new Patch();
     $patch->setOp('replace');
     $patch->setPath('/');
     $patch->setValue(array('state' => 'ACTIVE'));
     $patchRequest = new PatchRequest();
     $patchRequest->setPatches(array($patch));
     $plan = new Plan();
     $plan->setId($planId);
     return $plan->update($patchRequest, $apiContext);
 }
Пример #3
0
 /**
  * @dataProvider mockProvider
  * @param Plan $obj
  */
 public function testUpdate($obj, $mockApiContext)
 {
     $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(true));
     $patchRequest = PatchRequestTest::getObject();
     $result = $obj->update($patchRequest, $mockApiContext, $mockPayPalRestCall);
     $this->assertNotNull($result);
 }