shakurov / laravel-coinbase

Laravel wrapper for the Coinbase Commerce API
MIT License
44 stars 24 forks source link

How can I redirect user to my website page after paying? #17

Closed Haruteghiazaryan1987 closed 1 year ago

jeybin commented 2 years ago

Give the url as parameter while creating charge, you can pass

$newRequest['name'] = $payment_name;
$newRequest['description'] = $payment_description;
$newRequest['pricing_type'] = 'fixed_price';
$newRequest['metadata'] = [
    'customer_id' => $customer_email,
    'customer_name' => $customer_name
];
$newRequest['local_price'] = ['currency' => $currency, 'amount' => $amount];
$newRequest['redirect_url'] = 'https//example.com/payment-success';
$newRequest['cancel_url'] = 'https//example.com/payment-cancelled';

Coinbase::createCharge($newRequest);

The request will be as below

{
    "name": "Payment name",
    "description": "payment description",
    "pricing_type": "fixed_price",
    "metadata": {
        "customer_id": "customer_id",
        "customer_name": "customer_name"
    },
    "local_price": {
        "currency": "USD",
        "amount": 1000
    },
    "redirect_url": "https//example.com/payment-success",
    "cancel_url": "https//example.com/payment-cancelled"
}
antimech commented 1 year ago

https://docs.cloud.coinbase.com/commerce/reference/createcharge

$charge = Coinbase::createCharge([
    'name' => 'Name',
    'description' => 'Description',
    'local_price' => [
        'amount' => 100,
        'currency' => 'USD',
    ],
    'pricing_type' => 'fixed_price',
    'redirect_url' => 'https//example.com/payment-success',
]);