在 iOS SDK 中为 OrderRequest 传递多个 purchaseUnits 时,Paypal SDK 出错

Paypal SDK getting error when passing more than one purchaseUnits for OrderRequest in iOS SDK

我的paypal sdk代码如下

func makePaypalPayment(amount:String,userEmail:String,eChitthiAmount:String) {
         Checkout.start(
            createOrder: { createOrderAction in
            // This order is for eChitthi
            let amountForeChitthi = PurchaseUnit.Amount(currencyCode: .usd, value: eChitthiAmount)
            let purchaseUnitForeChitthi = PurchaseUnit(amount: amountForeChitthi)
            
            // This order is for user
            let amount = PurchaseUnit.Amount(currencyCode: .usd, value: amount)
            let payeeDetail = PurchaseUnit.Payee(emailAddress:userEmail)
            let purchaseUnit = PurchaseUnit(amount: amount,payee: payeeDetail)
            let order : OrderRequest = OrderRequest(intent: .capture, purchaseUnits: [purchaseUnit,purchaseUnitForeChitthi])
            createOrderAction.create(order: order)
            
        }, onApprove: { approval in
            approval.actions.capture { (response, error) in
                print("Payment successfully")
            }
        }, onCancel: {
            print("Order is cancelled.")
        }, onError: { error in
            print("Order have some error.")
        }
    )
}

这里我想一次支付两笔交易。比如用户想转账 100 美元给他的朋友,那么 1% 的费用将转给应用程序的所有者。

所以在我的场景中,如果用户 A 想向用户 B 转账 100 美元,那么总计 101 美元将从用户 A 的贝宝账户中扣除,100 美元转到用户 B 的账户,1 美元转到应用程序的所有者账户。为此,我创建了两个 PurchaseUnit 对象并将它们传递给 OrderRequest。因为得到 操作无法完成。 (OrderActionError 错误 202。)

我正在使用 SDK:PayPalCheckout (0.73.0)

语言:Swift

帮助(我已经实现了这篇文档中的代码)- https://developer.paypal.com/docs/business/native-checkout/ios/programmatically-start-sdk/

如有任何帮助,我们将不胜感激。谢谢

在订单创建请求中指定多个 purchase_units 时,每个都必须具有唯一的 reference_id,因为它们是独立的付款,可能单独成功或失败。它们还将导致独立的 PayPal 交易。

这记录在 https://developer.paypal.com/docs/api/orders/v2/#orders-create-request-body