Skip to content

Commit

Permalink
fix: put result to map and send to application
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanRybakEk committed Aug 31, 2021
1 parent f2fb986 commit 5231acb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions android/src/main/java/com/reactnativepaypal/PaypalModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ class PaypalModule(private val reactContext: ReactApplicationContext?) :
val orderId = parameters.getString("orderId") ?: ""
createOrderActions.set(orderId)
},
onApprove = OnApprove { approval -> promise.resolve(approval.data) },
onApprove = OnApprove { approval ->
run {
val result = Arguments.createMap()
result.putString("orderId", approval.data.orderId)
result.putString("payerId", approval.data.payerId)
result.putString("paymentId", approval.data.paymentId)
promise.resolve(result)
}
},
onCancel = OnCancel {
promise.reject(
parameters.getString("cancelErrorCode") ?: PAYPAL_CANCEL_DEFAULT_CODE,
Expand All @@ -44,4 +52,4 @@ class PaypalModule(private val reactContext: ReactApplicationContext?) :
onError = OnError { errorInfo -> promise.reject(PAYPAL_ERROR_CODE, errorInfo.reason) }
)
}
}
}

0 comments on commit 5231acb

Please sign in to comment.