您可以使用CakePHP PayPal組件將您的網站與PayPal集成: https://github.com/robmcvey/cakephp-paypal。
但是要在任何地方使用PayPal API,PayPal賬戶必須是Pro賬戶。您還需要爲每個帳戶(從PayPal - > Profile - > API Settings - > Signature)獲取API用戶名,密碼和簽名並將其放入您的代碼中。
在控制器的樣本代碼可能是這樣的:
class SomeController extends AppController {
public $components = array('Paypal');
public function payWithPaypal() {
$this->Paypal->config['password'] = 'your paypal password';
$this->Paypal->config['email'] = 'your paypal email';
$this->Paypal->config['signature'] = 'your paypal signature';
$this->Paypal->sandboxMode = false;
$this->Paypal->amount = 100;
$this->Paypal->itemName = 'some item';
$this->Paypal->quantity = 1;
$this->Paypal->localeCode = 'GB';
$this->Paypal->currencyCode = 'EUR';
$this->Paypal->returnUrl = 'some url';
$this->Paypal->cancelUrl = 'some url';
$paypal_url = $this->Paypal->expressCheckout();
$this->redirect($paypal_url);
}
}
閱讀組件文檔和代碼註釋的組件類裏面熟悉的細節。
任何人,請幫助! – user2858370
請參閱https://developer.paypal.com/webapps/developer/docs/api/。每個API都有示例php代碼。 PayPal沒有cakphp插件。你必須用php編寫。 – nithin
事實上,CakePHP有一個PayPal組件。我在我的回答中寫到了它。 –