Open KthProg opened 6 years ago
In test mode it works fine, in that case I don't get a token back though.
It looks like the onActivityResult
callback is not being called
It appeared to be fixed by adding this to my main activity class:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
((ReactInstanceManager)(Object)mReactInstanceManager.get()).onActivityResult(this, requestCode, resultCode, data );
}
Based on this issue: https://stackoverflow.com/questions/36335484/react-native-onactivityresult-not-work
The original issue still remains. This only fixes the issue in the TEST
environment.
@naoufal Any idea what's causing this?
Here's my code (edited):
import React from 'react';
import { View } from 'react-native';
import { PaymentRequest } from 'react-native-payments';
import { logger } from 'react-native-logger';
export default class Market extends React.Component {
static paymentMethodData = [{
supportedMethods: ['android-pay'],
data: {
supportedNetworks: ['visa', 'mastercard', 'amex'],
currencyCode: 'USD',
//environment: 'TEST',
paymentMethodTokenizationParameters: {
tokenizationType: 'GATEWAY_TOKEN',
parameters: {
gateway: 'stripe',
'stripe:publishableKey': Defaults.stripePubKeyLive,
'stripe:version': '2018-07-27' // Only required on Android
}
}
}
}];
constructor(props){
super(props);
// ...
}
purchaseCard(card){
const paymentDetails = {
displayItems: [
{
label: 'CardLife Market - ' + card.name,
amount: { currency: 'USD', value: card.cost }
}
],
total: {
label: '2e Soft',
amount: { currency: 'USD', value: card.cost }
}
};
const paymentRequest = new PaymentRequest(Market.paymentMethodData, paymentDetails);
paymentRequest.show().then(paymentResponse => {
const { getPaymentToken } = paymentResponse.details;
return getPaymentToken()
.then(paymentToken => {
// server code here
}).catch(failure => {
paymentResponse.complete('failure');
});
}).catch(failure => {
paymentRequest.abort();
})
}
render() {
return (
<View>
// ...
</View>
);
}
}
It looks like you have to request production access for your merchant id. THis should be included in the documentation: (https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist)
I'm facing same issue and I am Implement this library https://github.com/JadavChirag/react-native-GPay. and Its working fine for me. It build production and development fine as well as :)
I'm facing same issue and I am Implement this library https://github.com/JadavChirag/react-native-GPay. and Its working fine for me. It build production and development fine as well as :)
Thanks Its also work for me. :)
It's not clear how I would enable my account for Google Pay and following the docs exactly does not work. I am trying to use Stripe although I would be fine with using Google Pay directly.