简体   繁体   English

Braintree交易销售存储在valult和正确使用nonce和令牌

[英]Braintree Transaction Sale storing in valult and proper use of nonce and token

I have a few questions: 我有几个问题:

Can I store the credit card/paypal method in sale but also prevent duplicates? 我可以在销售中存储信用卡/ paypal方法,但也可以防止重复? OR do duplicates just create an error when using storeInVaultOnSuccess . 或者重复只是在使用storeInVaultOnSuccess时创建错误。 Will a "duplicate method" error cause sale to fail? “重复方法”错误会导致销售失败吗?

Can I create a customer with Braintree_Transaction::sale ? 我可以使用Braintree_Transaction :: sale创建客户吗? Will a "duplicate customer" error cause sale to fail? “重复客户”错误会导致销售失败吗?

Is there a way to combine to do a "either/or" for paymentMethodNonce and paymentMethodToken ? 有没有办法结合起来为paymentMethodNoncepaymentMethodToken做“或/或”?

Lastly security question. 最后是安全问题。 Does Braintree make sure the paymenthMethodToken for a customer matches the customerId of the sale? 是否布伦特里确保paymenthMethodToken为客户买卖的客户ID匹配? To ensure a token for one customer method cannot be used to complete sale for another customer. 确保一个客户方法的代币不能用于完成另一个客户的销售。

if($paymentMethodNonce){
  if($save){
    $create=Braintree_PaymentMethod::create([
      "customerId"=>$customerId,
      "paymentMethodNonce"=>$paymentMethodNonce,
      "options"=>["failOnDuplicatePaymentMethod"=>true]
    ]);      
  }
  $sale=Braintree_Transaction::sale([
    "amount"=>$cost,
    "paymentMethodNonce"=>$paymentMethodNonce,
    "customerId"=>$customerId
  ]);
}
else if($paymentMethodToken){
  $sale=Braintree_Transaction::sale([
    "amount"=>$cost,
    "paymentMethodToken"=>$paymentMethodToken,
    "customerId"=>$customerId
  ]);
}

To answer your last question, if you include both a paymentMethodToken and a customerId when creating a sale, we require that the paymentMethodToken belongs to the customer specified by the provided customerId . 要回答您的上一个问题,如果您在创建销售时同时包含paymentMethodTokencustomerId ,我们要求paymentMethodToken属于所提供的customerId指定的customerId If it does not belong to the customer specified, we throw a Transaction Error with code 91516 (Cannot provide both payment_method_token and customer_id unless the payment_method belongs to the customer). 如果它不属于指定的客户,我们会抛出代码为91516交易错误 (除非payment_method属于客户,否则不能同时提供payment_method_token和customer_id)。

You can create customers and payment methods inside the sale transaction, but they do create errors on duplicates which cause sale to fail. 您可以在销售交易中创建客户和付款方式,但它们会在重复上创建错误,从而导致销售失败。 The best way is just to create and ignore errors 最好的方法是创建和忽略错误

$create_customer=Braintree_Customer::create([
  "id"=>$id,
]);
$create_payment_method=Braintree_PaymentMethod::create([
  "customerId"=>$login,
  "paymentMethodNonce"=>$method
]);

Next, the only way to combine paymentMethodNonce and paymentMethodToken is to switch according to which one is being handled. 接下来,组合paymentMethodNonce和paymentMethodToken的唯一方法是根据正在处理的方式进行切换。

$TokenOrNonceType="paymentMethodToken"; or $TokenOrNonceType="paymentMethodNonce";
$sale=Braintree_Transaction::sale([
  "amount"=>$cost,
  $TokenOrNonceType=>$TokenOrNonce,
  "customerId"=>$customerId
]);

Lastly, I am still unsure about the last question. 最后,我仍然不确定最后一个问题。 Does Braintree make sure the paymenthMethodToken for a customer matches the customerId of the sale? 是否布伦特里确保paymenthMethodToken为客户买卖的客户ID匹配? To ensure a token for one customer method cannot be used to complete sale for another customer. 确保一个客户方法的代币不能用于完成另一个客户的销售。 Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM