Skip to content

Commit

Permalink
Manage ios and android sumup foreignTransactionId
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlevy0 committed Dec 23, 2018
1 parent 0c7a1d8 commit fcedb29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions android/src/main/java/com/nextar/sumup/RNSumUpModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]")
// .receiptSMS("+3531234567890")
.foreignTransactionId(foreignTransactionId)
.skipSuccessScreen()
.build();
SumUpAPI.checkout(getCurrentActivity(), payment, REQUEST_CODE_PAYMENT);
Expand Down
5 changes: 5 additions & 0 deletions ios/RNSumUp.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand All @@ -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) {
Expand Down

0 comments on commit fcedb29

Please sign in to comment.