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