これは答えではありませんが、最初にPayPal ExpressからPayPal RESTに切り替えることをお勧めします。これは、後者の方がはるかに優れており、新しいインターフェースです。
実際の回答:Omnipayはそのようには機能しません。基本的なゲートウェイメソッドを直接公開することはなく、 'setExpressCheckout'、 'doExpressCheckout'、 'getExpressCheckout'などのメソッドは、OmnipayメソッドではなくPayPalメソッドです。その代わりに、購入()や払い戻し()などのゲートウェイに依存しないメソッドがあります。
したがって、omnipay-paypal RESTゲートウェイのドキュメント(クラスヘッダーのdocblock)の例を次に示します。
// Create a gateway for the PayPal RestGateway
// (routes to GatewayFactory::create)
$gateway = Omnipay::create('PayPal_Rest');
// Initialise the gateway
$gateway->initialize(array(
'clientId' => 'MyPayPalClientId',
'secret' => 'MyPayPalSecret',
'testMode' => true, // Or false when you are ready for live transactions
));
ゲートウェイを初期化するだけです。このプロセスはPayPal Expressと同じですが、PayPal_Expressをゲートウェイ名として使用する場合を除き、initialize()
などのパラメータを指定する必要があります。あなたがそれを行うことを許可している場合は、カード番号と:
// 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 a purchase transaction on the gateway
try {
$transaction = $gateway->purchase(array(
'amount' => '10.00',
'currency' => 'AUD',
'description' => 'This is a test purchase transaction.',
'card' => $card,
));
$response = $transaction->send();
$data = $response->getData();
echo "Gateway purchase response data == " . print_r($data, true) . "\n";
if ($response->isSuccessful()) {
echo "Purchase transaction was successful!\n";
}
} catch (\Exception $e) {
echo "Exception caught while attempting authorize.\n";
echo "Exception type == " . get_class($e) . "\n";
echo "Message == " . $e->getMessage() . "\n";
}
PayPalアカウントの支払いなどのリダイレクトの支払いを行う多少異なりますが、それは、クラスコメントブロックに記述文書化されます。 src/Messages/RestPurchaseRequest.phpを参照してください
私は完全に同意します - Omnipayは役に立ちそうですが、どこからPayPal Expressを使い始めるべきかわかりません。 – Richard