2013-12-13 101 views
2

您知道通用錯誤消息如何幫助不大。Omni支付 - 支付通用錯誤

我想讓Omnipay與Pin Payments一起工作。

這是我到目前爲止有:

<?php 
require 'vendor/autoload.php'; 
use Omnipay\CreditCard; 
use Omnipay\Common\GatewayFactory; 

$gateway = GatewayFactory::create('Pin'); 


    $gateway->setSecretKey('KEY'); // TEST 
    $formData = ['number' => '4111111111111111', 'cvv' => '333','expiryMonth' => 6, 'expiryYear' => 2016]; 
    $response = $gateway->purchase([ 
     'email'  => '[email protected]', 
     'description' => 'Widgets', 
     'amount'  => '49.99', 
     'currency' => 'USD', 
     'card_token' => 'card_nytGw7koRg23EEp9NTmz9w', 
     'testMode' => true, 
     'ip_address' => '203.192.1.172', 
     'card' => $formData 


    ])->send(); 
    if ($response->isSuccessful()) { 
    // payment was successful: update database 
    print_r($response); 
    } elseif ($response->isRedirect()) { 
     // redirect to offsite payment gateway 
     $response->redirect(); 
    } else { 
     // payment failed: display message to customer 
     exit($response->getMessage()); 
    } 
    echo $response->getMessage(); 
?> 

這是我的錯誤: 一個或多個參數丟失或無效

任何幫助表示讚賞:)

+0

通過文檔來看,你錯過了你的'$ formData'數組中的CVV:https://github.com/omnipay/ omn​​ipay –

+0

他Scrowler,謝謝你的回覆,我已經加入了CVV。代碼工程沒有它,因爲我沒有從服務器收到有關CVV的消息。 – user30899

+0

您是否從OmniPay或Pin付款中收到該錯誤? – Keith

回答

0

問題已解決:

$response = $gateway->purchase([ 
     'email'  => '[email protected]', 
     'description' => 'Widgets', 
     'amount'  => '49.99', 
     'currency' => 'USD', 
     'card_token' => 'card_nytGw7koRg23EEp9NTmz9w', 
     'testMode' => true, 
     'ip_address' => '203.192.1.172', 
     'card' => $formData 


    ])->send(); 

用以下代碼替換上面的代碼(注: - >採購(陣列(NOT - >採購([

$response = $gateway->purchase(array(
     'email'  => '[email protected]', 
     'description' => 'Widgets', 
     'amount'  => '49.99', 
     'currency' => 'USD', 
     'card_token' => 'card_nytGw7koRg23EEp9NTmz9w', 
     'testMode' => true, 
     'ip_address' => '203.192.1.172', 
     'card' => $formData 


    ))->send(); 
+0

哦,同時也不要忘記將所有計費字段添加到卡對象。 – user30899

+0

使用var_dump($ response)獲取完整輸出。在Pin返回的JSON中也有一個錯誤列表,所以你應該在$ response對象中看到這個輸出。 –

+0

如果唯一的區別是你將'[]'改成'array()',這與Omnipay沒有任何關係 - 它意味着你運行的是PHP 5.3或更低版本,因爲短陣列語法[在PHP 5.4中引入] (http://php.net/manual/en/migration54.new-features.php)。 – Leith