我知道已有关于此主题的问题,但我找不到解决方案。我是paypal api的新手,我的任务是创建一个取消账单协议的功能。
甚至不知道如何形成和调用函数调用api。试图找到和示例,但到处都是我最终查看技术参考页面,这对我来说不是新手......
有人可以起草和举例吗?
到目前为止,我已经到了这个阶段,但仍然无法工作。
if(!empty($agreement->paypal_agreement_id) && $agreement->paypal_agreement_state == 'Active')
{
/*
* Cancel a billing agreement
*/
$apiContext = new ApiContext(new OAuthTokenCredential($this->clientid, $this->clientsecret));
$createdAgreement = $agreement->paypal_agreement_id;
$patch = new Patch();
$patch->setOp('replace')
->setPath('/')
->setValue(json_decode('{
"billingagreementstatus": "Canceled"
}'));
$patchRequest = new PatchRequest();
$patchRequest->addPatch($patch);
try {
// Uzkomentinta testatimui - netrinti. Mindaugas
$createdAgreement->update($patchRequest, $apiContext);
$agreement = Agreement::get($createdAgreement, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex);
exit(1);
}
} else {
return ['.reportmsg' => 'Payment agreements do not exist.'];
}
任何人都可以提供帮助吗?