PayPal API with Laravel - Updating of data

前端 未结 4 675
囚心锁ツ
囚心锁ツ 2021-02-14 10:51

I\'m trying to implement the API of PayPal payment with Laravel 5.1. But when I log in to PayPal (sandbox), it uses the addre

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-14 11:25

    After you have created the payment, try updating the address as shown in this example.

    $paymentId = $createdPayment->getId();
    
    $patch = new \PayPal\Api\Patch();
    $patch->setOp('add')
        ->setPath('/transactions/0/item_list/shipping_address')
        ->setValue([
            "recipient_name" => "Gruneberg, Anna",
            "line1" => "52 N Main St",
            "city" => "San Jose",
            "state" => "CA",
            "postal_code" => "95112",
            "country_code" => "US"
        ]);
    
    $patchRequest = new \PayPal\Api\PatchRequest();
    $patchRequest->setPatches([$patch]);
    $result = $createdPayment->update($patchRequest, $apiContext);
    

    I also reviewed this link but it seems like it cannot answer my problem. Also, what if the country has a province? How can we add that?

    Use the state codes listed here.

提交回复
热议问题