Comments (4)
ApplePay: https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/javascript/v3#apple-pay
GooglePay: https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/javascript/v3#google-pay
If you need additional help, contact our support team: https://help.braintreepayments.com/
from braintree_php_example.
that's confused me,,,,
currently i have on front end,,,so what's the next step, to include that button same ui,,,
and secondly when i use crdit card 42424 4242 etc the transaction working , but when i select paypal ,
then it show this error "PayPal pending payments are not supported"
<script src="https://js.braintreegateway.com/web/dropin/1.13.0/js/dropin.min.js"></script>
<script>
var form = document.querySelector('#payment-form');
var client_token = "{{ $token }}";
braintree.dropin.create({
authorization: client_token,
selector: '#bt-dropin',
paypal: {
flow: 'vault'
}
}, function (createErr, instance) {
if (createErr) {
console.log('Create Error', createErr);
return;
}
form.addEventListener('submit', function (event) {
event.preventDefault();
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Request Payment Method Error', err);
return;
}
// Add the nonce to the form and submit
document.querySelector('#nonce').value = payload.nonce;
form.submit();
});
});
});
</script>
from braintree_php_example.
sir can you please help,
i have added the google code above that one like this but not showing,,, and the token will be same for all,? or i have to do seprate back end for google pay? very confused please help,,,
<div class="bt-drop-in-wrapper">
<div id="bt-dropin"></div>
</div>
</section>
<input id="nonce" name="payment_method_nonce" type="hidden" />
<button class="button" type="submit"><span>Test Transaction</span></button>
</form>
</div>
</div>
</div>
<!-- <div class="phonnumber">
<p class="number">Need assistance? Call 1-800-669-4268</p>
</div> -->
</div>
@endsection
@section('page-js')
<script src="https://js.braintreegateway.com/web/dropin/1.13.0/js/dropin.min.js"></script>
<script>
var form = document.querySelector('#payment-form');
var client_token = "{{ $token }}";
braintree.dropin.create({
authorization: client_token,
container: '#bt-dropin',
googlePay: {
googlePayVersion: 2,
merchantId: 'merchant-id-from-google',
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPrice: '123.45',
currencyCode: 'USD'
},
cardRequirements: {
// We recommend collecting and passing billing address information with all Google Pay transactions as a best practice.
billingAddressRequired: true
}
}
});
braintree.dropin.create({
authorization: client_token,
selector: '#bt-dropin',
paypal: {
flow: 'vault'
}
},
function (createErr, instance) {
if (createErr) {
console.log('Create Error', createErr);
return;
}
form.addEventListener('submit', function (event) {
event.preventDefault();
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Request Payment Method Error', err);
return;
}
// Add the nonce to the form and submit
document.querySelector('#nonce').value = payload.nonce;
form.submit();
});
});
});
</script>
my backend function
public function index()
{
$gateway = new Braintree\Gateway([
'environment' => 'sandbox',
'merchantId' => 'tq7vsrgd2zjczk2t',
'publicKey' => '',
'privateKey' => ''
]);
$token = $gateway->ClientToken()->generate();
$title="Home Page";
return view('index',compact('title','token'));
}
public function checkout(Request $request){
$gateway = new Braintree\Gateway([
'environment' => 'sandbox',
'merchantId' => 'tq7vsrgd2zjczk2t',
'publicKey' => '',
'privateKey' => ''
]);
$amount = $request->amount;
$nonce = $request->payment_method_nonce;
$result = $gateway->transaction()->sale([
'amount' => $amount,
'paymentMethodNonce' => $nonce,
'customer' => [
'firstName' => 'Tony',
'lastName' => 'Stark',
'email' => '[email protected]',
],
'options' => [
'submitForSettlement' => true
]
]);
// echo '<pre>';
// print_r($result);
// exit();
if ($result->success) {
$transaction = $result->transaction;
// header("Location: transaction.php?id=" . $transaction->id);
return back()->with('success_message', 'Transaction successful. The ID is:'. $transaction->id);
} else {
$errorString = "";
foreach ($result->errors->deepAll() as $error) {
$errorString .= 'Error: ' . $error->code . ": " . $error->message . "\n";
}
// $_SESSION["errors"] = $errorString;
// header("Location: index.php");
return back()->withErrors('An error occurred with the message: '.$result->message);
}
}
from braintree_php_example.
I'm locking this issue - please contact Braintree Support for assistance. Also, it is good security practice to never publicly share private keys (even for a sandbox account). You should rotate the API keys for your account.
from braintree_php_example.
Related Issues (20)
- Is it possible for result success to be true and transaction to be null ? HOT 1
- Blockchain
- No payment nonce available with PayPal HOT 2
- Handle multiple "Merchant ID Accounts" HOT 2
- production transaction error at Uncaught exception 'Braintree\Exception\Authorization HOT 1
- PHP 7.2 "Choose a way to pay" box is missing on index.php HOT 3
- Missing autoload.php file HOT 2
- Drop In Request Exception HOT 1
- file missing HOT 2
- Something went wrong on our end. HOT 1
- Integrate recurring subscription HOT 7
- Payment method nonce represents an un-vaulted payment instrument HOT 1
- Integrating payment in an existent php application HOT 1
- Drop-In ui: How to pre-select a payment method based on a vaulted payment method token? HOT 2
- I have tried this example and its working fine for credit card and paypal but it is not working for apple pay or google pay etc... how to enable it? HOT 2
- Integration Error: Detected a 3DS 1.0 Form POST to a 3DS 2.0 Endpoint HOT 1
- Provided code example for detecting successful transactions is misleading HOT 3
- 3D secure missing HOT 2
- paypal onPaymentMethodReceived HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from braintree_php_example.