# Make payment in php to RAPYD COLLECT

**URL:** <https://community.rapyd.net/t/make-payment-in-php-to-rapyd-collect/482>\
**Category:** 🙋🏽‍♀️🙋🏽‍♂️ Ask Questions\
**Created:** [June 17, 2021, 7:00am UTC](https://community.rapyd.net/t/make-payment-in-php-to-rapyd-collect/482 "2021-06-17T07:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredjinbility](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@fredjinbility](https://community.rapyd.net/u/fredjinbility)\
**Post date:** [June 17, 2021, 7:00am UTC](https://community.rapyd.net/t/make-payment-in-php-to-rapyd-collect/482/1 "2021-06-17T07:00:00Z")

</div>

Am trying to make payments to a wallets using Rapyd Collect in php following the 2 sample code below but it print **null Value** as result

[https://docs.rapyd.net/build-with-rapyd/reference/payment-object](https://docs.rapyd.net/build-with-rapyd/reference/payment-object)

**sample code 1;**

```auto

<?php

$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/payments/utilities.php";
include($path);
$body = [
    'receipt_email' => 'johndow@rapyd.net',
     "amount"=> 100,
    "currency"=> "USD",
    "description"=> "Payment by card token",
    "payment_method"=> "card_823894ee89c52be00e76d2be10116672",
    "complete_payment_url"=> "http://localhost/success.php",
  "ewallets"=> [
            "ewallet"=> "ewalletmy-ewallet-id-goes-here",
            "percentage"=> 100
        
    ],

     "address"=> [
        "name"=> 'John Doe',
        "line_1"=> '123 Main Street',
        "line_2"=> 'Penthouse',
        "line_3"=> '',
        "city"=> 'Anytown',
        "district"=> '',
        "canton"=> '',
        "state"=> 'NY',
        "country"=> 'US',
        "zip"=> '12345',
        "phone_number"=> '16125551234'
      ]
];

try {
    $object = make_request('post', '/v1/payments/payment_19e3edad1e9102cd24006a34c52c9a0b', $body);
    var_dump($object);
} catch(Exception $e) {
    echo "Error: $e";
}

exit();

?>

```

I think the problem is value for **payment\_19e3edad1e9102cd24006a34c52c9a0b** or **card\_823894ee89c52be00e76d2be10116672**.

What are they. how can I solve the issue

```auto

**sample code 2:**

This sample code 2 below also displays **null value** as result. It seems some parameters needed to be passed as objects or arrays. can someone hep me out

<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/payments/utilities.php";
include($path);
$body = [
    'receipt_email' => 'johndow@rapyd.net',
     "amount"=> 100,
    "currency"=> "USD",
    "description"=> "Payment by card token",
  "ewallets"=> [
            "ewallet"=> "ewalletmy-ewallet-id-goes-here",
            "percentage"=> 100 
    ],
"metadata"=> [
        "merchant_defined"=> true
    ],

    "payment_method"=> [
    "type"=> "is_visa_card",
    "fields"=> [
        "name"=> "Test User",
        "number"=> "4111111111111111",
        "expiration_month"=> "08",
        "expiration_year"=> "24",
        "cvv"=> "789"
    ],
    "complete_payment_url"=> "http://localhost/success.php",
    "error_payment_url"=> "http://localhost/error.php"
    ],

     "address"=> [
        "name"=> 'John Doe',
        "line_1"=> '123 Main Street',
        "line_2"=> 'Penthouse',
        "line_3"=> '',
        "city"=> 'Anytown',
        "district"=> '',
        "canton"=> '',
        "state"=> 'NY',
        "country"=> 'US',
        "zip"=> '12345',
        "phone_number"=> '16125551234'
      ]
];

try {
    $object = make_request('post', '/v1/payments', $body);
    var_dump($object);
} catch(Exception $e) {
    echo "Error: $e";
}

?>

```

---

<div class="post-metadata">

**Author:** ![CharlesDorsett](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/charlesdorsett/32/47_2.png) [@CharlesDorsett](https://community.rapyd.net/u/CharlesDorsett)\
**Post date:** [June 19, 2021, 6:24pm UTC](https://community.rapyd.net/t/make-payment-in-php-to-rapyd-collect/482/2 "2021-06-19T18:24:23Z")

</div>

I answered this on Slack. See [https://formula0001ra-ofh1119.slack.com/archives/C0233AFKP4N/p1623965202208900](https://formula0001ra-ofh1119.slack.com/archives/C0233AFKP4N/p1623965202208900)

---

<div class="post-metadata">

**Author:** ![Community\_Team](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Community\_Team](https://community.rapyd.net/u/Community_Team)\
**Post date:** [May 14, 2022, 9:43pm UTC](https://community.rapyd.net/t/make-payment-in-php-to-rapyd-collect/482/3 "2022-05-14T21:43:39Z")

</div>

[REPOSTING FROM SLACK]:

Regarding your first example, I note the following points:

- You are mixing quotes - some are single and some are double. It might be better to stick with one style.
- The body of your request looks like a ‘Create Payment’, but in your try block, you are using ‘Update Payment’, which will ignore most of what you put in the body.
- Your use of the card ID implies that the card has previously been added to a customer or created with ‘Create Card Token - Hosted Page’
- In the ‘ewallet’ field, you must put the Rapyd ID of a previously created Rapyd Wallet, which is a string starting with **ewallet\_**. If you omit it, the payment will go into your Rapyd-defined client wallet, which may or may not be the one you want.

Regarding your second example, I note the following:

- `payment_method` needs to be an array (PHP array)
- `fields` needs to be a PHP array
- each `ewallet` JSON object needs to be a PHP array
- If you want to use `address` for this example, then it needs to be a PHP array, too.

See the PHP example on [Create Group Payment](https://docs.rapyd.net/build-with-rapyd/reference/group-payment-object#create-group-payment) for examples of the syntax.
