因为我尝试直接使用Omnipay REST API失败了,所以我想看看是否可以使用PayPal……有没有办法在Omnipay中使用REST API?到目前为止,我见过的唯一集成需要username和password,而不是client id和client secret
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('XXXXX');
$gateway->setPassword('XXXX');
$gateway->setSignature('XXXXX');
$response = $gateway->completePurchase(
array(
'cancelUrl' => 'www.xyz.com/cancelurl',
'returnUrl' => 'www.xyz.com/returnurl',
'amount' => '25.00',
'currency' => 'CAD'
)
)->send();发布于 2015-10-23 12:40:03
对于其他找到这篇文章的人,有对REST API的支持。
在源代码完整文档中找到的RestGateway.php摘录
提交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
发布于 2014-02-26 04:36:15
REST API在PayPal中仍然是非常新的,而且还不够完整。目前还没有多少第三方框架实现它。
看起来您正在使用PHP并尝试实现Express Checkout..??如果是这样的话,我建议你看看我的class library for PayPal。你可以在几分钟内完成这项工作。
它还使用API用户名、密码和签名。您可以从API Access部分下的PayPal帐户配置文件中获取这些凭据。
我的库附带了功能强大且易于遵循的Express Checkout示例,还有一些空模板,您可以从这些模板开始设置自己的模板,只需填写所需的任何参数。
发布于 2014-02-27 01:10:23
不,Omnipay还不支持REST API。
也就是说,Omnipay抽象了不同API之间的差异,所以使用哪个API对您来说并不重要。您在上面发布的代码应该可以很好地使用are,所以只需确保您使用的是正确的PayPal密钥,一切都将变得简单。
https://stackoverflow.com/questions/22024237
复制相似问题