Closed adeojoemmanuel closed 5 years ago
Hi, please can you show the full .js file where you are calling RNPaystack.init, the issue might be where you are calling it from
I did not call
Helo pls I have issue on dis help me resolve it i get the error
`you should call init first higer up your code https://github.com/tolu360/react-native-paystack#3-usagei get this error
Helo pls I have issue on dis help me resolve it i get the error
`you should call init first higer up your code https://github.com/tolu360/react-native-paystack#3-usagei get this error
Hi @hammedismail54, Can you share a screenshot of where you are calling RNPaystack.init({ publicKey: 'YOUR_PUBLIC_KEY_HERE' });
?
I did not call Hi @onyiiamala, You should actually, when using the library you have to first call
RNPaystack.init({ publicKey: 'YOUR_PUBLIC_KEY_HERE' });
higher up in your codebase (maybe in yourcomponentDidMount
or yourconstructor
)
Hw do I call RNPaystack.init
How do i call init
How can i get the loan without calling init because i don't even know how to call init
Step 1: Create a JS file and paste the JS class below
import RNPaystack from 'react-native-paystack';
/**
* This class handles all implementation details used to communicate with paystack
* @class
* @param {} onSuccessFunction Callback function to be called when the transaction and verification is successful
* @param {} onErrorFunction Callback function to be called when the transaction and/or verrification fails
*/
export class Paystack {
constructor(onSuccessFunction, onErrorFunction, sandboxMode = false) {
this.onSuccessFunction = onSuccessFunction;
this.onErrorFunction = onErrorFunction;
RNPaystack.init({
publicKey: '<ENTER_PUBLIC_KEY_FROM_PAYSTACK_HERE>',
});
this.sandboxMode = sandboxMode;
}
// function that calls the paystack verification endpoint
verifyTransaction = (referenceID) => {
fetch('<PAYSTACK_VERIFICATION_URL_WITH_REFERENCE_ID>', {
headers: { <read paystack documentattion to know which header to use here >},
})
.then(responsePlain => responsePlain.json())
.then((response) => {
const { data } = response;
if (response.status && data.status === 'success') {
this.onSuccessFunction(response);
} else {
this.onErrorFunction(response);
}
})
.catch(error => this.onErrorFunction(error));
};
// removes object values with empty strings
cleanObjectPayload = (payload) => {
const keys = Object.keys(payload);
const payloadToSend = {};
keys.forEach((key) => {
if (payload[key] !== '') {
payloadToSend[key] = payload[key];
}
});
return payloadToSend;
};
// function that actually charges the card
chargeCard({
cardNumber = '',
expiryMonth = '',
expiryYear = '',
cvc = '',
email = '',
amountInKobo = '',
subAccount = '',
} = {}) {
const inputToSend = this.cleanObjectPayload({
cardNumber: cardNumber,
expiryMonth,
expiryYear,
cvc,
email,
amountInKobo,
subAccount,
});
console.log(inputToSend);
RNPaystack.chargeCard(inputToSend)
.then((response) => {
if (this.sandboxMode) {
this.onSuccessFunction(response);
} else {
this.verifyTransaction(response.reference);
}
})
.catch((error) => {
this.onErrorFunction(error);
});
}
}
export default Paystack;
Then use it like below in your React class:
constructor(props) {
super(props);
this.paystack = new PaystackService(this.onSuccess, this.onError, true);
}
onSuccess = (data) => {
// function to run if the transaction is successful
};
onError = (error) => {
// handle the error if the payment fails
};
handlePayment = () => {
this.paystack.chargeCard({
cardNumber: 3222333300987776,
expiryMonth: 12,
expiryYear: 30,
cvc: 110,
email: '<email address>',
amountInKobo: 5000000,
});
};
I don't even understand what to do
Because I got the same init error
Where do I create js
Where do I create js Wherever you want, you can place it in any folder within your project and import it into where you want to use it
Good day, i actually applied for a loan on soft cash and it came up so how do i use it on the app
On Fri, Feb 8, 2019, 4:12 PM sammy <notifications@github.com wrote:
Where do I create js Wherever you want, you can place it in any folder within your project and import it into where you want to use it
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tolu360/react-native-paystack/issues/25#issuecomment-461834375, or mute the thread https://github.com/notifications/unsubscribe-auth/AtQV-S9o3ChtvUSiiVSAeiMKobWvpTGkks5vLZP0gaJpZM4aGgtr .
can you please help me with this?
On Fri, Feb 8, 2019, 4:16 PM paul itoadon <paulitoadon@gmail.com wrote:
Good day, i actually applied for a loan on soft cash and it came up so how do i use it on the app
On Fri, Feb 8, 2019, 4:12 PM sammy <notifications@github.com wrote:
Where do I create js Wherever you want, you can place it in any folder within your project and import it into where you want to use it
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tolu360/react-native-paystack/issues/25#issuecomment-461834375, or mute the thread https://github.com/notifications/unsubscribe-auth/AtQV-S9o3ChtvUSiiVSAeiMKobWvpTGkks5vLZP0gaJpZM4aGgtr .
please can i get a step by step on how to go about this?
On Fri, Feb 8, 2019, 4:18 PM paul itoadon <paulitoadon@gmail.com wrote:
can you please help me with this?
On Fri, Feb 8, 2019, 4:16 PM paul itoadon <paulitoadon@gmail.com wrote:
Good day, i actually applied for a loan on soft cash and it came up so how do i use it on the app
On Fri, Feb 8, 2019, 4:12 PM sammy <notifications@github.com wrote:
Where do I create js Wherever you want, you can place it in any folder within your project and import it into where you want to use it
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tolu360/react-native-paystack/issues/25#issuecomment-461834375, or mute the thread https://github.com/notifications/unsubscribe-auth/AtQV-S9o3ChtvUSiiVSAeiMKobWvpTGkks5vLZP0gaJpZM4aGgtr .
@hammedismail54 @oseme2 @onyiiamala
This is a library for developers integrating Paystack not for customers of a merchant using Paystack. Please reach out to the support team of the business you are trying to get a loan from so they can help you. This discussion is for developers
okay sir/ma
On Sun, Feb 10, 2019, 8:48 AM Stephen Amaza <notifications@github.com wrote:
@hammedismail54 https://github.com/hammedismail54 @oseme2 https://github.com/oseme2 @onyiiamala https://github.com/onyiiamala
This is a library for developers integrating Paystack not for customers of a merchant using Paystack. Please reach out to the support team of the business you are trying to get a loan from so they can help you. This discussion is for developers
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tolu360/react-native-paystack/issues/25#issuecomment-462111290, or mute the thread https://github.com/notifications/unsubscribe-auth/AtQV-RHwXF1o-3qqAyQVhqB3iD2h0TYlks5vL87JgaJpZM4aGgtr .
I need a loan from your company, but each time i applied, i always receive increase your Init code. Please what does that stands for?
I need a loan from your company, but each time i applied, i always receive increase your Init code. Please what does that stands for?
@tolu360 can you please call this issue :) @onyiiamala please email support@paystack.com
Am getting issue on my softcash app when applying for a load after filling every details its indicating I should call init can someone explain to me better how I can go about it.
Hi Softcash Dev, please update your app and stop showing these errors to your users - they are mainly just for your benefits. Thank you!
i get the error
you should call init first higer up your code https://github.com/tolu360/react-native-paystack#3-usagei get this error "
even after calling
RNPaystack.init({ publicKey: 'pk_live_7df3a55391cd5a9dc3fe2eeb27a20d3d295feb0d' });
right benit my import