本文整理汇总了PHP中Transaction::sale方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::sale方法的具体用法?PHP Transaction::sale怎么用?PHP Transaction::sale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::sale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaleWithInvalidAmount
function testSaleWithInvalidAmount()
{
$this->expectException(new Errors\ValidationError(array(array('property' => 'payment_transaction.amount', 'message' => 'must have a minimum value of 1'))));
$data = $this->fixture('sale.json');
$data['amount'] = -10;
Transaction::sale($this->channelToken, $data);
}
示例2:
<?php
/**
* Created by PhpStorm.
* User: David
* Date: 2015-09-19
* Time: 1:54 AM
*/
require "braintree-php/lib/Braintree.php";
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('f8hz5cfs97665c2r');
Braintree_Configuration::publicKey('289njc8rrdf47cwk');
Braintree_Configuration::privateKey('e23e1e9b16adfccd3208096b42bba5a9');
echo $clientToken = Braintree_ClientToken::generate();
//Process payment
$nonce = $_POST["payment_method_nonce"];
/* Use payment method nonce here */
//Amount of payment
$amount = $_POST["payment_amount"];
$result = Braintree . Transaction::sale(['amount' => $amount, 'paymentMethodNonce' => $nonce]);
echo $nonce . " for \$" . $amount . "\n";
示例3: processPayment
private function processPayment()
{
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('f8hz5cfs97665c2r');
Braintree_Configuration::publicKey('289njc8rrdf47cwk');
Braintree_Configuration::privateKey('e23e1e9b16adfccd3208096b42bba5a9');
//echo($clientToken = Braintree_ClientToken::generate());
//Process payment
$nonce = $_POST["payment_method_nonce"];
/* Use payment method nonce here */
//Amount of payment
$amount = $_POST["payment_amount"];
$result = Braintree . Transaction::sale(['amount' => $amount, 'paymentMethodNonce' => $nonce]);
$name = "Valid payment";
switch ($nonce) {
case "fake-valid-visa-nonce":
$name = "Visa";
break;
case "fake-valid-mastercard-nonce":
$name = "Mastercard";
break;
case "fake-valid-debit-nonce":
$name = "Debit";
break;
default:
break;
}
//echo($name . " for $" . $amount . "\n");
}