将多个值传递到信用卡借记卡

时间:2013-12-17 18:22:39

标签: php balanced-payments

我正在尝试使用PHP将三个值传递到平衡支付中的借记交易。

当我这样做时,我能够成功创建一个事务:

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

而不是将$ transaction定义为数组。当我在下面创建数组时,我得到一个错误。我已经查看了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;

}

抱歉,我不想发布错误,因为它是不透明的 - 这是:

  

致命错误:未捕获异常'平衡\错误\错误'   /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Errors.php:35   堆栈跟踪:#0   /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Resource.php(24):   Balanced \ Errors \ Error :: createFromResponse(Object(Httpful \ Response))#1   [内部功能]:   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   在   /Applications/MAMP/htdocs/merchantfuse/application/libraries/balanced/balanced/src/Balanced/Errors.php   第35行

1 个答案:

答案 0 :(得分: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