react-native-hyperpay-sdk 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/HyperPay.h +3 -1
- package/ios/HyperPay.m +24 -21
- package/package.json +1 -1
package/ios/HyperPay.h
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
#import <React/RCTBridgeModule.h>
|
|
5
5
|
#import <React/RCTEventEmitter.h>
|
|
6
6
|
|
|
7
|
-
@interface HyperPay : RCTEventEmitter <RCTBridgeModule>
|
|
7
|
+
@interface HyperPay : RCTEventEmitter <RCTBridgeModule, OPPCheckoutProviderDelegate>
|
|
8
|
+
|
|
9
|
+
@property(nonatomic, strong) OPPCheckoutProvider *checkoutProvider;
|
|
8
10
|
|
|
9
11
|
@end
|
|
10
12
|
|
package/ios/HyperPay.m
CHANGED
|
@@ -101,35 +101,32 @@ RCT_EXPORT_METHOD(createPaymentTransaction: (NSDictionary*)options resolver:(RCT
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
RCT_EXPORT_METHOD(applePay:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
OPPCheckoutSettings *checkoutSettings = [[OPPCheckoutSettings alloc] init];
|
|
106
106
|
PKPaymentRequest *paymentRequest = [OPPPaymentProvider paymentRequestWithMerchantIdentifier:merchantIdentifier countryCode:countryCode];
|
|
107
107
|
paymentRequest.supportedNetworks = supportedNetworks;
|
|
108
|
-
|
|
108
|
+
// paymentRequest.merchantCapabilities = PKMerchantCapability3DS;
|
|
109
|
+
|
|
110
|
+
if ([params valueForKey:@"companyName"]) {
|
|
111
|
+
companyName = [params valueForKey:@"companyName"];
|
|
112
|
+
}
|
|
109
113
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
NSDecimalNumber *amount = [NSDecimalNumber decimalNumberWithMantissa:[[params valueForKey:@"amount"] intValue] exponent:-2 isNegative:NO];
|
|
114
|
-
paymentRequest.paymentSummaryItems = @[[PKPaymentSummaryItem summaryItemWithLabel:companyName amount:amount]];
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
checkoutSettings.shopperResultURL=shopperResultURL;
|
|
114
|
+
NSDecimalNumber *amount = [NSDecimalNumber decimalNumberWithMantissa:[[params valueForKey:@"amount"] intValue] exponent:-2 isNegative:NO];
|
|
115
|
+
paymentRequest.paymentSummaryItems = @[ [PKPaymentSummaryItem summaryItemWithLabel:companyName amount:amount] ];
|
|
116
|
+
checkoutSettings.shopperResultURL = shopperResultURL;
|
|
118
117
|
checkoutSettings.applePayPaymentRequest = paymentRequest;
|
|
119
|
-
OPPCheckoutProvider *checkoutProvider = [OPPCheckoutProvider checkoutProviderWithPaymentProvider:provider
|
|
120
|
-
checkoutID:[params valueForKey:@"checkoutID"]
|
|
121
|
-
settings:checkoutSettings];
|
|
122
118
|
|
|
123
|
-
|
|
119
|
+
self.checkoutProvider = [OPPCheckoutProvider checkoutProviderWithPaymentProvider:provider
|
|
120
|
+
checkoutID:[params valueForKey:@"checkoutID"]
|
|
121
|
+
settings:checkoutSettings];
|
|
122
|
+
self.checkoutProvider.delegate = self;
|
|
123
|
+
|
|
124
|
+
[self.checkoutProvider presentCheckoutWithPaymentBrand:@"APPLEPAY"
|
|
124
125
|
loadingHandler:^(BOOL inProgress) {
|
|
125
126
|
[self sendEventWithName:@"onProgress" body:@(inProgress)];
|
|
126
|
-
// Executed whenever SDK sends request to the server or receives the response.
|
|
127
|
-
// You can start or stop loading animation based on inProgress parameter.
|
|
128
127
|
} completionHandler:^(OPPTransaction * _Nullable transaction, NSError * _Nullable error) {
|
|
129
128
|
if (error) {
|
|
130
|
-
|
|
131
|
-
reject(@"applePay",error.localizedDescription, error);
|
|
132
|
-
// See code attribute (OPPErrorCode) and NSLocalizedDescription to identify the reason of failure.
|
|
129
|
+
reject(@"applePay", error.localizedDescription, error);
|
|
133
130
|
} else {
|
|
134
131
|
if (transaction.redirectURL)
|
|
135
132
|
resolve(@{@"redirectURL": transaction.redirectURL.absoluteString});
|
|
@@ -137,12 +134,18 @@ RCT_EXPORT_METHOD(applePay:(NSDictionary*)params resolver:(RCTPromiseResolveBloc
|
|
|
137
134
|
resolve(@{@"resourcePath": transaction.resourcePath});
|
|
138
135
|
}
|
|
139
136
|
} cancelHandler:^{
|
|
140
|
-
|
|
141
|
-
// Executed if the shopper closes the payment page prematurely.
|
|
137
|
+
reject(@"applePay", @"cancel", NULL);
|
|
142
138
|
}];
|
|
143
139
|
|
|
144
140
|
}
|
|
145
141
|
|
|
142
|
+
#pragma mark - OPPCheckoutProviderDelegate
|
|
143
|
+
|
|
144
|
+
- (void)checkoutProvider:(OPPCheckoutProvider *)checkoutProvider
|
|
145
|
+
continueSubmitting:(OPPTransaction *)transaction
|
|
146
|
+
completion:(void (^)(NSString * _Nullable, BOOL))completion {
|
|
147
|
+
completion(nil, YES);
|
|
148
|
+
}
|
|
146
149
|
|
|
147
150
|
@end
|
|
148
151
|
|