sorokin0andrey / react-native-apay

React Native bridge for Apple Pay
55 stars 30 forks source link

PaymentMethod data is missing #13

Open ramisalem opened 4 years ago

ramisalem commented 4 years ago

Hi I am integrating Payfort payment gateway but for some reason, the following data from the example do not come to me, they do not exist at all. Also, Checking on a real device. No errors occur

What is missing in the response from apple pay is paymentMethod

// paymentMethod example 
{ 
"paymentMethod": { "network": "MasterCard", "type": "credit", "displayName": "MasterCard 4248"

}

What comes to me:

'{
"paymentData": {
"version": "EC_v1",
"data": "string",
"signature": "string",
"header": {
"ephemeralPublicKey": "string",
"publicKeyHash": "string",
"transactionId": "string"
}
},
"transactionIdentifier": "string"
}  

Do you know what should I do to get paymentMethod ? Thanks for the fixes

mindnervestech commented 4 years ago

Please change the below content in this file node_module/react-native-apay/ios/RNApplePay.m

import "RNApplePay.h"

import <React/RCTUtils.h>

@implementation RNApplePay

RCT_EXPORT_METHOD(requestPayment:(NSDictionary )props promiseWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { PKPaymentRequest paymentRequest = [[PKPaymentRequest alloc] init]; paymentRequest.merchantCapabilities = PKMerchantCapability3DS; paymentRequest.merchantIdentifier = props[@"merchantIdentifier"]; paymentRequest.countryCode = props[@"countryCode"]; paymentRequest.currencyCode = props[@"currencyCode"]; paymentRequest.supportedNetworks = [self getSupportedNetworks:props]; paymentRequest.paymentSummaryItems = [self getPaymentSummaryItems:props];

self.viewController = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest: paymentRequest];
self.viewController.delegate = self;
dispatch_async(dispatch_get_main_queue(), ^{
    UIViewController *rootViewController = RCTPresentedViewController();
    [rootViewController presentViewController:self.viewController animated:YES completion:nil];
    self.requestPaymentResolve = resolve;
});

}

RCT_EXPORT_METHOD(complete:(NSNumber *_Nonnull)status promiseWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { if (self.completion != NULL) { self.completeResolve = resolve; if ([status isEqualToNumber: self.constantsToExport[@"SUCCESS"]]) { self.completion(PKPaymentAuthorizationStatusSuccess); } else { self.completion(PKPaymentAuthorizationStatusFailure); } self.completion = NULL; } }

@end

Then you will get complete data, which you have required.