setName('DPRP') ->setDescription('Payment with credit Card') ->setStartDate('2015-06-17T9:45:04Z'); // Add Plan ID // Please note that the plan Id should be only set in this case. $plan = new Plan(); $plan->setId($createdPlan->getId()); $agreement->setPlan($plan); // Add Payer $payer = new Payer(); $payer->setPaymentMethod('credit_card') ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com'))); // Add Credit Card to Funding Instruments $creditCard = new CreditCard(); $creditCard->setType('visa') ->setNumber('4491759698858890') ->setExpireMonth('12') ->setExpireYear('2017') ->setCvv2('128'); $fundingInstrument = new FundingInstrument(); $fundingInstrument->setCreditCard($creditCard); $payer->setFundingInstruments(array($fundingInstrument)); //Add Payer to Agreement $agreement->setPayer($payer); // Add Shipping Address $shippingAddress = new ShippingAddress(); $shippingAddress->setLine1('111 First Street') ->setCity('Saratoga') ->setState('CA') ->setPostalCode('95070') ->setCountryCode('US'); $agreement->setShippingAddress($shippingAddress); // For Sample Purposes Only. $request = clone $agreement; // ### Create Agreement try { // Please note that as the agreement has not yet activated, we wont be receiving the ID just yet. $agreement = $agreement->create($apiContext); } catch (Exception $ex) { ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex); exit(1); } ResultPrinter::printResult("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $agreement); return $agreement;