2013-12-17 88 views
0

我想通過三個值來借記交易平衡付款使用PHP。通過信用卡借記多個值

我能夠成功地創建一個交易當我這樣做:

$transaction=$customer->debit($total*100); 

,而不是定義$交易作爲數組。當我在下面創建數組時,出現錯誤。我已經查看了API文檔,但是沒有一個例子在PHP中傳遞了多個值。

function new_transaction($cc_token=NULL, $total=NULL, $order_id=NULL){ 

    $customer = \Balanced\Customer::get('/v1/customers/CU7MPeEt3DhflopxaeFG'); 
    $transaction=$customer->debit(array(
     "amount"  => $total*100, 
     "source_uri" => $cc_token, 
     "appears_on_statement_as" => 'Order #'.$order_id, 
    ));  

    return $transaction->uri; 

} 

對不起,我沒多想就發佈錯誤,因爲它是不透明的 - 那就是:

Fatal error: Uncaught exception 'Balanced\Errors\Error' in /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Errors.php:35 Stack trace: #0 /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Resource.php(24): Balanced\Errors\Error::createFromResponse(Object(Httpful\Response)) #1 [internal function]: Balanced\Resource::convertError(Object(Httpful\Response)) #2 /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/restful/src/RESTful/Client.php(69): call_user_func('Balanced\Resour...', Object(Httpful\Response)) #3 /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/restful/src/RESTful/Client.php(34): RESTful\Client->_op(Object(Httpful\Request)) #4 /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/restful/src/RESTful/Collection.php(35): RESTful\Client->post('/v1/customers/C...', Array) #5 /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Customer.php in /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Errors.php on line 35

+0

*「我得到一個錯誤」*,真的嗎? – AbraCadaver

+0

什麼是錯誤? – user20232359723568423357842364

+0

剛剛發佈了錯誤,這是說他們的API庫中的第35行存在錯誤,而不是我的代碼。在我們的網站與平衡之間的溝通中存在錯誤。是否有其他地方可能列出錯誤? – Dan

回答

0

隨着平衡的支持的幫助下,我想通了這一點

function new_transaction($cc_token=NULL, $total=NULL, $order_id=NULL){ 
     $customer = \Balanced\Customer::get('/v1/customers/CU7guBPfer2uEkOEopU0KgXl'); 
     $transaction=$customer->debit($total*100, 'Statement Info', null, 'Description, $cc_token, null);  

     return $transaction->uri; 
    } 

作品...檢查在平衡代碼中的功能: https://github.com/balanced/balanced-php/blob/master/src/Balanced/Customer.php#L141

相關問題