2016-06-27 22 views
0

Was bedeutet TEMPLATE_ID_INVALID? Warum schlägt der folgende Code fehl? .PayPal SDK - TEMPLATE_ID_INVALID

$apiContext=getApiContext(); 
$agreement = new Agreement(); 
$agreement->setName("name") 
->setDescription("descr") 
->setStartDate(date("Y-m-d\TH:i:s",strtotime("+1 days"))."Z" ); 
$plan = new Plan(); 
$plan->setId($planid); 
$agreement->setPlan($plan); 

$payer = new Payer(); 
$payer->setPaymentMethod('paypal'); 
$agreement->setPayer($payer); 

try { 
$agreement = $agreement->create($apiContext); 
$approvalUrl = $agreement->getApprovalLink(); 
} catch (Exception $ex) { 

} 

Ausnahme $ex ist:

PayPal\Exception\PayPalConnectionException object { 
    url => (string) https://api.sandbox.paypal.com/v1/payments/billing-agreements/ 
    data => (string) {"name":"TEMPLATE_ID_INVALID","details":[{"field":"template id is invalid","issue":"Incorrect Template Id."}],"message":"","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#TEMPLATE_ID_INVALID","debug_id":"fdf8520bc9574"} 
    message => (string) Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/billing-agreements/. 

Antwort

0

ich die Lösung gefunden. $planid hatte den falschen Wert. Die richtige Plan-ID muss folgendermaßen aussehen: 'P-86531922WW564673NESSWCCA'.