I'm making a shift from tipsi-stripe to stripe-react-native and I'm having some trouble getting confirmSetupIntent to work.
I'm getting a paymentIntentClientSecret from our server, and I have a custom credit card form from which I used to collect the card details and send in to confirmSetupIntent on tipsi-stripe, but it seems like that this doesn't work on stripe-react-native.
I'm calling the function like so, with some placeholder test data:
const result = await confirmSetupIntent(
clientSecret,
{
type: 'Card',
},
{
brand: 'Visa',
last4: '4242',
expiryYear: 22,
expiryMonth: 4,
postalCode: '90001',
}
)
console.log('Stripe confirmSetupIntent result', result)
And I get the following response:
I guess I'm not sure how Stripe expects the card details to be passed in. Has anyone else experienced the same issue? Any help is greatly appreciated!
Found the solution. It seems like we can only use the components provided by Stripe due to PCI DSS requirements. That's why this error occurs. Read more here.
Related
I am looking into the Payment Request API as a way to streamline payments on our site checkout and have run into a bit of a brick wall on how to use it with card payments. There are a few demos explaining how to use the payment request API, this one seemed to be the simplest and easiest to follow, but it is also quite out of date (as a lot of PR API demos i've found seem to be). Here is my code than runs when the payment button is clicked:
const paymentMethods = [
{
supportedMethods: ['basic-card', 'visa', 'mastercard', 'amex'],
data: {
supportedNetworks: ['visa', 'mastercard', 'amex']
}
}
];
const details = { total: { label: 'Test payment', amount: { currency: 'GBP', value: '1.00' } } };
// Show a native Payment Request UI and handle the result
const request = new PaymentRequest(paymentMethods, details);
request.show()
.then(response => {
console.log('yep');
console.log(response);
})
.catch(err => {
console.error(err);
});
I get the following error in the console:
Uncaught RangeError: Failed to construct 'PaymentRequest': Invalid payment method identifier format
I did some digging and found that the 'basic-card' supportedMethod is deprecated, and simple references to credit card providers don't seem to be supported anymore. The MDN docs for supportedMethods actually state
Starting with more recent browsers, this parameter is more generic than credit cards, it is a single string, and the meaning of the data parameter changes with the supportedMethods. For example, the Example Pay payment method is selected by specifying the string https://example.com/pay here.
Which is all well and good, but if i want to support Visa or Mastercard credit and debit card payments what URL do i use for them under supported methods? The payment processor for our website is Worldpay, so is this something i'd ask them for? Or do i need to find individual urls for Visa and Mastercard? I have done some googling and can't find anything relevant for either of them. Maybe i'm just bad at googling, but i don't really know how to proceed with this and wondered if anyone else had experience in setting up the payment request API to use credit and debit cards.
Oh, and i'm testing this in Chrome 103 btw.
Thanks
I am trying to understand eth_signTypedMessage with Metamask and a little toy example.
Code in Browser (using Metamask and Chrome):
ethereum.request({ method: 'eth_signTypedData', params: [
[
{
type: 'string',
name: 'testname',
value: '1234567890'
}
],
publicAddress
] }).then((signedData) => {
SendSignedDataToBackend(signedData);
});
I am trying to figure out how to calculate the message hash of the typed data, but I can't really get it straight with the standard:
Backend php code (using the old php ECRecover):
$typeHash = Keccak::hash('(string testname)',256); // Also no success without the brackets
$encodeData = keccak::hash("1234567890",256);
$typedMsgHash = keccak::hash(hex2bin($typeHash.$encodeData),256);
$ecRecover = new EcRecover();
$address = $ecRecover->personalEcRecover($typedMsgHash,$signedData);
This results in the wrong public address. Any advise?
After going through the code of Metamask, it seems that Metamask signs the plain message:
sign(message)
and not as I expected
sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)))
This does not seem to follow EIP-712, but maybe I misunderstood it. Removing the extra hash calculation of "\x19Ethereum ..." on the server solved the problem. $typeHash calculation is without the brackets in the code of my question. Also need to add an extra "0x" in my code:
$typedMsgHash = '0x'.keccak::hash(hex2bin($typeHash.$encodeData),256);
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 the Route 53 Node API to create and configure a hosted zone. Creating the zone works fine, but when I try to use the changeResourceRecordSets function to add an A record, I get an error that says 'InvalidInput: Invalid request' but doesn't say what is invalid about it. Here is my request params object:
var zoneConfig = {
ChangeBatch: {
Changes: [{
Action: 'CREATE',
ResourceRecordSet: {
Name: 'my.domain.com',
Type: 'A',
Region: 'us-east-1',
TTL: 300,
ResourceRecords: [{
Value: '111.222.111.000'
}]
}
}],
Comment: 'direct hosted zone A record to point to the server'
},
HostedZoneId: 'ZZH1GLJKE22DK'
};
rt53.changeResourceRecordSets( zoneConfig, function(...
Any ideas what might be wrong in the request?
Finally figured it out. The problem was the Region field in the ResourceRecordSet. I missed it in the documentation, but that is only to be used for latency-based resource record sets. So, deleting that line fixed the issue
Really wish the API error message could have just said that.
This is a basic question, but I am new to JavaScript, and I want to use some Chrome APIs. My problem lies in understanding what the page is trying to tell me, for instance, what do they mean by types on this page? How would I create a message using the details on that page for a message? I apologize if it seems like a newb question, but I am new to this and am completely lost.
Basically I am trying to better understand what is meant by type. Does that mean I have to create variables that satisfy the parameters of that type? SO for the execute method, I would pass it a variable that satisfies the type of a message? Thanks!
var message = ("type","payload");
chrome.copresence.execute([message], function callback)
Untested due to the lack of a supported device:
chrome.copresence.execute([
{
publish: {
id: "someID",
message: {type: "joke", payload: data},
timeToLiveMillis: 1000,
policy: {onlyEarshot: true}
}
}
], function(status) {
console.log(status);
});
payload is an ArrayBuffer per documentation, so to send a string you'd have to convert it (I guess) like this, for example:
var data = new TextEncoder("utf8").encode("Hello, world!").buffer;