Example #1
0
<?php

require 'header.php';
$post_url = "shipping-address.php";
$unid_name = 'address_unid';
if (isset($_POST['insert_or_edit'])) {
    $insert_update_array = array('address_line_1' => mysql_real_escape_string($_POST['address_line_1']), 'address_line_2' => mysql_real_escape_string($_POST['address_line_2']), 'city' => mysql_real_escape_string($_POST['city']), 'state' => mysql_real_escape_string($_POST['state']), 'zip' => mysql_real_escape_string($_POST['zip']), 'user_unid' => $user_unid);
    if ($_POST['insert_or_edit'] == 'insert') {
        $do_script = db_insert_array($insert_update_array, 'website_address');
    }
    if ($_POST['insert_or_edit'] == 'edit') {
        //unset($array1[2]); // delete known index(2) value from array
        //var_dump($array1);
        $last_field = array_pop($insert_update_array);
        $do_script = db_update_array($insert_update_array, "website_address", "WHERE address_unid = '{$edit_unid}' AND user_unid = '{$user_unid}'");
    }
}
if (isset($delete_unid)) {
    $do_script = db_delete("website_address", "WHERE address_unid = '{$delete_unid}' AND user_unid = '{$user_unid}'");
}
if (isset($_GET['edit_unid'])) {
    $edit_shipping = db_get_single("SELECT * FROM website_address WHERE address_unid = '{$edit_unid}' AND user_unid = '{$user_unid}'");
} else {
    $edit_shipping = db_get_single("SELECT * FROM website_address WHERE blank = '1'");
}
$result = db_query("SELECT * FROM website_address WHERE user_unid = '{$user_unid}'");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
Example #2
0
    $result = file_get_contents($url, false, $context);
    $resp = json_decode($result);
    if (isset($resp->stripe_user_id)) {
        $stripe_user_id = $resp->stripe_user_id;
        $query1 = "SELECT * FROM website_users_to_sellers WHERE stripe_user_id = '{$stripe_user_id}' AND user_unid = '{$user_unid}'";
        $result1 = mysql_query($query1);
        if (!$result1) {
            die('Invalid query: ' . mysql_error());
        }
        if (mysql_num_rows($result1) == 0) {
            Stripe\Stripe::setApiKey($resp->access_token);
            $seller_account = Stripe\Account::retrieve($stripe_user_id);
            $seller_insert = array('stripe_user_id' => $resp->stripe_user_id, 'access_token' => $resp->access_token, 'stripe_publishable_key' => $resp->stripe_publishable_key, 'refresh_token' => $resp->refresh_token, 'created_user_unid' => $user_unid, 'address_line2' => $seller_account->legal_entity[0]->address->line1, 'address_line2' => $seller_account->legal_entity[0]->address->line2, 'address_city' => $seller_account->legal_entity[0]->address->city, 'address_state' => $seller_account->legal_entity[0]->address->state, 'address_poastal_code' => $seller_account->legal_entity[0]->address->postal_code, 'business_url' => $seller_account->business_url, 'account_email' => $seller_account->email, 'business_name' => $seller_account->business_name, 'display_name' => $seller_account->display_name, 'timezone' => $seller_account->timezone, 'first_name' => $seller_account->legal_entity[1]->first_name, 'last_name' => $seller_account->legal_entity[1]->last_name, 'type' => $seller_account->legal_entity[0]->type);
            $seller_unid = db_insert_array($seller_insert, 'website_seller_account');
            $user_to_account = array('seller_unid' => $seller_unid, 'user_unid' => $user_unid, 'stripe_user_id' => $stripe_user_id, 'type' => $seller_account->legal_entity[0]->type);
            $do_script = db_insert_array($user_to_account, 'website_users_to_sellers');
            //header("Location: /seller-accounts.php");
        }
        // no duplicate accounts
        $url_error = urlencode('Duplicate Stripe/Seller Account');
        header("Location: /seller-accounts.php?error={$url_error}");
    }
    // isset sctripe account
} else {
    if (isset($_GET['error'])) {
        // Error
        echo $_GET['error_description'];
    } else {
        // Show OAuth link
        $authorize_request_body = array('response_type' => 'code', 'scope' => 'read_write', 'client_id' => CLIENT_ID);
        $url = AUTHORIZE_URI . '?' . http_build_query($authorize_request_body);