Question regarding Payment V2 API (Using PHP SDK)

bbroerman30
Contributor
Contributor

I have a website that I've just integrated with PayPal. I'm using the PHP SDK on the back-end and the JavaScript front-end.

When creating the order id to pass back to the JavaScript, I am creating an order with a list of items with a category of "DIGITAL_GOODS"... Yet, paypal is still asking for shipping information, tracking info, etc. and putting a hold on my funds until the user "receives" the shipment... 

 

So, How do I streamline this and get PayPal to acknowledge that there is no shipment, and these are not tangible goods?

 

The items are build in a loop, and the total amount is calculated:
$purchase_items[] = array(
                            'name' => 'Payment to Scout Account',
                            'description' => 'Payment to ' . $unit_name .' Scout Account, for ' . $scout['name'],
                            'sku' => 'pymt',
                            'unit_amount' => array(
                                'currency_code' => 'USD',
                                'value' => number_format( floatval($scout['amount']), 2, ".","" )
                                ),
                            'quantity' => '1',
                            'category' => 'DIGITAL_GOODS',
                        );

Then the request body is generated for the PayPal call:

    $request->body = array(
            'intent' => 'CAPTURE',
            'application_context' =>
                array(
                    'return_url' => 'https://742scouts.org/user.php?action=paypalsuccess',
                    'cancel_url' => 'https://742scouts.org/user.php?action=paypalcancel'
                ),
            'purchase_units' =>
                array(
                    0 =>
                        array(
                            'description' => 'Payment to ' . $unit_name .' Scout Account',
                            'soft_descriptor' => 'ScoutAccount',
                            'amount' =>
                                array(
                                    'currency_code' => 'USD',
                                    'value' => number_format( floatval($total_amount), 2, ".","" )
                                )
                        )
                ),
            'items' => $purchase_items
    );

Finally, the paypal call is made:

$client = PayPalClient::getClient();
        
   $response = null;
    try {
        // Make the call.
        $logger->debug(" Sending request to PayPal: " . json_encode($request->body) );
        $response = $client->execute($request);
    } catch( Exception $e ) {
        $logger->error('Exception caught making PayPal Call: ' . $e->getMessage() . "\n" . $e->getTraceAsString() );
        $response = array('statusCode' => 500);
    }

    $logger->debug(" Returning: " . json_encode(array('orderID'=> $response->result->id)) );
    print json_encode(array('orderID'=> $response->result->id));
    http_response_code(200);
Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.