I need only one Payment Method (AliPay). But I can't disable default payment method with Stripe Checkout (Credit Card). Of course, I read documentation, but I don't have any idea how I can make that.
This is My code.
var handler = StripeCheckout.configure({
key: 'public_key',
alipay: true,
locale: false,
currency: "usd",
token: function(token) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});
handler.open({
name: 'example.com',
description: 'AliPay Payment',
amount: 10000
});
Thanks!
It's not possible to disable the default (card) area of Checkout.
If you're looking for greater customizability of your payment form I'd have a look at Stripe.js/Elements and the Sources API. You can use the Sources
to generate an AliPay source, redirect a user to AliPay to authorize a payment, and then return them to your site, https://stripe.com/docs/sources/alipay
Related
I would like to change the placeholder value from "Card Number" to something like 1234*****5678 in the stripe modal. How can I do that?
Thank you.
The modal has been generate by the below code.
<script src="https://checkout.stripe.com/checkout.js" ></script>
var handler = StripeCheckout.configure({
key: "",
locale: 'english',
image: '',
panelLabel: 'Update Card',
token: function(token) {
});
handler.open({
name: "sitename",
currency: 'USD',
opened: function () {
}
});
Stripe Javascript creates an iFrame hosted on their own domain, so for security reasons you're not allowed to access/edit the DOM of such iFrame.
Just imagine that if this wouldn't be the case, your page could be allowed to get the credit number of the customer, which is a big nono.
Furthermore please note that you're using an outdated version of Stripe, you should look into migrating to a newer version here.
I'm using Apple Pay integration with Stripe and I need to get the shippingAddress from Apple Pay before shown the order information because I need to calculate taxes and shipment cost based on the address.
Currently, I can get the shipmentAddress but after show the window with the information.
I'm sending this payload:
var paymentRequest = {
requiredShippingContactFields: ['postalAddress','email', 'phone'],
countryCode: 'US',
currencyCode: 'USD',
lineItems: this.buildLineItems(lineItems),
total: this.buildTotal(lineItems)
};
There's a way to get the shipment information before show the window or update the window based on the information that I get?
Source:
https://stripe.com/docs/apple-pay/web/v2
https://stripe.com/docs/apple-pay/web/v2/custom
Thanks
In order to get the shipment information you need to listen for onshippingcontactselected
session.onshippingcontactselected = (event) => {
// You can do work asynchronously here; just call
// session.completeShippingMethodSelection when you're done.
}
Documentation
https://stripe.com/docs/stripe-js/reference#payment-request-on
https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected?language=javascript
All I am trying to do is charge a customer like this:
var stripe = require("stripe")("sk_test_5uwvjas5uFYUCZN5d3YdAT19");
stripe.charges.create({
amount: 1000,
currency: "usd",
customer: "cus_112121212", // CUSTOMER ID
destination: {
account: "{CONNECTED_STRIPE_ACCOUNT_ID}",
},
}).then(function(charge) {
// asynchronously called
});
According to the documentation:
https://stripe.com/docs/api/charges/create
This should be possible,
Yet i get the error:
there was an issue Error: No such token: cus_111212122112
Am I reading the docs wrong? Thank you.
Review Firestripe example since it’s in Node js.
https://github.com/firebase/functions-samples/blob/master/stripe/functions/index.js
If that doesn’t help, confirm that customer have a source attached to it. If not, then you can’t charge that customer.
I am using React-GA, and it works as expected, but I have a requirement to put user email in event tracking:
I see this in the example:
ReactGA.event({
category: 'Editing',
action: 'Deleted Component',
label: 'Game Widget'
});
I have a email of each user as a string. Where do I better put it in the request?
yes i am with #davids answer but i want to give more proper answer.
first you need to import react-ga module
import ReactGA from 'react-ga';
and than whenever you initialize google analytics you can set userId there
ReactGA.initialize('UA-000000-01', {
gaOptions: {
userId: xxx-xxx-xxx-xxx
}
});
Or if you want to set userId after user logs into your system, than you can do the following way
1. initialize google analytics without userId
ReactGA.initialize('UA-000000-01');
2. and just after login you can set userId
ReactGA.set({ userId: 123 });
ref: https://github.com/react-ga/react-ga#reactgasetfieldsobject
You should not use an email address as that is personally identifiable information and as such to track it in GA is against Google's terms and conditions.
User ID ("userId") should be setup in the "initialize" or "set" GA command, not in an event. User ID is scoped to the user, so it shouldn't ever change for a user. Also, you'll have convert email to an anonymous (non-PII) id before it's used as userId
ReactGA.initialize('UA-000000-01', {
debug: true,
titleCase: false,
gaOptions: {
userId: 123
}
});
User ID doc: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#userId
I'm developing an e commerce website using angularjs in which I'm using paypal checkout https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/script-option... for paypal integration. When a user click's paypal rendered button, it is supposed to open a new popup window in which paypal login and payment is made, and then user is redirected to our app with payment details. The app seems to work fine in chrome, edge and even IE for that matter (although IE has different issue with the flow), but in firefox, the popup modal is not triggering at all. No console errors, which has made it very difficult to solve. Made a lot of research (google search :-p) but couldn't fix it. Please anyone help me, thanks.
Here is my script js for paypal
// Paypal
paypal.Button.render({
env: 'sandbox', // Environment: 'sandbox' or 'production'
// Pass the client ids to use to create your transaction on sandbox and production environments
client: {
sandbox: 'xxxxxx', // from https://developer.paypal.com/developer/applications/
production: 'xxxxxx' // from https://developer.paypal.com/developer/applications/
},
// Pass the payment details for your transaction
// See https://developer.paypal.com/docs/api/payments/#payment_create for the expected json parameters
payment: function() {
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [{
amount: {
total: 25.00,
currency: 'USD'
}
}]
});
},
// Display a "Pay Now" button rather than a "Continue" button
commit: true,
// Pass a function to be called when the customer completes the payment
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
console.log('The payment was completed!');
});
},
// Pass a function to be called when the customer cancels the payment
onCancel: function(data) {
// console.log('The payment was cancelled!');
}
}, '#paypal');
And html for rendering button
<button type="button" id="paypal"></button>