对于发现这篇文章的其他任何人,都支持 REST API。
RestGateway.php
源代码完整文档中的摘录
- 两种环境都支持 PayPal REST API。使用沙盒环境
- 用于测试目的,然后转移到现场环境进行生产处理。
- 测试时,使用您的测试凭据生成访问令牌以调用
- 沙盒 URI。当您准备上线时,请使用分配给
- 您的应用程序生成一个新的访问令牌以与实时 URI 一起使用。
提交
https://github.com/thephpleague/omnipay-paypal/pull/21
// Create a gateway for the PayPal RestGateway
// (routes to GatewayFactory::create)
$gateway = Omnipay::create('RestGateway');
// Initialise the gateway
$gateway->initialize(array(
'clientId' => 'MyPayPalClientId',
'secret' => 'MyPayPalSecret',
'testMode' => true, // Or false when you are ready for live transactions
));
// Create a credit card object
// DO NOT USE THESE CARD VALUES -- substitute your own
// see the documentation in the class header.
$card = new CreditCard(array(
'firstName' => 'Example',
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => '01',
'expiryYear' => '2020',
'cvv' => '123',
'billingAddress1' => '1 Scrubby Creek Road',
'billingCountry' => 'AU',
'billingCity' => 'Scrubby Creek',
'billingPostcode' => '4999',
'billingState' => 'QLD',
));
// Do an authorisation transaction on the gateway
$transaction = $gateway->authorize(array(
'amount' => '10.00',
'currency' => 'AUD',
'description' => 'This is a test authorize transaction.',
'card' => $card,
));
$response = $transaction->send();
if ($response->isSuccessful()) {
echo "Authorize transaction was successful!\n";
// Find the authorization ID
$auth_id = $response->getTransactionReference();
}
来自 RestAuthorizeRequest.php