douxian6260 2017-02-12 21:35
浏览 163

使用PayPal iOS SDK与WooCommerce

I am working on iOS app using XCode 8.2.1 and Swift 3.0 for a WooCommerce Store website.

What I am trying to do is to allow the user to pay for the order using PayPal iOS SDK inside the app then after receiving the payment success confirmation from the SDK programatically add the order to WooCommerce as paid using PayPal without the need to login to wordpress and proceed to checkout by the user, how to achieve this approach?

Here is my code to create the order on WooCommerce:-

try {
    $api = WC()->api->WC_API_Orders;
    $orderData = $api->create_order($this->data);
    $order = $orderData["order"];
} catch (Exception $e) {
    error_log("Caught $e");
}

Here is the swift code from the paypal ios sdk once the payment succeeded:-

func payPalPaymentViewController(_ paymentViewController: PayPalPaymentViewController, didComplete completedPayment: PayPalPayment) {
    print("PayPal Payment Success !")
    paymentViewController.dismiss(animated: true, completion: { () -> Void in
        // send completed confirmaion to your server
        print("Here is your proof of payment:

\(completedPayment.confirmation)

Send this to your server for confirmation and fulfillment.")

        self.resultText = completedPayment.description
        self.showSuccess()
    })
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab中使用gurobi时报错
    • ¥15 WPF 大屏看板表格背景图片设置
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂