Checkpoint commit. Fix p97 integration
This commit is contained in:
parent
eeb5f9d002
commit
74db3283cf
|
@ -1,6 +1,7 @@
|
|||
import { Platform } from 'react-native';
|
||||
import RNLocation from 'react-native-location';
|
||||
import EP from './endpoints.js';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
export default async function API(endpoint, method, headers, params, body, onSuccess, onError) {
|
||||
let deviceID = DeviceInfo.getDeviceId();
|
||||
|
@ -8,6 +9,7 @@ export default async function API(endpoint, method, headers, params, body, onSuc
|
|||
let OS = Platform.OS;
|
||||
let appBundleID = OS === 'android' ? "com.project.yondu.unioilloyaltyapp" : "com.rnunioilloyaltyapp";
|
||||
let versionRelease = DeviceInfo.getBuildNumber();
|
||||
let location = await RNLocation.getLatestLocation(latestLocation => latestLocation);
|
||||
|
||||
try {
|
||||
if(method == "post") {
|
||||
|
@ -16,6 +18,8 @@ export default async function API(endpoint, method, headers, params, body, onSuc
|
|||
'Content-Type': 'application/json',
|
||||
'x-p97-tenantid': '8ba3cd89-74be-4a7a-91a5-5eb59a2040b8',
|
||||
'x-p97-apikey': EP.post_pay_api_key,
|
||||
'x-p97-latitude': location.latitude,
|
||||
'x-p97-longitude': location.longitude,
|
||||
'x-p97-deviceid': deviceID,
|
||||
'x-p97-appversionnumber': versionNumb,
|
||||
'x-p97-appbundleid': appBundleID,
|
||||
|
@ -47,6 +51,8 @@ export default async function API(endpoint, method, headers, params, body, onSuc
|
|||
'Content-Type': 'application/json',
|
||||
'x-p97-tenantid': '8ba3cd89-74be-4a7a-91a5-5eb59a2040b8',
|
||||
'x-p97-apikey': EP.post_pay_api_key,
|
||||
'x-p97-latitude': location.latitude,
|
||||
'x-p97-longitude': location.longitude,
|
||||
'x-p97-deviceid': deviceID,
|
||||
'x-p97-appversionnumber': versionNumb,
|
||||
'x-p97-appbundleid': appBundleID,
|
||||
|
@ -58,7 +64,6 @@ export default async function API(endpoint, method, headers, params, body, onSuc
|
|||
|
||||
if(endpoint.includes("/")) {
|
||||
const newURL = endpoint.split("/");
|
||||
console.log(newURL);
|
||||
url = newURL[0].includes(":") ? newURL[0] : EP[newURL[0]];
|
||||
url = `${url}/${newURL[1]}`;
|
||||
} else {
|
||||
|
|
|
@ -68,25 +68,31 @@ class PayatpumpStationTransactionDetails extends React.Component {
|
|||
}
|
||||
|
||||
getTransactionDetails = async (claimId, fundingProviderName, userPaymentSourceId, onSuccess, onError) => {
|
||||
let cardNumber = this.state.selectedPaymentCard.firstSix.replace(" ", "") + this.state.selectedPaymentCard.lastFour;
|
||||
|
||||
if(claimId == null) {
|
||||
Alert.alert("Error", "No transaction id exist.")
|
||||
return
|
||||
}
|
||||
|
||||
let length = 8
|
||||
let partnerTransactionId = parseInt((Math.random() * 9 + 1) * Math.pow(10, length-1), 10)
|
||||
let params = {
|
||||
claimId: claimId,
|
||||
partnerTransactionId: partnerTransactionId,
|
||||
walletRequest: {
|
||||
fundingProviderName: fundingProviderName, //change this value later
|
||||
currencyCode: "PHP",
|
||||
partnerTransactionId: "93931",
|
||||
walletRequests: [{
|
||||
fundingProviderName: fundingProviderName,
|
||||
fundingPayload: {
|
||||
userPaymentSourceId: userPaymentSourceId //change this value later
|
||||
userPaymentSourceId: userPaymentSourceId
|
||||
}
|
||||
},
|
||||
}, {
|
||||
fundingProviderName: "loyalty_points",
|
||||
fundingPayload: {
|
||||
"paymentToken": cardNumber,
|
||||
"points": 0
|
||||
}
|
||||
}],
|
||||
userPreference: {
|
||||
receiptPreference: "doNotPrintReceipt", //printReceipt, doNotPrintReceipt
|
||||
emailReceiptPreference: true
|
||||
},
|
||||
loyaltyPassthroughInformation: {
|
||||
loyaltyInfo: []
|
||||
|
@ -100,6 +106,7 @@ class PayatpumpStationTransactionDetails extends React.Component {
|
|||
token: USER_PROFILE.data.auth_p97,
|
||||
language: 'en-US'
|
||||
}, {}, params, async (res) => {
|
||||
console.log(res);
|
||||
if(res.success && res.response != undefined && res.response.status == "success") {
|
||||
REQUEST_POST_PAY('getTransactionDetails/'+res.response.transaction_id, "get", {
|
||||
token: USER_PROFILE.data.auth_p97,
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue