Created
February 9, 2016 21:39
-
-
Save matthewarkin/8f27ac2b4998e90ca383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://js.braintreegateway.com/v2/braintree.js"></script> | |
<form id="form" action="chargeCustomer.php" method="POST"> | |
</form> | |
<div id="paypal-container"></div> | |
<script type="text/javascript"> | |
braintree.setup("<?php echo($gateway->clientToken()->generate());?>", "custom", { | |
paypal: { | |
container: "paypal-container", | |
singleUse: true, // Required | |
amount: 10.00, // Required | |
currency: 'USD', // Required | |
locale: 'en_us', | |
enableShippingAddress: 'true', | |
shippingAddressOverride: { | |
recipientName: 'Scruff McGruff', | |
streetAddress: '1234 Main St.', | |
extendedAddress: 'Unit 1', | |
locality: 'Chicago', | |
countryCodeAlpha2: 'US', | |
postalCode: '60652', | |
region: 'IL', | |
phone: '123.456.7890', | |
editable: false | |
} | |
}, | |
onPaymentMethodReceived: function (obj) { | |
var input = document.createElement('input'); | |
input.type = 'hidden'; | |
input.name = '$_POST['payment_method_nonce']'; | |
input.value = obj.nonce; | |
document.getElementById('form').appendChild(input); | |
document.getElementById('form').submit() | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment