diff --git a/android/src/main/java/com/nextar/sumup/RNSumUpModule.java b/android/src/main/java/com/nextar/sumup/RNSumUpModule.java index 63a73c9..69dc7e6 100644 --- a/android/src/main/java/com/nextar/sumup/RNSumUpModule.java +++ b/android/src/main/java/com/nextar/sumup/RNSumUpModule.java @@ -134,15 +134,22 @@ private SumUpPayment.Currency getCurrency(String currency) { @ReactMethod public void checkout(ReadableMap request, Promise promise) { - // TODO: replace foreignTransactionId for transaction UUID sent by user. mSumUpPromise = promise; try { + String foreignTransactionId = UUID.randomUUID().toString(); + if (request.getString("foreignTransactionId") != null) { + foreignTransactionId = request.getString("foreignTransactionId"); + } SumUpPayment.Currency currencyCode = this.getCurrency(request.getString("currencyCode")); SumUpPayment payment = SumUpPayment.builder() .total(new BigDecimal(request.getString("totalAmount")).setScale(2, RoundingMode.HALF_EVEN)) .currency(currencyCode) .title(request.getString("title")) - .foreignTransactionId(UUID.randomUUID().toString()) + // Wait for ios imp + // .addAdditionalInfo("AccountId", "taxi0334") + // .receiptEmail("customer@mail.com") + // .receiptSMS("+3531234567890") + .foreignTransactionId(foreignTransactionId) .skipSuccessScreen() .build(); SumUpAPI.checkout(getCurrentActivity(), payment, REQUEST_CODE_PAYMENT); diff --git a/ios/RNSumUp.m b/ios/RNSumUp.m index 22d1030..6834d98 100644 --- a/ios/RNSumUp.m +++ b/ios/RNSumUp.m @@ -124,6 +124,7 @@ - (NSDictionary *)constantsToExport NSDecimalNumber *total = [NSDecimalNumber decimalNumberWithString:[RCTConvert NSString:request[@"totalAmount"]]]; NSString *title = [RCTConvert NSString:request[@"title"]]; NSString *currencyCode = [RCTConvert NSString:request[@"currencyCode"]]; + NSString *foreignTransactionID = [RCTConvert NSString:[request objectForKeyNotNull:@"foreignTransactionId"]]; NSUInteger paymentOption = [RCTConvert SMPPaymentOptions:request[@"paymentOption"]]; NSUInteger skipScreen = [RCTConvert SMPSkipScreenOptions:@"1"]; @@ -132,6 +133,10 @@ - (NSDictionary *)constantsToExport currencyCode:currencyCode paymentOptions:paymentOption]; checkoutRequest.skipScreenOptions = skipScreen; + if (foreignTransactionID != [NSNull null]) { + [checkoutRequest setForeignTransactionID:foreignTransactionID]; + } + dispatch_sync(dispatch_get_main_queue(), ^{ UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController; while (rootViewController.presentedViewController != nil) {