Created
December 7, 2017 16:08
-
-
Save nanasess/a8b7f6756d59f6658cade084d82c83de to your computer and use it in GitHub Desktop.
checkout.js example
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://www.paypalobjects.com/api/checkout.min.js" data-version-4></script> | |
<script> | |
paypal.Button.render({ | |
env: '<%= @paypal_env %>', // Specify 'sandbox' for the test environment | |
client: { | |
sandbox: '<%= @sandbox_client_id %>', | |
production: '<%= @production_client_id %>' | |
}, | |
locale: 'ja_JP', | |
style: { | |
size: 'small' | |
}, | |
payment: function(resolve, reject) { | |
var env = this.props.env; | |
var client = this.props.client; | |
return paypal.rest.payment.create(env, client, { | |
transactions: [ | |
{ | |
amount: { total: '<%= @price %>', currency: 'JPY' }, | |
invoice_number: '<%= @invoice_number %>', | |
item_list: { | |
items: [ | |
{ | |
name: 'メークアップ料', | |
price: '<%= @price %>', | |
currency: 'JPY', | |
quantity: '1', | |
tax: '0' | |
} | |
] | |
}, | |
description: 'MAKE UP(質問形式)' | |
} | |
] | |
}, | |
{ | |
input_fields: { | |
no_shipping: 1 | |
} | |
}); | |
}, | |
commit: true, | |
onAuthorize: function(data, actions) { | |
// Execute the payment here, when the buyer approves the transaction | |
return actions.payment.execute().then(function() { | |
$('#new_answer').submit(); | |
}); | |
} | |
}, '#paypal-button'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment